diff --git a/.changeset/healthy-forks-teach.md b/.changeset/healthy-forks-teach.md new file mode 100644 index 00000000..abade9fe --- /dev/null +++ b/.changeset/healthy-forks-teach.md @@ -0,0 +1,7 @@ +--- +'@moonbeam-network/xcm-builder': patch +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +Change Astar and Shiden pallet and fix Any keyword error diff --git a/packages/builder/src/extrinsic/ExtrinsicBuilder.utils.ts b/packages/builder/src/extrinsic/ExtrinsicBuilder.utils.ts index 938477d1..b7310b60 100644 --- a/packages/builder/src/extrinsic/ExtrinsicBuilder.utils.ts +++ b/packages/builder/src/extrinsic/ExtrinsicBuilder.utils.ts @@ -38,13 +38,12 @@ export function getExtrinsicArgumentVersion( } export function getExtrinsicAccount(address: string) { - const isEthAddress = address.length === 42; + const isEthAddress = address.length === 42 && address.startsWith('0x'); return isEthAddress ? { AccountKey20: { key: address, - network: 'Any', }, } : { diff --git a/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap b/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap index 8b2f83cf..5cba6c8e 100644 --- a/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/eqBalances/__snapshots__/eqBalances.test.ts.snap @@ -28,7 +28,6 @@ exports[`eqBalances transferXcm should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], @@ -98,7 +97,6 @@ exports[`eqBalances xcmTransfer should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], diff --git a/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap b/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap index 635b285f..28783af1 100644 --- a/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/polkadotXcm/__snapshots__/polkadotXcm.test.ts.snap @@ -27,7 +27,6 @@ exports[`polkadotXcm limitedReserveTransferAssets here should get correct argume "X1": { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, }, @@ -144,7 +143,6 @@ exports[`polkadotXcm limitedReserveTransferAssets x1 should get correct argument "X1": { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, }, @@ -202,7 +200,6 @@ exports[`polkadotXcm limitedReserveTransferAssets x2 should get correct argument "X1": { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, }, @@ -328,7 +325,6 @@ exports[`polkadotXcm limitedReserveWithdrawAssets x2 should get correct argument "X1": { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, }, diff --git a/packages/builder/src/extrinsic/pallets/xTokens/__snapshots__/xTokens.test.ts.snap b/packages/builder/src/extrinsic/pallets/xTokens/__snapshots__/xTokens.test.ts.snap index 905be276..e388f1bd 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/__snapshots__/xTokens.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/xTokens/__snapshots__/xTokens.test.ts.snap @@ -23,7 +23,6 @@ exports[`xTokens transfer should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], @@ -128,7 +127,6 @@ exports[`xTokens transferMultiAsset x1 should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], @@ -183,7 +181,6 @@ exports[`xTokens transferMultiAsset x2 should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], @@ -271,7 +268,6 @@ exports[`xTokens transferMultiCurrencies x2 should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], diff --git a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts index a5eca27d..5a55f22a 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts +++ b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts @@ -3,12 +3,9 @@ import { ExtrinsicConfigBuilder, XcmVersion, } from '../../ExtrinsicBuilder.interfaces'; -import { - getExtrinsicAccount, - getExtrinsicArgumentVersion, -} from '../../ExtrinsicBuilder.utils'; +import { getExtrinsicArgumentVersion } from '../../ExtrinsicBuilder.utils'; import { ExtrinsicConfig } from '../../ExtrinsicConfig'; -import { getWeight } from './xTokens.utils'; +import { getDestination, getWeight } from './xTokens.utils'; const pallet = 'xTokens'; @@ -25,19 +22,7 @@ export function xTokens() { return [ asset, amount, - { - [version]: { - parents: 1, - interior: { - X2: [ - { - Parachain: destination.parachainId, - }, - getExtrinsicAccount(address), - ], - }, - }, - }, + getDestination(version, address, destination), getWeight(source.weight, func), ]; }, @@ -47,6 +32,34 @@ export function xTokens() { const funcName = 'transferMultiasset'; return { + here: (): ExtrinsicConfigBuilder => ({ + build: ({ address, amount, destination }) => + new ExtrinsicConfig({ + module: pallet, + func: funcName, + getArgs: (func) => { + const version = getExtrinsicArgumentVersion(func, 1); + + return [ + { + [version]: { + id: { + Concrete: { + parents: 0, + interior: 'Here', + }, + }, + fun: { + Fungible: amount, + }, + }, + }, + getDestination(version, address, destination), + 'Unlimited', + ]; + }, + }), + }), X1: (): ExtrinsicConfigBuilder => ({ build: ({ address, amount, destination }) => new ExtrinsicConfig({ @@ -73,19 +86,7 @@ export function xTokens() { }, }, }, - { - [version]: { - parents: 1, - interior: { - X2: [ - { - Parachain: destination.parachainId, - }, - getExtrinsicAccount(address), - ], - }, - }, - }, + getDestination(version, address, destination), 'Unlimited', ]; }, @@ -122,19 +123,7 @@ export function xTokens() { }, }, }, - { - [version]: { - parents: 1, - interior: { - X2: [ - { - Parachain: destination.parachainId, - }, - getExtrinsicAccount(address), - ], - }, - }, - }, + getDestination(version, address, destination), getWeight(source.weight, func), ]; }, @@ -153,19 +142,7 @@ export function xTokens() { [feeAsset, fee], ], 1, - { - [XcmVersion.v3]: { - parents: 1, - interior: { - X2: [ - { - Parachain: destination.parachainId, - }, - getExtrinsicAccount(address), - ], - }, - }, - }, + getDestination(XcmVersion.v3, address, destination), 'Unlimited', ], }), diff --git a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts index 27a83b9a..2b44f740 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts +++ b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts @@ -1,4 +1,7 @@ +import { AnyChain } from '@moonbeam-network/xcm-types'; import { SubmittableExtrinsicFunction } from '@polkadot/api/types'; +import { XcmVersion } from '../../ExtrinsicBuilder.interfaces'; +import { getExtrinsicAccount } from '../../ExtrinsicBuilder.utils'; import { XTokensWeightLimit } from './xTokens.interfaces'; /** @@ -27,3 +30,24 @@ export function getWeight( return weight; } + +export function getDestination( + version: XcmVersion, + address: string, + destination: AnyChain, +) { + return { + [version]: { + parents: 1, + // eslint-disable-next-line sort-keys + interior: { + X2: [ + { + Parachain: destination.parachainId, + }, + getExtrinsicAccount(address), + ], + }, + }, + }; +} diff --git a/packages/builder/src/extrinsic/pallets/xTransfer/__snapshots__/xTransfer.test.ts.snap b/packages/builder/src/extrinsic/pallets/xTransfer/__snapshots__/xTransfer.test.ts.snap index 7b4367ed..4c6955f4 100644 --- a/packages/builder/src/extrinsic/pallets/xTransfer/__snapshots__/xTransfer.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/xTransfer/__snapshots__/xTransfer.test.ts.snap @@ -31,7 +31,6 @@ exports[`xTransfer transfer here should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], @@ -139,7 +138,6 @@ exports[`xTransfer transfer x2 should get correct arguments 1`] = ` { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, ], diff --git a/packages/builder/src/extrinsic/pallets/xcmPallet/__snapshots__/xcmPallet.test.ts.snap b/packages/builder/src/extrinsic/pallets/xcmPallet/__snapshots__/xcmPallet.test.ts.snap index 4b04961c..7728b9c0 100644 --- a/packages/builder/src/extrinsic/pallets/xcmPallet/__snapshots__/xcmPallet.test.ts.snap +++ b/packages/builder/src/extrinsic/pallets/xcmPallet/__snapshots__/xcmPallet.test.ts.snap @@ -27,7 +27,6 @@ exports[`xcmPallet limitedReserveTransferAssets should get correct arguments 1`] "X1": { "AccountKey20": { "key": "0xeF46c7649270C912704fB09B75097f6E32208b85", - "network": "Any", }, }, }, diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 60294898..01065f0e 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -136,7 +136,6 @@ export const astar = new Parachain({ { asset: glmr, id: 18446744073709551619n, - palletInstance: 10, }, // NOTE: no meta for native token { @@ -1242,7 +1241,6 @@ export const shiden = new Parachain({ { asset: movr, id: 18446744073709551620n, - palletInstance: 10, }, // NOTE: no meta for native token { @@ -1257,7 +1255,7 @@ export const shiden = new Parachain({ name: 'Shiden', parachainId: 2007, ss58Format: 5, - ws: 'wss://rpc.shiden.astar.network', + ws: 'wss://shiden-rpc.dwellir.com', }); export const turing = new Parachain({ diff --git a/packages/config/src/configs/astar.ts b/packages/config/src/configs/astar.ts index b79a0d52..c4e34671 100644 --- a/packages/config/src/configs/astar.ts +++ b/packages/config/src/configs/astar.ts @@ -20,8 +20,8 @@ export const astarConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, extrinsic: ExtrinsicBuilder() - .polkadotXcm() - .limitedReserveTransferAssets() + .xTokens() + .transferMultiAsset(astar.parachainId) .here(), }), new AssetConfig({ @@ -33,10 +33,7 @@ export const astarConfig = new ChainConfig({ asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, - extrinsic: ExtrinsicBuilder() - .polkadotXcm() - .limitedReserveTransferAssets() - .X2(), + extrinsic: ExtrinsicBuilder().xTokens().transfer(), fee: { asset: astr, balance: BalanceBuilder().substrate().system().account(), diff --git a/packages/config/src/configs/khala.ts b/packages/config/src/configs/khala.ts index e56ec5ca..3c6a063b 100644 --- a/packages/config/src/configs/khala.ts +++ b/packages/config/src/configs/khala.ts @@ -26,7 +26,7 @@ export const khalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: 0.001, asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/shiden.ts b/packages/config/src/configs/shiden.ts index 967f592a..6f1baece 100644 --- a/packages/config/src/configs/shiden.ts +++ b/packages/config/src/configs/shiden.ts @@ -20,8 +20,8 @@ export const shidenConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, extrinsic: ExtrinsicBuilder() - .polkadotXcm() - .limitedReserveTransferAssets() + .xTokens() + .transferMultiAsset(shiden.parachainId) .here(), }), new AssetConfig({ @@ -33,10 +33,7 @@ export const shidenConfig = new ChainConfig({ asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, - extrinsic: ExtrinsicBuilder() - .polkadotXcm() - .limitedReserveWithdrawAssets() - .X2(), + extrinsic: ExtrinsicBuilder().xTokens().transfer(), fee: { asset: sdn, balance: BalanceBuilder().substrate().system().account(),