Skip to content

Commit

Permalink
more fixes and configuration adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Nov 14, 2024
1 parent 4454c58 commit 69fd74c
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 94 deletions.
37 changes: 21 additions & 16 deletions packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ExtrinsicConfigBuilder } from '../../ExtrinsicBuilder.interfaces';
import {
getExtrinsicArgumentVersion,
normalizeConcrete,
normalizeX1,
} from '../../ExtrinsicBuilder.utils';
import {
getPolkadotXcmExtrinsicArgs,
Expand All @@ -22,54 +23,58 @@ export function polkadotXcm() {
new ExtrinsicConfig({
module: pallet,
func,
getArgs: (extrinsicFunction) =>
getPolkadotXcmExtrinsicArgs({
getArgs: (extrinsicFunction) => {
const version = getExtrinsicArgumentVersion(extrinsicFunction);
return getPolkadotXcmExtrinsicArgs({
...params,
func: extrinsicFunction,
asset: [
{
id: {
Concrete: {
parents: 0,
interior: 'Here',
},
},
id: normalizeConcrete(version, {
parents: 0,
interior: 'Here',
}),
fun: {
Fungible: params.asset.amount,
},
},
],
}),
});
},
}),
}),
X1: (): ExtrinsicConfigBuilder => ({
build: (params) =>
new ExtrinsicConfig({
module: pallet,
func,
getArgs: (extrinsicFunction) =>
getPolkadotXcmExtrinsicArgs({
getArgs: (extrinsicFunction) => {
const version = getExtrinsicArgumentVersion(extrinsicFunction);

return getPolkadotXcmExtrinsicArgs({
...params,
func: extrinsicFunction,
asset: [
{
id: {
Concrete: {
id: normalizeConcrete(
version,
normalizeX1(version, {
parents: 0,
interior: {
X1: {
PalletInstance:
params.asset.getAssetPalletInstance(),
},
},
},
},
}),
),
fun: {
Fungible: params.asset.amount,
},
},
],
}),
});
},
}),
}),
X2: (): ExtrinsicConfigBuilder => ({
Expand Down
51 changes: 26 additions & 25 deletions packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
type ExtrinsicConfigBuilder,
XcmVersion,
} from '../../ExtrinsicBuilder.interfaces';
import { getExtrinsicArgumentVersion } from '../../ExtrinsicBuilder.utils';
import {
getExtrinsicArgumentVersion,
normalizeConcrete,
normalizeX1,
} from '../../ExtrinsicBuilder.utils';
import { getDestination, getWeight } from './xTokens.utils';

const pallet = 'xTokens';
Expand Down Expand Up @@ -44,12 +48,10 @@ export function xTokens() {
return [
{
[version]: {
id: {
Concrete: {
parents: 0,
interior: 'Here',
},
},
id: normalizeConcrete(version, {
parents: 0,
interior: 'Here',
}),
fun: {
Fungible: asset.amount,
},
Expand All @@ -72,16 +74,17 @@ export function xTokens() {
return [
{
[version]: {
id: {
Concrete: {
id: normalizeConcrete(
version,
normalizeX1(version, {
parents: 1,
interior: {
X1: {
Parachain: originParachainId,
},
},
},
},
}),
),
fun: {
Fungible: asset.amount,
},
Expand All @@ -104,21 +107,19 @@ export function xTokens() {
return [
{
[version]: {
id: {
Concrete: {
parents: 1,
interior: {
X2: [
{
Parachain: originParachainId,
},
{
GeneralKey: asset.getAssetId(),
},
],
},
id: normalizeConcrete(version, {
parents: 1,
interior: {
X2: [
{
Parachain: originParachainId,
},
{
GeneralKey: asset.getAssetId(),
},
],
},
},
}),
fun: {
Fungible: asset.amount,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function buildSendExtrinsic({

return sourceApi.tx.polkadotXcm.send(
{
// TODO apply XCM versioning
V3: {
parents: 1,
interior: { X1: { Parachain: moonChain.parachainId } },
Expand Down
7 changes: 7 additions & 0 deletions packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,9 @@ export const moonbaseAlpha = new EvmParachain({
ChainAsset.fromAsset(ftmwh, {
address: '0x566c1cebc6A4AFa1C122E039C4BEBe77043148Ee',
decimals: 18,
ids: {
palletInstance: 48,
},
}),
ChainAsset.fromAsset(hdx, {
address: '0xFFFfFfff345Dc44DDAE98Df024Eb494321E73FcC',
Expand All @@ -943,6 +946,9 @@ export const moonbaseAlpha = new EvmParachain({
ChainAsset.fromAsset(usdcwh, {
address: '0xE5dE10C4b744bac6b783fAF8d9B9fDFF14Acc3c9',
decimals: 6,
ids: {
palletInstance: 48,
},
}),
ChainAsset.fromAsset(agng, {
address: '0xFFfFFFFF38794F8c53fC7325ea07463dc6965e20',
Expand Down Expand Up @@ -2228,6 +2234,7 @@ export const chainsList: AnyChain[] = [
moonriver,
neuroweb,
originTrailAlphanet,
peaqAlphanet,
peaqChain,
peaqEvm,
peaqEvmAlphanet,
Expand Down
52 changes: 1 addition & 51 deletions packages/config/src/xcm-configs/moonbaseBeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ExtrinsicBuilder,
FeeBuilder,
} from '@moonbeam-network/xcm-builder';
import { alan, betaDEV, dev, ftmwh, usdcwh } from '../assets';
import { alan, betaDEV, dev } from '../assets';
import { moonbaseAlpha, moonbaseBeta } from '../chains';
import { ChainRoutes } from '../types/ChainRoutes';

Expand Down Expand Up @@ -60,55 +60,5 @@ export const moonbaseBetaRoutes = new ChainRoutes({
},
extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(),
},
{
source: {
asset: usdcwh,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: betaDEV,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().system().account(),
},
},
destination: {
asset: usdcwh,
chain: moonbaseAlpha,
balance: BalanceBuilder().evm().erc20(),
fee: {
amount: FeeBuilder()
.xcmPaymentApi()
.xcmPaymentFee({ isAssetReserveChain: true }),
asset: dev,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(),
},
{
source: {
asset: ftmwh,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: betaDEV,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().system().account(),
},
},
destination: {
asset: ftmwh,
chain: moonbaseAlpha,
balance: BalanceBuilder().evm().erc20(),
fee: {
amount: FeeBuilder()
.xcmPaymentApi()
.xcmPaymentFee({ isAssetReserveChain: true }),
asset: dev,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(),
},
],
});
2 changes: 1 addition & 1 deletion packages/config/src/xcm-configs/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ export const moonbeamRoutes = new ChainRoutes({
chain: darwinia,
balance: BalanceBuilder().substrate().system().account(),
fee: {
amount: 4,
amount: 0.1,
asset: ring,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/xcm-configs/moonriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const moonriverRoutes = new ChainRoutes({
chain: darwiniaCrab,
balance: BalanceBuilder().substrate().system().account(),
fee: {
amount: 4,
amount: 0.1,
asset: crab,
},
},
Expand Down

0 comments on commit 69fd74c

Please sign in to comment.