diff --git a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts index 49676399..8c3f1422 100644 --- a/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts +++ b/packages/builder/src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts @@ -3,6 +3,7 @@ import type { ExtrinsicConfigBuilder } from '../../ExtrinsicBuilder.interfaces'; import { getExtrinsicArgumentVersion, normalizeConcrete, + normalizeX1, } from '../../ExtrinsicBuilder.utils'; import { getPolkadotXcmExtrinsicArgs, @@ -22,24 +23,24 @@ 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 => ({ @@ -47,14 +48,17 @@ 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: { + id: normalizeConcrete( + version, + normalizeX1(version, { parents: 0, interior: { X1: { @@ -62,14 +66,15 @@ export function polkadotXcm() { params.asset.getAssetPalletInstance(), }, }, - }, - }, + }), + ), fun: { Fungible: params.asset.amount, }, }, ], - }), + }); + }, }), }), X2: (): ExtrinsicConfigBuilder => ({ diff --git a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts index 47b6f8b4..6ecd7526 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts +++ b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts @@ -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'; @@ -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, }, @@ -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, }, @@ -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, }, diff --git a/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts b/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts index fab440e9..7f74d5de 100644 --- a/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts +++ b/packages/builder/src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts @@ -115,6 +115,7 @@ export function buildSendExtrinsic({ return sourceApi.tx.polkadotXcm.send( { + // TODO apply XCM versioning V3: { parents: 1, interior: { X1: { Parachain: moonChain.parachainId } }, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 3435ee21..bcf08ec0 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -932,6 +932,9 @@ export const moonbaseAlpha = new EvmParachain({ ChainAsset.fromAsset(ftmwh, { address: '0x566c1cebc6A4AFa1C122E039C4BEBe77043148Ee', decimals: 18, + ids: { + palletInstance: 48, + }, }), ChainAsset.fromAsset(hdx, { address: '0xFFFfFfff345Dc44DDAE98Df024Eb494321E73FcC', @@ -943,6 +946,9 @@ export const moonbaseAlpha = new EvmParachain({ ChainAsset.fromAsset(usdcwh, { address: '0xE5dE10C4b744bac6b783fAF8d9B9fDFF14Acc3c9', decimals: 6, + ids: { + palletInstance: 48, + }, }), ChainAsset.fromAsset(agng, { address: '0xFFfFFFFF38794F8c53fC7325ea07463dc6965e20', @@ -2228,6 +2234,7 @@ export const chainsList: AnyChain[] = [ moonriver, neuroweb, originTrailAlphanet, + peaqAlphanet, peaqChain, peaqEvm, peaqEvmAlphanet, diff --git a/packages/config/src/xcm-configs/moonbaseBeta.ts b/packages/config/src/xcm-configs/moonbaseBeta.ts index e0acf549..50ce4de3 100644 --- a/packages/config/src/xcm-configs/moonbaseBeta.ts +++ b/packages/config/src/xcm-configs/moonbaseBeta.ts @@ -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'; @@ -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(), - }, ], }); diff --git a/packages/config/src/xcm-configs/moonbeam.ts b/packages/config/src/xcm-configs/moonbeam.ts index c969dcc3..fba792db 100644 --- a/packages/config/src/xcm-configs/moonbeam.ts +++ b/packages/config/src/xcm-configs/moonbeam.ts @@ -584,7 +584,7 @@ export const moonbeamRoutes = new ChainRoutes({ chain: darwinia, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 4, + amount: 0.1, asset: ring, }, }, diff --git a/packages/config/src/xcm-configs/moonriver.ts b/packages/config/src/xcm-configs/moonriver.ts index 04218017..2c58b14f 100644 --- a/packages/config/src/xcm-configs/moonriver.ts +++ b/packages/config/src/xcm-configs/moonriver.ts @@ -266,7 +266,7 @@ export const moonriverRoutes = new ChainRoutes({ chain: darwiniaCrab, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 4, + amount: 0.1, asset: crab, }, }, diff --git a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap index 30e334ce..04919784 100644 --- a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap +++ b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap @@ -348,7 +348,9 @@ exports[`sdk > getParachainBalances > on 'Moonbase Alpha' for address: '0x4E8214 "address": "0x566c1cebc6A4AFa1C122E039C4BEBe77043148Ee", "amount": 1234567890000000000n, "decimals": 18, - "ids": undefined, + "ids": { + "palletInstance": 48, + }, "key": "ftmwh", "min": undefined, "originSymbol": "FTM.wh", @@ -358,7 +360,9 @@ exports[`sdk > getParachainBalances > on 'Moonbase Alpha' for address: '0x4E8214 "address": "0xE5dE10C4b744bac6b783fAF8d9B9fDFF14Acc3c9", "amount": 10000n, "decimals": 6, - "ids": undefined, + "ids": { + "palletInstance": 48, + }, "key": "usdcwh", "min": undefined, "originSymbol": "USDC.Wh", @@ -475,36 +479,6 @@ exports[`sdk > getParachainBalances > on 'Moonbase Alpha' for address: '0x4E8214 exports[`sdk > getParachainBalances > on 'Moonbase Beta' for address: '0x4E82143Af671Cc8201Bc7efCBbCED3A69e8…' > should get expected balances 1`] = ` [ - _AssetAmount { - "address": undefined, - "amount": 100000000000000000n, - "decimals": 18, - "ids": { - "balanceId": "198801030527939140930753142903035039136", - "id": { - "ForeignAsset": "198801030527939140930753142903035039136", - }, - }, - "key": "ftmwh", - "min": undefined, - "originSymbol": "FTM.wh", - "symbol": undefined, - }, - _AssetAmount { - "address": undefined, - "amount": 0n, - "decimals": 6, - "ids": { - "balanceId": "319794858556516669238969276945382613133", - "id": { - "ForeignAsset": "319794858556516669238969276945382613133", - }, - }, - "key": "usdcwh", - "min": undefined, - "originSymbol": "USDC.Wh", - "symbol": undefined, - }, _AssetAmount { "address": undefined, "amount": 1100000000000000000n,