Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to use polkadotXcm for moonbeam #109

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/networks/src/chains/moonbeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ const custom = {
dot: 42259045809535163221576417993425387648n,
aca: 224821240862170613278369189818311486111n,
ldot: 225719522181998468294117309041779353812n,
xcmDot: { Concrete: { parents: 1, interior: 'Here' } },
xcmAca: {
Concrete: {
parents: 1,
interior: {
X2: [
{ Parachain: 2000 },
{ GeneralKey: { data: '0x0000000000000000000000000000000000000000000000000000000000000000', length: 2 } },
],
},
},
},
xcmLdot: {
Concrete: {
parents: 1,
interior: {
X2: [
{ Parachain: 2000 },
{ GeneralKey: { data: '0x0003000000000000000000000000000000000000000000000000000000000000', length: 2 } },
],
},
},
},
},
moonriver: {},
}
Expand Down
6 changes: 3 additions & 3 deletions packages/polkadot/src/acala.moonbeam.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('acala & moonbeam', async () => {
routeChain: polkadotClient,
isCheckUmp: true,

tx: tx.xtokens.transfer({ ForeignAsset: moonbeamDot }, 1e12, tx.xtokens.parachainV3(acala.paraId!)),
tx: tx.xcmPallet.transferAssetsV3(moonbeam.custom.xcmDot, 1e12, tx.xcmPallet.parachainV3(1, acala.paraId!)),
}
})

Expand Down Expand Up @@ -82,7 +82,7 @@ describe('acala & moonbeam', async () => {
toBalance: query.balances,
toAccount: defaultAccounts.bob,

tx: tx.xtokens.transfer({ ForeignAsset: moonbeam.custom.aca }, 1e12, tx.xtokens.parachainV3(acala.paraId!)),
tx: tx.xcmPallet.transferAssetsV3(moonbeam.custom.xcmAca, 1e12, tx.xcmPallet.parachainV3(1, acala.paraId!)),
}
})

Expand Down Expand Up @@ -116,7 +116,7 @@ describe('acala & moonbeam', async () => {
toBalance: query.tokens(acala.custom.ldot),
toAccount: defaultAccounts.bob,

tx: tx.xtokens.transfer({ ForeignAsset: moonbeam.custom.ldot }, 1e12, tx.xtokens.parachainV3(acala.paraId!)),
tx: tx.xcmPallet.transferAssetsV3(moonbeam.custom.xcmLdot, 1e12, tx.xcmPallet.parachainV3(1, acala.paraId!)),
}
})
})
28 changes: 28 additions & 0 deletions packages/shared/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,34 @@ export const xcmPallet = {
({ api }: { api: ApiPromise }) => {
return api.tx.polkadotXcm.send(dest, xcm)
},
transferAssetsV3:
(token: any, amount: any, dest: any) =>
({ api }: { api: ApiPromise }, acc: any) =>
(api.tx.xcmPallet || api.tx.polkadotXcm).transferAssets(
dest,
{
V3: {
parents: 0,
interior: {
X1: {
AccountId32: {
id: acc,
},
},
},
},
},
{
V3: [
{
id: token,
fun: { Fungible: amount },
},
],
},
0,
'Unlimited',
),
}

export const tx = {
Expand Down
Loading