Skip to content

Commit

Permalink
update Moonbeam XCM (#217)
Browse files Browse the repository at this point in the history
* update Moonbeam XCM

* Update darwinia.ts
  • Loading branch information
StrawberryFlavor authored Nov 26, 2024
1 parent 0a39634 commit 4cceb95
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
40 changes: 40 additions & 0 deletions helpers/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ export const xcmPallet = {
},
},
}),
parachainV4: (parents: number, paraId: any) => ({
V4: {
parents,
interior: {
X1: [{ Parachain: paraId }],
},
},
}),

limitedTeleportAssets:
(token: any, amount: any, dest: any) =>
({ api }: { api: ApiPromise }, acc: any) =>
Expand Down Expand Up @@ -206,6 +215,37 @@ export const xcmPallet = {
0,
'Unlimited',
),
transferAssetsV4:
(token: any, amount: any, dest: any) =>
({ api }: { api: ApiPromise }, acc: any) =>
(api.tx.xcmPallet || api.tx.polkadotXcm).transferAssets(
dest,
{
V4: {
parents: 0,
interior: {
X1: [
{
AccountId32: {
id: acc,
},
network: undefined,
},
],
},
},
},
{
V4: [
{
id: token,
fun: { Fungible: amount },
},
],
},
0,
'Unlimited',
),
}

export const tx = {
Expand Down
2 changes: 1 addition & 1 deletion networks/darwinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
},
kusama: {
name: 'crab' as const,
endpoint: 'wss://crab-rpc.darwinia.network',
endpoint: 'wss://darwiniacrab-rpc.dwellir.com',
},
config: ({ alice }) => ({
storages: {
Expand Down
1 change: 1 addition & 0 deletions networks/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default {
export const moonbeam = {
paraId: 2004,
dot: 42259045809535163221576417993425387648n,
parachainDot: { parents: 1, interior: 'Here' },
} as const

export const moonriver = {
Expand Down
13 changes: 13 additions & 0 deletions tests/xcm-transfer/__snapshots__/polkadot-para.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,17 @@ exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > balance o
}
`;

exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > balance on from chain 2`] = `
{
"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)",
Expand Down Expand Up @@ -887,3 +898,5 @@ exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > tx events
},
]
`;

exports[`'moonbeam' -> 'acala' xcm transfer 'DOT' > xtokens transfer > tx events 2`] = `[]`;
2 changes: 1 addition & 1 deletion tests/xcm-transfer/polkadot-para.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const tests = [
}),
test: {
xtokenstHorizontal: {
tx: tx.xtokens.transfer({ ForeignAsset: moonbeam.dot }, 1e12, tx.xtokens.parachainV3(acala.paraId)),
tx: tx.xcmPallet.transferAssetsV4(moonbeam.parachainDot, 1e12, tx.xcmPallet.parachainV4(1, acala.paraId)),
fromBalance: query.assets(moonbeam.dot),
toBalance: query.tokens(acala.dot),
checkUmp: true,
Expand Down

0 comments on commit 4cceb95

Please sign in to comment.