diff --git a/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.ts b/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.ts index f1a456db..dcbfe120 100644 --- a/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.ts +++ b/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.ts @@ -21,7 +21,7 @@ import { getExtrinsicAssetLocation, } from '../ExtrinsicBuilder.utils'; -import { Parents, XcmVersion } from '../types'; +import { Parents, XcmTransferType, XcmVersion } from '../types'; const pallet = 'polkadotXcm'; @@ -207,7 +207,9 @@ const teleportAssets = (parent: Parents) => { }; }; -const transferAssetsUsingTypeAndThen = (): ExtrinsicConfigBuilder => ({ +const transferAssetsUsingTypeAndThen = ( + transferType: XcmTransferType +): ExtrinsicConfigBuilder => ({ build: ({ address, asset, amount, destination, sender, source }) => new ExtrinsicConfig({ module: pallet, @@ -246,8 +248,8 @@ const transferAssetsUsingTypeAndThen = (): ExtrinsicConfigBuilder => ({ const assetTransferType = v4.toTransferType( version, - transferAssetLocation, - rcv + transferType, + transferAssetLocation ); const remoteFeeId = { @@ -258,8 +260,8 @@ const transferAssetsUsingTypeAndThen = (): ExtrinsicConfigBuilder => ({ const feesTransferType = v4.toTransferType( version, - transferFeeLocation, - rcv + transferType, + transferFeeLocation ); const customXcmOnDest = diff --git a/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.utils.v4.ts b/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.utils.v4.ts index 02feeae7..1f2abba4 100644 --- a/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.utils.v4.ts +++ b/packages/xcm-cfg/src/builders/extrinsics/polkadotXcm.utils.v4.ts @@ -1,6 +1,6 @@ import { Parachain } from '@galacticcouncil/xcm-core'; -import { XcmVersion } from '../types'; +import { XcmTransferType, XcmVersion } from '../types'; import { findNestedKey } from '../utils'; const ETHEREUM_CHAIN_ID = 1; @@ -36,24 +36,23 @@ export const toDest = (version: XcmVersion, destination: Parachain) => { export const toTransferType = ( version: XcmVersion, - assetLocation: object, - destination: Parachain + type: XcmTransferType, + assetLocation: object ) => { - if (destination.key === 'assethub' || destination.key === 'ethereum') { - return 'DestinationReserve'; - } - - const reserveChain = findNestedKey(assetLocation, 'Parachain'); - return { - RemoteReserve: { - [version]: { - parents: 1, - interior: { - X1: [reserveChain], + if (type === XcmTransferType.RemoteReserve) { + const reserveChain = findNestedKey(assetLocation, 'Parachain'); + return { + RemoteReserve: { + [version]: { + parents: 1, + interior: { + X1: [reserveChain], + }, }, }, - }, - }; + }; + } + return type; }; export const toAsset = (assetLocation: object, amount: any) => { diff --git a/packages/xcm-cfg/src/builders/types.ts b/packages/xcm-cfg/src/builders/types.ts index 160af060..9a6c0d22 100644 --- a/packages/xcm-cfg/src/builders/types.ts +++ b/packages/xcm-cfg/src/builders/types.ts @@ -5,4 +5,11 @@ export enum XcmVersion { v4 = 'V4', } +export enum XcmTransferType { + Teleport = 'Teleport', + LocalReserve = 'LocalReserve', + DestinationReserve = 'DestinationReserve', + RemoteReserve = 'RemoteReserve', +} + export type Parents = 0 | 1 | 2; diff --git a/packages/xcm-cfg/src/configs/polkadot/assethub/index.ts b/packages/xcm-cfg/src/configs/polkadot/assethub/index.ts index 24541533..0b784961 100644 --- a/packages/xcm-cfg/src/configs/polkadot/assethub/index.ts +++ b/packages/xcm-cfg/src/configs/polkadot/assethub/index.ts @@ -20,7 +20,7 @@ import { toMoonbeamExtTemplate, xcmDeliveryFee, } from './templates'; -import { XcmVersion } from 'builders/types'; +import { XcmTransferType, XcmVersion } from 'builders/types'; const toHydration: AssetRoute[] = [ new AssetRoute({ @@ -127,7 +127,7 @@ const toHydration: AssetRoute[] = [ }, extrinsic: ExtrinsicBuilder() .polkadotXcm() - .transferAssetsUsingTypeAndThen(), + .transferAssetsUsingTypeAndThen(XcmTransferType.RemoteReserve), }), toHydrationExtTemplate(pink), toHydrationExtTemplate(ded), diff --git a/packages/xcm-cfg/src/configs/polkadot/hydration/index.ts b/packages/xcm-cfg/src/configs/polkadot/hydration/index.ts index 51897fe4..0653871e 100644 --- a/packages/xcm-cfg/src/configs/polkadot/hydration/index.ts +++ b/packages/xcm-cfg/src/configs/polkadot/hydration/index.ts @@ -78,7 +78,7 @@ import { toMoonbeamErc20Template, toZeitgeistErc20Template, } from './templates'; -import { XcmVersion } from 'builders/types'; +import { XcmTransferType, XcmVersion } from 'builders/types'; const toAcala: AssetRoute[] = [ new AssetRoute({ @@ -198,7 +198,7 @@ const toAssetHub: AssetRoute[] = [ }, extrinsic: ExtrinsicBuilder() .polkadotXcm() - .transferAssetsUsingTypeAndThen(), + .transferAssetsUsingTypeAndThen(XcmTransferType.DestinationReserve), }), new AssetRoute({ source: { @@ -257,7 +257,7 @@ const toAssetHub: AssetRoute[] = [ }, extrinsic: ExtrinsicBuilder() .polkadotXcm() - .transferAssetsUsingTypeAndThen(), + .transferAssetsUsingTypeAndThen(XcmTransferType.DestinationReserve), }), toHubExtTemplate(pink), toHubExtTemplate(ded), @@ -910,7 +910,7 @@ const toEthereumViaSnowbridge: AssetRoute[] = [ }, extrinsic: ExtrinsicBuilder() .polkadotXcm() - .transferAssetsUsingTypeAndThen(), + .transferAssetsUsingTypeAndThen(XcmTransferType.DestinationReserve), }), ];