diff --git a/tests/bridge-sdk/__snapshots__/polkadot.test.ts.snap b/tests/bridge-sdk/__snapshots__/polkadot.test.ts.snap index b760cac..07484c3 100644 --- a/tests/bridge-sdk/__snapshots__/polkadot.test.ts.snap +++ b/tests/bridge-sdk/__snapshots__/polkadot.test.ts.snap @@ -129,7 +129,7 @@ exports[`'polkadot' to 'acala' using bridgeSDK cross-chain 'DOT' > parachain bri } `; -exports[`'polkadot' to 'acala' using bridgeSDK cross-chain 'DOT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.0001)"`; +exports[`'polkadot' to 'acala' using bridgeSDK cross-chain 'DOT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > fee 1`] = `"(rounded 0.0002)"`; exports[`'polkadot' to 'acala' using bridgeSDK cross-chain 'DOT' > parachain bridge to releaychain > Cross-chain using BridgeSDK works > initial 1`] = ` { diff --git a/tests/xcm-transfer/__snapshots__/polkadot-para.test.ts.snap b/tests/xcm-transfer/__snapshots__/polkadot-para.test.ts.snap index 8362e39..6fdceb7 100644 --- a/tests/xcm-transfer/__snapshots__/polkadot-para.test.ts.snap +++ b/tests/xcm-transfer/__snapshots__/polkadot-para.test.ts.snap @@ -1,200 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`'acala' -> 'hydraDX' xcm transfer 'DAI' > xtokens transfer > balance on from chain 1`] = `99000000000000000000`; - -exports[`'acala' -> 'hydraDX' xcm transfer 'DAI' > xtokens transfer > balance on to chain 1`] = ` -{ - "free": "(rounded 100000000000000000000)", - "frozen": 0, - "reserved": 0, -} -`; - -exports[`'acala' -> 'hydraDX' xcm transfer 'DAI' > xtokens transfer > from chain hrmp messages 1`] = ` -[ - { - "data": [ - "ConcatenatedVersionedXcm", - { - "v2": [ - { - "reserveAssetDeposited": [ - { - "fun": { - "fungible": "0x00000000000000000de0b6b3a7640000", - }, - "id": { - "concrete": { - "interior": { - "x2": [ - { - "parachain": 2000, - }, - { - "generalKey": "0x0254a37a01cd75b616d63e0ab665bffdb0143c52ae", - }, - ], - }, - "parents": 1, - }, - }, - }, - ], - }, - { - "clearOrigin": null, - }, - { - "buyExecution": { - "fees": { - "fun": { - "fungible": "0x00000000000000000de0b6b3a7640000", - }, - "id": { - "concrete": { - "interior": { - "x2": [ - { - "parachain": 2000, - }, - { - "generalKey": "0x0254a37a01cd75b616d63e0ab665bffdb0143c52ae", - }, - ], - }, - "parents": 1, - }, - }, - }, - "weightLimit": { - "unlimited": null, - }, - }, - }, - { - "depositAsset": { - "assets": { - "wild": { - "all": null, - }, - }, - "beneficiary": { - "interior": { - "x1": { - "accountId32": { - "id": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee", - "network": { - "any": null, - }, - }, - }, - }, - "parents": 0, - }, - "maxAssets": 1, - }, - }, - ], - }, - ], - "recipient": 2034, - }, -] -`; - -exports[`'acala' -> 'hydraDX' xcm transfer 'DAI' > xtokens transfer > to chain xcm events 1`] = ` -[ - { - "data": { - "messageHash": "(hash)", - "messageId": "(hash)", - "weight": { - "proofSize": 0, - "refTime": 400000000, - }, - }, - "method": "Success", - "section": "xcmpQueue", - }, -] -`; - -exports[`'acala' -> 'hydraDX' xcm transfer 'DAI' > xtokens transfer > tx events 1`] = ` -[ - { - "data": { - "assets": [ - { - "fun": { - "Fungible": 1000000000000000000, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "Parachain": 2000, - }, - { - "GeneralKey": { - "data": "(hash)", - "length": 21, - }, - }, - ], - }, - "parents": 1, - }, - }, - }, - ], - "dest": { - "interior": { - "X2": [ - { - "Parachain": "(rounded 2000)", - }, - { - "AccountId32": { - "id": "(hash)", - "network": null, - }, - }, - ], - }, - "parents": 1, - }, - "fee": { - "fun": { - "Fungible": 1000000000000000000, - }, - "id": { - "Concrete": { - "interior": { - "X2": [ - { - "Parachain": 2000, - }, - { - "GeneralKey": { - "data": "(hash)", - "length": 21, - }, - }, - ], - }, - "parents": 1, - }, - }, - }, - "sender": "23y3WetbNi6rDMgHmyRDjgpb7PnhgPotuPPawxruTMLYTLzG", - }, - "method": "TransferredMultiAssets", - "section": "xTokens", - }, -] -`; - exports[`'acala' -> 'moonbeam' xcm transfer 'DOT' > xtokens transfer > balance on from chain 1`] = ` { "free": 9000000000000, @@ -607,6 +412,204 @@ exports[`'acala' -> 'statemint' xcm transfer 'WBTC' > xtokens transfer > tx even ] `; +exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > balance on from chain 1`] = ` +{ + "balance": 9000000000000, + "extra": null, + "reason": { + "consumer": null, + }, + "status": "Liquid", +} +`; + +exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > balance on to chain 1`] = ` +{ + "free": "(rounded 11000000000000)", + "frozen": 0, + "reserved": 0, +} +`; + +exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > from chain ump messages 1`] = ` +[ + { + "v3": [ + { + "withdrawAsset": [ + { + "fun": { + "fungible": 1000000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + ], + }, + { + "clearOrigin": null, + }, + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 500000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 0, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositReserveAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "dest": { + "interior": { + "x1": { + "parachain": 2000, + }, + }, + "parents": 0, + }, + "xcm": [ + { + "buyExecution": { + "fees": { + "fun": { + "fungible": 500000000000, + }, + "id": { + "concrete": { + "interior": { + "here": null, + }, + "parents": 1, + }, + }, + }, + "weightLimit": { + "unlimited": null, + }, + }, + }, + { + "depositAsset": { + "assets": { + "wild": { + "allCounted": 1, + }, + }, + "beneficiary": { + "interior": { + "x1": { + "accountId32": { + "id": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee", + "network": null, + }, + }, + }, + "parents": 0, + }, + }, + }, + ], + }, + }, + ], + }, +] +`; + +exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > to chain xcm events 1`] = ` +[ + { + "data": { + "messageHash": "(hash)", + "messageId": "(hash)", + "outcome": { + "Complete": { + "proofSize": 0, + "refTime": 1000000000, + }, + }, + }, + "method": "ExecutedDownward", + "section": "dmpQueue", + }, +] +`; + +exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > tx events 1`] = ` +[ + { + "data": { + "assets": [ + { + "fun": { + "Fungible": 1000000000000, + }, + "id": { + "Concrete": { + "interior": "Here", + "parents": 1, + }, + }, + }, + ], + "dest": { + "interior": { + "X2": [ + { + "Parachain": 2000, + }, + { + "AccountId32": { + "id": "(hash)", + "network": null, + }, + }, + ], + }, + "parents": 1, + }, + "fee": { + "fun": { + "Fungible": 1000000000000, + }, + "id": { + "Concrete": { + "interior": "Here", + "parents": 1, + }, + }, + }, + "sender": "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac", + }, + "method": "TransferredMultiAssets", + "section": "xTokens", + }, +] +`; + exports[`'statemint' -> 'acala' xcm transfer 'WBTC' > xcmPallet transfer > balance on from chain 1`] = ` { "balance": 90000000, diff --git a/tests/xcm-transfer/polkadot-para.test.ts b/tests/xcm-transfer/polkadot-para.test.ts index 5d6fc5c..e6caa66 100644 --- a/tests/xcm-transfer/polkadot-para.test.ts +++ b/tests/xcm-transfer/polkadot-para.test.ts @@ -2,7 +2,6 @@ import { Context } from '../../networks/types' import { query, tx } from '../../helpers/api' import { acala } from '../../networks/acala' -import { hydraDX } from '../../networks/hydraDX' import { moonbeam } from '../../networks/moonbeam' import { statemint } from '../../networks/statemint' @@ -68,50 +67,6 @@ const tests = [ }, }, }, - // acala <-> hydraDX - { - from: 'acala', - to: 'hydraDX', - name: 'DAI', - precision: 2, // fee varies a lot on hydraDX - fromStorage: { - Evm: { - accountStorages: [ - [ - [ - acala.dai.Erc20, - '0x2aef47e62c966f0695d5af370ddc1bc7c56902063eee60853e2872fc0ff4f88c', // balanceOf(Alice) - ], - '0x0000000000000000000000000000000000000000000000056bc75e2d63100000', // 1e20 - ], - ], - }, - }, - test: { - xtokenstHorizontal: { - tx: tx.xtokens.transfer(acala.dai, 10n ** 18n, tx.xtokens.parachainV3(hydraDX.paraId)), - fromBalance: query.evm(acala.dai.Erc20, '0x2aef47e62c966f0695d5af370ddc1bc7c56902063eee60853e2872fc0ff4f88c'), - toBalance: query.tokens(hydraDX.dai), - }, - }, - }, - // { - // from: 'hydraDX', - // to: 'acala', - // name: 'DAI', - // fromStorage: ({ alice }: Context) => ({ - // Tokens: { - // accounts: [[[alice.address, hydraDX.dai], { free: 10n * 10n ** 18n }]], - // }, - // }), - // test: { - // xtokenstHorizontal: { - // tx: tx.xtokens.transfer(hydraDX.dai, 10n ** 18n, tx.xtokens.parachainV3(acala.paraId)), - // fromBalance: query.tokens(hydraDX.dai), - // toBalance: query.evm(acala.dai.Erc20, '0x2aef47e62c966f0695d5af370ddc1bc7c56902063eee60853e2872fc0ff4f88c'), - // }, - // }, - // }, // acala <-> moonbeam { from: 'acala', @@ -128,26 +83,26 @@ const tests = [ }, }, }, - // { - // from: 'moonbeam', - // to: 'acala', - // route: 'polkadot', - // name: 'DOT', - // fromAccount: ({ alith }: Context) => alith, - // fromStorage: ({ alith }: Context) => ({ - // Assets: { - // account: [[[moonbeam.dot, alith.address], { balance: 10e12 }]], - // }, - // }), - // test: { - // xtokenstHorizontal: { - // tx: tx.xtokens.transfer({ ForeignAsset: moonbeam.dot }, 1e12, tx.xtokens.parachainV3(acala.paraId)), - // fromBalance: query.assets(moonbeam.dot), - // toBalance: query.tokens(acala.dot), - // checkUmp: true, - // }, - // }, - // }, + { + from: 'moonbeam', + to: 'acala', + route: 'polkadot', + name: 'DOT', + fromAccount: ({ alith }: Context) => alith, + fromStorage: ({ alith }: Context) => ({ + Assets: { + account: [[[moonbeam.dot, alith.address], { balance: 10e12 }]], + }, + }), + test: { + xtokenstHorizontal: { + tx: tx.xtokens.transfer({ ForeignAsset: moonbeam.dot }, 1e12, tx.xtokens.parachainV3(acala.paraId)), + fromBalance: query.assets(moonbeam.dot), + toBalance: query.tokens(acala.dot), + checkUmp: true, + }, + }, + }, ] as const export type TestType = (typeof tests)[number] diff --git a/tests/xcm-transfer/shared.ts b/tests/xcm-transfer/shared.ts index 89f60dc..6a13416 100644 --- a/tests/xcm-transfer/shared.ts +++ b/tests/xcm-transfer/shared.ts @@ -38,10 +38,10 @@ export default function buildTest(tests: ReadonlyArray) { toAccount = (opt.toAccount as any)(ctx) } - let precision = 3 - if ('precision' in opt) { - precision = opt.precision - } + const precision = 3 + // if ('precision' in opt) { + // precision = opt.precision + // } beforeEach(async () => { const networkOptions = { @@ -115,11 +115,17 @@ export default function buildTest(tests: ReadonlyArray) { await checkEvents(tx0, 'xcmPallet').redact({ number: precision }).toMatchSnapshot('tx events') await toChain.chain.newBlock() + if (toChain.api.query.messageQueue) { + // messageQueue always delay XCM for one block for no good reason https://github.com/paritytech/polkadot-sdk/issues/3709 + await toChain.chain.newBlock() + } await check(balance(toChain, toAccount.address)) .redact({ number: precision }) .toMatchSnapshot('balance on to chain') - await checkSystemEvents(toChain, 'parachainSystem', 'dmpQueue').toMatchSnapshot('to chain dmp events') + await checkSystemEvents(toChain, 'parachainSystem', 'dmpQueue', 'messageQueue').toMatchSnapshot( + 'to chain dmp events', + ) }, 240000) } @@ -148,11 +154,17 @@ export default function buildTest(tests: ReadonlyArray) { await routeChain.chain.newBlock() } await toChain.chain.newBlock() + if (toChain.api.query.messageQueue) { + // messageQueue always delay XCM for one block for no good reason https://github.com/paritytech/polkadot-sdk/issues/3709 + await toChain.chain.newBlock() + } await check(toBalance(toChain, toAccount.address)) .redact({ number: precision }) .toMatchSnapshot('balance on to chain') - await checkSystemEvents(toChain, 'xcmpQueue', 'dmpQueue').toMatchSnapshot('to chain xcm events') + await checkSystemEvents(toChain, 'xcmpQueue', 'dmpQueue', 'messageQueue').toMatchSnapshot( + 'to chain xcm events', + ) }, 240000) } @@ -180,11 +192,17 @@ export default function buildTest(tests: ReadonlyArray) { await routeChain.chain.newBlock() } await toChain.chain.newBlock() + if (toChain.api.query.messageQueue) { + // messageQueue always delay XCM for one block for no good reason https://github.com/paritytech/polkadot-sdk/issues/3709 + await toChain.chain.newBlock() + } await check(toBalance(toChain, toAccount.address)) .redact({ number: precision }) .toMatchSnapshot('balance on to chain') - await checkSystemEvents(toChain, 'xcmpQueue', 'dmpQueue').toMatchSnapshot('to chain xcm events') + await checkSystemEvents(toChain, 'xcmpQueue', 'dmpQueue', 'messageQueue').toMatchSnapshot( + 'to chain xcm events', + ) }, 240000) } }) diff --git a/wasm/acala-2240.wasm b/wasm/acala-2240.wasm new file mode 100644 index 0000000..8a4c221 Binary files /dev/null and b/wasm/acala-2240.wasm differ diff --git a/wasm/karura-2240.wasm b/wasm/karura-2240.wasm new file mode 100644 index 0000000..7651a02 Binary files /dev/null and b/wasm/karura-2240.wasm differ