diff --git a/packages/xcm-cfg/src/builders/pallets/polkadotXcm.ts b/packages/xcm-cfg/src/builders/pallets/polkadotXcm.ts index eacbcceb..5ccbc57d 100644 --- a/packages/xcm-cfg/src/builders/pallets/polkadotXcm.ts +++ b/packages/xcm-cfg/src/builders/pallets/polkadotXcm.ts @@ -24,6 +24,7 @@ const limitedReserveTransferAssets = () => { toBeneficiary(version, account), toAssets( version, + 0, { X2: [ { @@ -59,7 +60,7 @@ const reserveTransferAssets = () => { return [ toDest(version, destination), toBeneficiary(version, account), - toAssets(version, 'Here', amount), + toAssets(version, 0, 'Here', amount), 0, ]; }, @@ -68,9 +69,34 @@ const reserveTransferAssets = () => { }; }; +const limitedTeleportAssets = () => { + const func = 'limitedTeleportAssets'; + return { + here: (): ExtrinsicConfigBuilder => ({ + build: ({ address, amount, destination }) => + new ExtrinsicConfig({ + module: pallet, + func, + getArgs: () => { + const version = XcmVersion.v2; + const account = getExtrinsicAccount(address); + return [ + toDest(version, destination), + toBeneficiary(version, account), + toAssets(version, 1, 'Here', amount), + 0, + 'Unlimited', + ]; + }, + }), + }), + }; +}; + export const polkadotXcm = () => { return { limitedReserveTransferAssets, + limitedTeleportAssets, reserveTransferAssets, }; }; diff --git a/packages/xcm-cfg/src/builders/pallets/polkadotXcm.utils.ts b/packages/xcm-cfg/src/builders/pallets/polkadotXcm.utils.ts index 9bc3d8b7..d148525b 100644 --- a/packages/xcm-cfg/src/builders/pallets/polkadotXcm.utils.ts +++ b/packages/xcm-cfg/src/builders/pallets/polkadotXcm.utils.ts @@ -1,7 +1,16 @@ -import { XcmVersion } from '@moonbeam-network/xcm-builder'; +import { Parents, XcmVersion } from '@moonbeam-network/xcm-builder'; import { AnyChain } from '@moonbeam-network/xcm-types'; export const toDest = (version: XcmVersion, destination: AnyChain) => { + if (destination.key === 'polkadot') { + return { + [version]: { + parents: 1, + interior: 'Here', + }, + }; + } + return { [version]: { parents: 1, @@ -23,13 +32,18 @@ export const toBeneficiary = (version: XcmVersion, account: any) => { }; }; -export const toAssets = (version: XcmVersion, interior: any, amount: any) => { +export const toAssets = ( + version: XcmVersion, + parents: Parents, + interior: any, + amount: any +) => { return { [version]: [ { id: { Concrete: { - parents: 0, + parents: parents, interior: interior, }, },