diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 9184d47f..e2505945 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,9 +12,9 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-sdk": "2.5.14", - "@moonbeam-network/xcm-utils": "2.1.7" + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-sdk": "2.6.3", + "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { "bun": "^1.1.25" diff --git a/mkdocs/docs/contribute.md b/mkdocs/docs/contribute.md index d52c00ea..22f77cd1 100644 --- a/mkdocs/docs/contribute.md +++ b/mkdocs/docs/contribute.md @@ -48,7 +48,7 @@ Follow these steps: 3. Add your asset to the `assetsList` array at the end of the file !!! note - Assets are listed in alphabetical order. Please make sure you follow this order when adding new assets. +Assets are listed in alphabetical order. Please make sure you follow this order when adding new assets. ## Add a Chain @@ -120,7 +120,7 @@ To add a chain, take the following steps: 4. Add the newly created chain to the `chainsList` array at the end of the file !!! note - Chains are listed in alphabetical order. Please make sure you follow this order when adding new chains. +Chains are listed in alphabetical order. Please make sure you follow this order when adding new chains. Now that you've added the chain, you can continue to the next section to add the assets that this chain supports. @@ -242,7 +242,7 @@ Assuming that all of the required pallets and methods are already supported, you 4. Add the newly created chain configurations to the `chainsConfigList` in the `xcm-sdk/blob/main/packages/config/src/configs/index.ts` file !!! note - Chain configurations are listed in alphabetical order. Please follow this order when adding new chain configurations. +Chain configurations are listed in alphabetical order. Please follow this order when adding new chain configurations. For example, to add support to transfer USDT from the Polkadot Asset Hub to Moonbeam, the Polkadot Asset Hub configuration file is as follows: @@ -267,7 +267,9 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/mkdocs/docs/reference/interfaces.md b/mkdocs/docs/reference/interfaces.md index 19fd5509..a1000294 100644 --- a/mkdocs/docs/reference/interfaces.md +++ b/mkdocs/docs/reference/interfaces.md @@ -44,7 +44,7 @@ Defines an asset's key and symbol used on the asset's origin chain. Defines properties related to an asset, including `Asset` properties, the decimals and symbol of the asset, and the amount an associated source or destination address has of the asset. !!! note - A few utility methods are available for working with the `AssetAmount` class that converts the amount to various formats. Please refer to the [Methods for Asset Conversions](./methods.md#asset-utilities) section. +A few utility methods are available for working with the `AssetAmount` class that converts the amount to various formats. Please refer to the [Methods for Asset Conversions](./methods.md#asset-utilities) section. **Attributes** @@ -692,7 +692,9 @@ Defines a chain's configurations, including information for each chain's support balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -762,7 +764,9 @@ Defines an asset's configurations for a source chain and includes information ab balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -832,7 +836,9 @@ Defines the fees for a particular asset on the destination chain. { asset: dot, balance: BalanceBuilder().substrate().system().account(), - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), } ``` diff --git a/package-lock.json b/package-lock.json index 67505536..f9b0c34c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,9 +50,9 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-sdk": "2.5.14", - "@moonbeam-network/xcm-utils": "2.1.7" + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-sdk": "2.6.3", + "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { "bun": "^1.1.25" @@ -19594,11 +19594,11 @@ }, "packages/builder": { "name": "@moonbeam-network/xcm-builder", - "version": "2.4.7", + "version": "2.5.1", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-types": "2.3.4", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-types": "2.4.1", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { @@ -19611,11 +19611,11 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "2.5.12", + "version": "2.6.3", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-builder": "2.4.7", - "@moonbeam-network/xcm-types": "2.3.4" + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-types": "2.4.1" }, "peerDependencies": { "@polkadot/types": "^12.4.2", @@ -19625,13 +19625,13 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "2.5.14", + "version": "2.6.3", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-builder": "2.4.7", - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-types": "2.3.4", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-types": "2.4.1", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { @@ -19645,10 +19645,10 @@ }, "packages/types": { "name": "@moonbeam-network/xcm-types", - "version": "2.3.4", + "version": "2.4.1", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { @@ -19657,7 +19657,7 @@ }, "packages/utils": { "name": "@moonbeam-network/xcm-utils", - "version": "2.1.7", + "version": "2.2.0", "license": "MIT", "dependencies": { "big.js": "^6.2.1", diff --git a/packages/builder/CHANGELOG.md b/packages/builder/CHANGELOG.md index ae6a9311..79cd5891 100644 --- a/packages/builder/CHANGELOG.md +++ b/packages/builder/CHANGELOG.md @@ -1,5 +1,24 @@ # @moonbeam-network/xcm-builder +## 2.5.1 + +### Patch Changes + +- Updated dependencies [[`4be5659`](https://github.com/moonbeam-foundation/xcm-sdk/commit/4be5659c05fe2487dd6f440c833fdf7cdc369917)]: + - @moonbeam-network/xcm-utils@2.2.0 + - @moonbeam-network/xcm-types@2.4.1 + +## 2.5.0 + +### Minor Changes + +- [#351](https://github.com/moonbeam-foundation/xcm-sdk/pull/351) [`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769) Thanks [@mmaurello](https://github.com/mmaurello)! - Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha + +### Patch Changes + +- Updated dependencies [[`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769)]: + - @moonbeam-network/xcm-types@2.4.0 + ## 2.4.7 ### Patch Changes diff --git a/packages/builder/package.json b/packages/builder/package.json index 2f9cdbdc..7746065a 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-builder", - "version": "2.4.7", + "version": "2.5.1", "description": "Moonbeam XCM builder", "scripts": { "build": "tsup", @@ -49,8 +49,8 @@ "types": "./build/index.d.ts", "main": "./build/index.cjs", "dependencies": { - "@moonbeam-network/xcm-types": "2.3.4", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-types": "2.4.1", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { diff --git a/packages/builder/src/fee/FeeBuilder.interfaces.ts b/packages/builder/src/fee/FeeBuilder.interfaces.ts index 2c6d5230..71e43c7c 100644 --- a/packages/builder/src/fee/FeeBuilder.interfaces.ts +++ b/packages/builder/src/fee/FeeBuilder.interfaces.ts @@ -1,5 +1,7 @@ -import { ChainAssetId } from '@moonbeam-network/xcm-types'; +import { AnyParachain, ChainAssetId } from '@moonbeam-network/xcm-types'; import { ApiPromise } from '@polkadot/api'; +import { Enum } from '@polkadot/types'; +import { StagingXcmV3MultiLocation } from '@polkadot/types/lookup'; import { SubstrateCallConfig } from '../types/substrate/SubstrateCallConfig'; export interface FeeConfigBuilder { @@ -7,6 +9,20 @@ export interface FeeConfigBuilder { } export interface FeeConfigBuilderPrams { - asset: ChainAssetId; + address: string; api: ApiPromise; + feeAsset: ChainAssetId; + transferAsset: ChainAssetId; + chain: AnyParachain; +} + +export interface XcmPaymentFeeProps { + isAssetReserveChain: boolean; + shouldTransferAssetPrecedeAsset?: boolean; +} + +export interface MoonbeamRuntimeXcmConfigAssetType extends Enum { + readonly isXcm: boolean; + readonly asXcm: StagingXcmV3MultiLocation; + readonly type: 'Xcm'; } diff --git a/packages/builder/src/fee/FeeBuilder.ts b/packages/builder/src/fee/FeeBuilder.ts index 055f5e0c..9c6bbf44 100644 --- a/packages/builder/src/fee/FeeBuilder.ts +++ b/packages/builder/src/fee/FeeBuilder.ts @@ -1,41 +1,67 @@ /* eslint-disable sort-keys */ /* eslint-disable @typescript-eslint/no-use-before-define */ -import { Option, u128 } from '@polkadot/types'; import { SubstrateCallConfig } from '../types/substrate/SubstrateCallConfig'; -import { FeeConfigBuilder } from './FeeBuilder.interfaces'; +import { FeeConfigBuilder, XcmPaymentFeeProps } from './FeeBuilder.interfaces'; +import { + getBuyExecutionInstruction, + getClearOriginInstruction, + getDepositAssetInstruction, + getFeeForXcmInstructionsAndAsset, + getReserveAssetDepositedInstruction, + getSetTopicInstruction, + getVersionedAssetId, + getWithdrawAssetInstruction, +} from './FeeBuilder.utils'; export function FeeBuilder() { return { - assetManager, + xcmPaymentApi, }; } -function assetManager() { +function xcmPaymentApi() { return { - assetTypeUnitsPerSecond: (weight = 1_000_000_000): FeeConfigBuilder => ({ - build: ({ api, asset }) => + xcmPaymentFee: ({ + isAssetReserveChain, + shouldTransferAssetPrecedeAsset = false, + }: XcmPaymentFeeProps): FeeConfigBuilder => ({ + build: ({ address, api, feeAsset, chain, transferAsset }) => new SubstrateCallConfig({ api, call: async (): Promise => { - const type = (await api.query.assetManager.assetIdType( - asset, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - )) as unknown as Option; + const versionedAssetId = await getVersionedAssetId( + api, + feeAsset, + chain, + ); + const versionedTransferAssetId = await getVersionedAssetId( + api, + transferAsset, + chain, + ); + const versionedAssets = shouldTransferAssetPrecedeAsset + ? [versionedTransferAssetId, versionedAssetId] + : [versionedAssetId, versionedTransferAssetId]; - if (type.isNone) { - throw new Error(`No asset type found for asset ${asset}`); - } + const assets = + feeAsset === transferAsset ? [versionedAssetId] : versionedAssets; - const unwrappedType = type.unwrap(); + const instructions = [ + isAssetReserveChain + ? getWithdrawAssetInstruction(assets) + : getReserveAssetDepositedInstruction(assets), + getClearOriginInstruction(), + getBuyExecutionInstruction(versionedAssetId), + getDepositAssetInstruction(address, assets), + getSetTopicInstruction(), + ]; - const res = (await api.query.assetManager.assetTypeUnitsPerSecond( - unwrappedType, - )) as unknown as Option; - - const unitsPerSecond = res.unwrapOrDefault().toBigInt(); - - return (BigInt(weight) * unitsPerSecond) / BigInt(10 ** 12); + return getFeeForXcmInstructionsAndAsset( + api, + instructions, + versionedAssetId, + ); }, }), }), diff --git a/packages/builder/src/fee/FeeBuilder.utils.ts b/packages/builder/src/fee/FeeBuilder.utils.ts new file mode 100644 index 00000000..769d1d00 --- /dev/null +++ b/packages/builder/src/fee/FeeBuilder.utils.ts @@ -0,0 +1,244 @@ +/* eslint-disable sort-keys */ +import { AnyParachain, ChainAssetId } from '@moonbeam-network/xcm-types'; +import { isHexString } from '@moonbeam-network/xcm-utils'; +import { ApiPromise } from '@polkadot/api'; +import { Option, Result, u128 } from '@polkadot/types'; +import { Error as PolkadotError, Weight } from '@polkadot/types/interfaces'; +import { AnyJson } from '@polkadot/types/types'; +import { XcmVersion } from '../extrinsic'; +import { MoonbeamRuntimeXcmConfigAssetType } from './FeeBuilder.interfaces'; + +const DEFAULT_AMOUNT = 10 ** 6; +const DEFALUT_HEX_STRING = + '0xabcdef1234567890fedcba0987654321abcdef1234567890fedcba0987654321'; + +const MOON_CHAIN_NATIVE_ASSET_ID = '0x0000000000000000000000000000000000000802'; + +const MOON_CHAIN_BALANCES_PALLET_INSTANCE: Record = { + moonbeam: '10', + moonriver: '10', + 'moonbase-alpha': '3', +}; +const MOON_CHIAN_ERC20_PALLET_INSTANCE: Record = { + moonbeam: '110', + moonriver: '110', + 'moonbase-alpha': '48', +}; + +const XCM_VERSION: XcmVersion = XcmVersion.v4; // TODO + +function isXcmV4() { + return XCM_VERSION === XcmVersion.v4; +} + +function normalizeX1(assetType: Record) { + if (!isXcmV4()) { + return assetType; + } + const normalizedAssetType = { ...assetType }; + if ( + normalizedAssetType.interior && + typeof normalizedAssetType.interior === 'object' && + 'x1' in normalizedAssetType.interior + ) { + if (!Array.isArray(normalizedAssetType.interior.x1)) { + normalizedAssetType.interior.x1 = [normalizedAssetType.interior.x1]; + } + } + return normalizedAssetType; +} + +export function getWithdrawAssetInstruction(assetTypes: object[]) { + return { + WithdrawAsset: assetTypes.map((assetType) => ({ + id: { ...assetType }, + fun: { + Fungible: DEFAULT_AMOUNT, + }, + })), + }; +} + +export function getReserveAssetDepositedInstruction(assetTypes: object[]) { + return { + ReserveAssetDeposited: assetTypes.map((assetType) => ({ + id: { ...assetType }, + fun: { + Fungible: DEFAULT_AMOUNT, + }, + })), + }; +} + +export function getClearOriginInstruction() { + return { + ClearOrigin: 'NULL', + }; +} + +export function getBuyExecutionInstruction(assetType: object) { + // TODO should verify that asset is in acceptable payment assets + // api.call.xcmPaymentApi.queryAcceptablePaymentAssets(xcmVersion) + return { + BuyExecution: { + fees: { + id: { + ...assetType, + }, + fun: { + Fungible: DEFAULT_AMOUNT, + }, + }, + weight_limit: { + Unlimited: 'NULL', + }, + }, + }; +} + +export function getDepositAssetInstruction(address: string, assets: object[]) { + const accountKey = { + AccountKey20: { + key: address, + network: null, + }, + }; + + return { + DepositAsset: { + assets: { + Wild: { + AllCounted: assets.length, + }, + }, + beneficiary: { + interior: { + X1: isXcmV4() ? [accountKey] : accountKey, + }, + parents: 0, + }, + max_assets: 0, + }, + }; +} + +export function getSetTopicInstruction() { + return { + SetTopic: DEFALUT_HEX_STRING, + }; +} + +function applyConcreteWrapper(id: object) { + return { + Concrete: { ...id }, + }; +} + +// TODO this is for Moonbeam +function getNativeAssetId(chainKey: string): object { + const palletInstance = { + PalletInstance: MOON_CHAIN_BALANCES_PALLET_INSTANCE[chainKey], + }; + const id = { + interior: { + X1: isXcmV4() ? [palletInstance] : palletInstance, + }, + parents: '0', + }; + + return isXcmV4() ? id : applyConcreteWrapper(id); +} + +function getConcreteAssetIdWithAccountKey20( + asset: ChainAssetId, + chainKey: string, +): object { + const id = { + interior: { + X2: [ + { + PalletInstance: MOON_CHIAN_ERC20_PALLET_INSTANCE[chainKey], + }, + { + AccountKey20: { + key: asset, + network: null, + }, + }, + ], + }, + parents: '0', + }; + return isXcmV4() ? id : applyConcreteWrapper(id); +} + +export async function getAssetIdType( + api: ApiPromise, + asset: ChainAssetId, +): Promise> { + const type = + await api.query.assetManager.assetIdType< + Option + >(asset); + + if (type.isNone || !type.unwrap().isXcm) { + throw new Error(`No asset type found for asset ${asset}`); + } + return type; +} + +export async function getVersionedAssetId( + api: ApiPromise, + asset: ChainAssetId, + chain: AnyParachain, +): Promise { + if (asset === MOON_CHAIN_NATIVE_ASSET_ID) { + return getNativeAssetId(chain.key); + } + + if (isHexString(asset)) { + return getConcreteAssetIdWithAccountKey20(asset, chain.key); + } + + const assetType = await getAssetIdType(api, asset); + const assetTypeObject = assetType.unwrap().asXcm.toJSON(); + + const normalizedAssetTypeObject = normalizeX1(assetTypeObject); + + return isXcmV4() + ? normalizedAssetTypeObject + : applyConcreteWrapper(normalizedAssetTypeObject); +} + +export async function getFeeForXcmInstructionsAndAsset( + api: ApiPromise, + instructions: AnyJson, + versionedAssetId: object, +) { + const xcmToWeightResult = await api.call.xcmPaymentApi.queryXcmWeight< + Result + >({ + [XCM_VERSION]: instructions, + }); + if (!xcmToWeightResult.isOk) { + throw new Error( + 'There was an error trying to get the weight for the xcm instructions (queryXcmWeight)', + ); + } + const xcmToWeight = xcmToWeightResult.asOk; + + const weightToForeingAssets = + await api.call.xcmPaymentApi.queryWeightToAssetFee< + Result + >(xcmToWeight, { + [XCM_VERSION]: { + ...versionedAssetId, + }, + }); + if (!weightToForeingAssets.isOk) { + throw new Error( + 'There was an error trying to get the fee with the weight and asset (weightToForeingAssets)', + ); + } + return weightToForeingAssets.asOk.toBigInt(); +} diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index 63c1e6ab..9772ed0f 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,37 @@ # @moonbeam-network/xcm-config +## 2.6.3 + +### Patch Changes + +- [#359](https://github.com/moonbeam-foundation/xcm-sdk/pull/359) [`5d308c3`](https://github.com/moonbeam-foundation/xcm-sdk/commit/5d308c3455126b5dfedb93c38a0afb18344a183e) Thanks [@mmaurello](https://github.com/mmaurello)! - Fix Asset Hub memecoins asset ordering in fee calculation + +## 2.6.2 + +### Patch Changes + +- [#356](https://github.com/moonbeam-foundation/xcm-sdk/pull/356) [`3f22072`](https://github.com/moonbeam-foundation/xcm-sdk/commit/3f22072c837a55e9109ad042efa555a46802e6e6) Thanks [@mmaurello](https://github.com/mmaurello)! - Fix TEER configuration in Integritee + +## 2.6.1 + +### Patch Changes + +- Updated dependencies []: + - @moonbeam-network/xcm-builder@2.5.1 + - @moonbeam-network/xcm-types@2.4.1 + +## 2.6.0 + +### Minor Changes + +- [#351](https://github.com/moonbeam-foundation/xcm-sdk/pull/351) [`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769) Thanks [@mmaurello](https://github.com/mmaurello)! - Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha + +### Patch Changes + +- Updated dependencies [[`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769)]: + - @moonbeam-network/xcm-builder@2.5.0 + - @moonbeam-network/xcm-types@2.4.0 + ## 2.5.12 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index c773a492..2210fafc 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "2.5.12", + "version": "2.6.3", "description": "All necessary configuration to transfer assets from Moonbeam, Moonriver, Moonbase to other parachains and back", "scripts": { "build": "tsup", @@ -49,8 +49,8 @@ "types": "./build/index.d.ts", "main": "./build/index.cjs", "dependencies": { - "@moonbeam-network/xcm-builder": "2.4.7", - "@moonbeam-network/xcm-types": "2.3.4" + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-types": "2.4.1" }, "peerDependencies": { "@polkadot/types": "^12.4.2", diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index 863a8db7..c36a0936 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -412,7 +412,7 @@ export const darwiniaCrab = new EvmParachain({ parachainId: 2105, rpc: 'https://crab-rpc.darwinia.network', ss58Format: 18, - ws: ['wss://crab-rpc.darwinia.network', 'wss://darwiniacrab-rpc.dwellir.com'], + ws: ['wss://darwiniacrab-rpc.dwellir.com', 'wss://crab-rpc.darwinia.network'], }); export const hydration = new Parachain({ @@ -528,6 +528,13 @@ export const interlay = new Parachain({ }); export const integritee = new Parachain({ + assetsData: [ + { + asset: teer, + id: teer.originSymbol, + metadataId: 0, + }, + ], ecosystem: Ecosystem.Kusama, genesisHash: '0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da', @@ -941,7 +948,7 @@ export const moonbeam = new EvmParachain({ address: '0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2', asset: fil, id: '0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2', - metadataId: 0, // no metadata for ERC20 tokens + metadataId: '144012926827374458669278577633504620722', }, { address: '0x0000000000000000000000000000000000000802', diff --git a/packages/config/src/configs/acala.ts b/packages/config/src/configs/acala.ts index 1ed10647..d4bdd533 100644 --- a/packages/config/src/configs/acala.ts +++ b/packages/config/src/configs/acala.ts @@ -16,7 +16,9 @@ export const acalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aca, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const acalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aseed, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -43,7 +47,9 @@ export const acalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -59,7 +65,9 @@ export const acalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.005, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ldot, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/alphanetAssetHub.ts b/packages/config/src/configs/alphanetAssetHub.ts index 677fe7e6..b81abcd4 100644 --- a/packages/config/src/configs/alphanetAssetHub.ts +++ b/packages/config/src/configs/alphanetAssetHub.ts @@ -16,7 +16,9 @@ export const alphanetAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tt1, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/alphanetRelay.ts b/packages/config/src/configs/alphanetRelay.ts index c4201c6a..810b4cd1 100644 --- a/packages/config/src/configs/alphanetRelay.ts +++ b/packages/config/src/configs/alphanetRelay.ts @@ -15,7 +15,9 @@ export const alphanetRelayConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: unit, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/astar.ts b/packages/config/src/configs/astar.ts index c4e34671..198be071 100644 --- a/packages/config/src/configs/astar.ts +++ b/packages/config/src/configs/astar.ts @@ -15,7 +15,9 @@ export const astarConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: astr, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const astarConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/bifrostKusama.ts b/packages/config/src/configs/bifrostKusama.ts index 2fc3682b..774c5b04 100644 --- a/packages/config/src/configs/bifrostKusama.ts +++ b/packages/config/src/configs/bifrostKusama.ts @@ -16,7 +16,9 @@ export const bifrostKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const bifrostKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -43,7 +47,9 @@ export const bifrostKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.2, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -59,7 +65,9 @@ export const bifrostKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.2, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -75,7 +83,9 @@ export const bifrostKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.2, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/bifrostPolkadot.ts b/packages/config/src/configs/bifrostPolkadot.ts index 87d060cb..b38d5c51 100644 --- a/packages/config/src/configs/bifrostPolkadot.ts +++ b/packages/config/src/configs/bifrostPolkadot.ts @@ -26,7 +26,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -37,7 +39,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -53,7 +57,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -69,7 +75,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -85,7 +93,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: vdot, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -101,7 +111,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -117,7 +129,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -133,7 +147,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, @@ -149,7 +165,9 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.05, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/calamari.ts b/packages/config/src/configs/calamari.ts index aee2b28c..3263179c 100644 --- a/packages/config/src/configs/calamari.ts +++ b/packages/config/src/configs/calamari.ts @@ -16,7 +16,9 @@ export const calamariConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: kma, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const calamariConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/centrifuge.ts b/packages/config/src/configs/centrifuge.ts index 86b89f36..362859c9 100644 --- a/packages/config/src/configs/centrifuge.ts +++ b/packages/config/src/configs/centrifuge.ts @@ -15,7 +15,9 @@ export const centrifugeConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: cfg, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/crustShadow.ts b/packages/config/src/configs/crustShadow.ts index 1ce592f6..3dc6e63f 100644 --- a/packages/config/src/configs/crustShadow.ts +++ b/packages/config/src/configs/crustShadow.ts @@ -15,7 +15,9 @@ export const crustShadowConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: csm, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const crustShadowConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/darwinia.ts b/packages/config/src/configs/darwinia.ts index 84e2bfff..eff141e2 100644 --- a/packages/config/src/configs/darwinia.ts +++ b/packages/config/src/configs/darwinia.ts @@ -15,7 +15,9 @@ export const darwiniaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ring, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/darwiniaCrab.ts b/packages/config/src/configs/darwiniaCrab.ts index 70ba3c40..7a153aac 100644 --- a/packages/config/src/configs/darwiniaCrab.ts +++ b/packages/config/src/configs/darwiniaCrab.ts @@ -15,7 +15,9 @@ export const darwiniaCrabConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: crab, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/hydration.ts b/packages/config/src/configs/hydration.ts index 03011e73..a28bde62 100644 --- a/packages/config/src/configs/hydration.ts +++ b/packages/config/src/configs/hydration.ts @@ -15,7 +15,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: hdx, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -37,7 +41,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -52,7 +58,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -67,7 +75,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -82,7 +92,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -97,7 +109,9 @@ export const hydrationConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/hydrationAlphanet.ts b/packages/config/src/configs/hydrationAlphanet.ts index e3658693..a670b57f 100644 --- a/packages/config/src/configs/hydrationAlphanet.ts +++ b/packages/config/src/configs/hydrationAlphanet.ts @@ -16,7 +16,9 @@ export const hydrationAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: hdx, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const hydrationAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -38,7 +42,9 @@ export const hydrationAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -53,7 +59,9 @@ export const hydrationAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/index.ts b/packages/config/src/configs/index.ts index bcbfa77b..72474bdf 100644 --- a/packages/config/src/configs/index.ts +++ b/packages/config/src/configs/index.ts @@ -47,7 +47,6 @@ import { subsocialConfig } from './subsocial'; import { tinkernetConfig } from './tinkernet'; import { turingConfig } from './turing'; import { turingAlphanetConfig } from './turingAlphanet'; -import { uniqueAlphaConfig } from './uniqueAlpha'; import { zeitgeistConfig } from './zeitgeist'; export const chainsConfigList: ChainConfig[] = [ @@ -98,7 +97,6 @@ export const chainsConfigList: ChainConfig[] = [ tinkernetConfig, turingConfig, turingAlphanetConfig, - uniqueAlphaConfig, zeitgeistConfig, ]; diff --git a/packages/config/src/configs/integritee.ts b/packages/config/src/configs/integritee.ts index 28739e8e..48f3217a 100644 --- a/packages/config/src/configs/integritee.ts +++ b/packages/config/src/configs/integritee.ts @@ -15,7 +15,9 @@ export const integriteeConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: teer, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/interlay.ts b/packages/config/src/configs/interlay.ts index e8b5838e..ac49da7c 100644 --- a/packages/config/src/configs/interlay.ts +++ b/packages/config/src/configs/interlay.ts @@ -15,7 +15,9 @@ export const interlayConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: intr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -26,7 +28,10 @@ export const interlayConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: intr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -41,7 +46,9 @@ export const interlayConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/karura.ts b/packages/config/src/configs/karura.ts index 8f7302ff..a328762f 100644 --- a/packages/config/src/configs/karura.ts +++ b/packages/config/src/configs/karura.ts @@ -16,7 +16,9 @@ export const karuraConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: kar, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const karuraConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aseed, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -43,7 +47,9 @@ export const karuraConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/khala.ts b/packages/config/src/configs/khala.ts index 3c6a063b..8589721a 100644 --- a/packages/config/src/configs/khala.ts +++ b/packages/config/src/configs/khala.ts @@ -15,7 +15,9 @@ export const khalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pha, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const khalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: 0.001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/kintsugi.ts b/packages/config/src/configs/kintsugi.ts index 99c03ce6..b8d88717 100644 --- a/packages/config/src/configs/kintsugi.ts +++ b/packages/config/src/configs/kintsugi.ts @@ -15,7 +15,9 @@ export const kintsugiConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: kint, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -26,7 +28,10 @@ export const kintsugiConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: kint, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/kusama.ts b/packages/config/src/configs/kusama.ts index ca13d41d..877891da 100644 --- a/packages/config/src/configs/kusama.ts +++ b/packages/config/src/configs/kusama.ts @@ -15,7 +15,9 @@ export const kusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: ksm, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/kusamaAssetHub.ts b/packages/config/src/configs/kusamaAssetHub.ts index 51893e5b..c25f1468 100644 --- a/packages/config/src/configs/kusamaAssetHub.ts +++ b/packages/config/src/configs/kusamaAssetHub.ts @@ -18,7 +18,9 @@ export const kusamaAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: rmrk, balance: BalanceBuilder().substrate().assets().account(), }, @@ -38,7 +40,9 @@ export const kusamaAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/mangataKusama.ts b/packages/config/src/configs/mangataKusama.ts index 7b075cc2..7124c0f1 100644 --- a/packages/config/src/configs/mangataKusama.ts +++ b/packages/config/src/configs/mangataKusama.ts @@ -15,7 +15,9 @@ export const mangataKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: mgx, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -26,7 +28,9 @@ export const mangataKusamaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.000008, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/mantaParachain.ts b/packages/config/src/configs/mantaParachain.ts index 7d84709a..b7066daf 100644 --- a/packages/config/src/configs/mantaParachain.ts +++ b/packages/config/src/configs/mantaParachain.ts @@ -16,7 +16,9 @@ export const mantaParachainConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: manta, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const mantaParachainConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/moonbaseAlpha.ts b/packages/config/src/configs/moonbaseAlpha.ts index 1492c18c..77301f1e 100644 --- a/packages/config/src/configs/moonbaseAlpha.ts +++ b/packages/config/src/configs/moonbaseAlpha.ts @@ -91,21 +91,6 @@ export const moonbaseAlphaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), }, }), - // NOTE: Disabling because ws endpoint is not working - // new AssetConfig({ - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // contract: ContractBuilder().Xtokens().transfer(), - // destination: uniqueAlpha, - // destinationFee: { - // amount: 0, - // asset: auq, - // }, - // fee: { - // asset: dev, - // balance: BalanceBuilder().substrate().system().account(), - // }, - // }), new AssetConfig({ asset: ampe, balance: BalanceBuilder().substrate().assets().account(), diff --git a/packages/config/src/configs/moonbaseBeta.ts b/packages/config/src/configs/moonbaseBeta.ts index 006dea49..8ac35232 100644 --- a/packages/config/src/configs/moonbaseBeta.ts +++ b/packages/config/src/configs/moonbaseBeta.ts @@ -1,8 +1,9 @@ import { BalanceBuilder, ExtrinsicBuilder, + FeeBuilder, } from '@moonbeam-network/xcm-builder'; -import { alan, betaDEV, dev, ftmwh, usdcwh } from '../assets'; +import { alan, betaDEV, dev } from '../assets'; import { moonbaseAlpha, moonbaseBeta } from '../chains'; import { AssetConfig } from '../types/AssetConfig'; import { ChainConfig } from '../types/ChainConfig'; @@ -14,7 +15,9 @@ export const moonbaseBetaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbaseAlpha, destinationFee: { - amount: 0.0002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().assets().account(), }, @@ -29,37 +32,9 @@ export const moonbaseBetaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbaseAlpha, destinationFee: { - amount: 0.002, - asset: dev, - balance: BalanceBuilder().substrate().system().account(), - }, - extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(), - fee: { - asset: betaDEV, - balance: BalanceBuilder().substrate().system().account(), - }, - }), - new AssetConfig({ - asset: usdcwh, - balance: BalanceBuilder().substrate().assets().account(), - destination: moonbaseAlpha, - destinationFee: { - amount: 0.002, - asset: dev, - balance: BalanceBuilder().substrate().system().account(), - }, - extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(), - fee: { - asset: betaDEV, - balance: BalanceBuilder().substrate().system().account(), - }, - }), - new AssetConfig({ - asset: ftmwh, - balance: BalanceBuilder().substrate().assets().account(), - destination: moonbaseAlpha, - destinationFee: { - amount: 0.002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/neuroweb.ts b/packages/config/src/configs/neuroweb.ts index b1ab0e48..7be24b7a 100644 --- a/packages/config/src/configs/neuroweb.ts +++ b/packages/config/src/configs/neuroweb.ts @@ -15,7 +15,9 @@ export const neurowebConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: neuro, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/nodle.ts b/packages/config/src/configs/nodle.ts index de532b5d..b9b26ab1 100644 --- a/packages/config/src/configs/nodle.ts +++ b/packages/config/src/configs/nodle.ts @@ -15,7 +15,9 @@ export const nodleConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: nodl, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/originTrailAlphanet.ts b/packages/config/src/configs/originTrailAlphanet.ts index a71c55d7..f7b17018 100644 --- a/packages/config/src/configs/originTrailAlphanet.ts +++ b/packages/config/src/configs/originTrailAlphanet.ts @@ -15,7 +15,9 @@ export const originTrailAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: otp, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/parallel.ts b/packages/config/src/configs/parallel.ts index 50320dac..e0182854 100644 --- a/packages/config/src/configs/parallel.ts +++ b/packages/config/src/configs/parallel.ts @@ -15,7 +15,9 @@ export const parallelConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: para, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const parallelConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/peaq.ts b/packages/config/src/configs/peaq.ts index d9fbb651..58e81089 100644 --- a/packages/config/src/configs/peaq.ts +++ b/packages/config/src/configs/peaq.ts @@ -16,7 +16,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: peaq, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, @@ -39,7 +43,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, @@ -55,7 +61,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, @@ -71,7 +79,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, @@ -87,7 +97,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, @@ -103,7 +115,9 @@ export const peaqConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/peaqAlphanet.ts b/packages/config/src/configs/peaqAlphanet.ts index efd40072..03a3db27 100644 --- a/packages/config/src/configs/peaqAlphanet.ts +++ b/packages/config/src/configs/peaqAlphanet.ts @@ -16,7 +16,9 @@ export const peaqAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: agng, balance: BalanceBuilder().substrate().system().account(), }, @@ -27,7 +29,9 @@ export const peaqAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbaseAlpha, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().assets().account(), }, @@ -39,7 +43,9 @@ export const peaqAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbaseAlpha, destinationFee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/peaqEvm.ts b/packages/config/src/configs/peaqEvm.ts index 8b5ca789..8737f9fd 100644 --- a/packages/config/src/configs/peaqEvm.ts +++ b/packages/config/src/configs/peaqEvm.ts @@ -2,6 +2,7 @@ import { AssetMinBuilder, BalanceBuilder, ContractBuilder, + FeeBuilder, } from '@moonbeam-network/xcm-builder'; import { dai, glmr, peaq, usdcwh, usdtwh, wbtc, weth } from '../assets'; import { moonbeam, peaqEvm } from '../chains'; @@ -16,7 +17,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transfer(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, @@ -32,7 +35,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, @@ -48,7 +53,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbeam, destinationFee: { - amount: 0.1, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, @@ -64,7 +71,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, @@ -80,7 +89,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, @@ -96,7 +107,9 @@ export const peaqEvmConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().evm().erc20(), }, diff --git a/packages/config/src/configs/peaqEvmAlphanet.ts b/packages/config/src/configs/peaqEvmAlphanet.ts index 788f5034..15d65de0 100644 --- a/packages/config/src/configs/peaqEvmAlphanet.ts +++ b/packages/config/src/configs/peaqEvmAlphanet.ts @@ -2,6 +2,7 @@ import { AssetMinBuilder, BalanceBuilder, ContractBuilder, + FeeBuilder, } from '@moonbeam-network/xcm-builder'; import { agng, dev, ftmwh } from '../assets'; import { moonbaseAlpha, peaqEvmAlphanet } from '../chains'; @@ -16,7 +17,9 @@ export const peaqEvmAlphanetConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transferMultiCurrencies(), destination: moonbaseAlpha, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().evm().erc20(), }, @@ -32,7 +35,9 @@ export const peaqEvmAlphanetConfig = new ChainConfig({ contract: ContractBuilder().Xtokens().transfer(), destination: moonbaseAlpha, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().evm().erc20(), }, diff --git a/packages/config/src/configs/pendulum.ts b/packages/config/src/configs/pendulum.ts index 4850842d..f2620421 100644 --- a/packages/config/src/configs/pendulum.ts +++ b/packages/config/src/configs/pendulum.ts @@ -15,7 +15,9 @@ export const pendulumConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pen, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const pendulumConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -41,7 +45,9 @@ export const pendulumConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/pendulumAlphanet.ts b/packages/config/src/configs/pendulumAlphanet.ts index 6827d549..1f1f588c 100644 --- a/packages/config/src/configs/pendulumAlphanet.ts +++ b/packages/config/src/configs/pendulumAlphanet.ts @@ -15,7 +15,9 @@ export const pendulumAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ampe, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const pendulumAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/phala.ts b/packages/config/src/configs/phala.ts index 62310462..03528022 100644 --- a/packages/config/src/configs/phala.ts +++ b/packages/config/src/configs/phala.ts @@ -15,7 +15,9 @@ export const phalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pha, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const phalaConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/picasso.ts b/packages/config/src/configs/picasso.ts index 388ddac0..2e488334 100644 --- a/packages/config/src/configs/picasso.ts +++ b/packages/config/src/configs/picasso.ts @@ -15,7 +15,9 @@ export const picassoConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: pica, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const picassoConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/picassoAlphanet.ts b/packages/config/src/configs/picassoAlphanet.ts index f22ce37a..28864405 100644 --- a/packages/config/src/configs/picassoAlphanet.ts +++ b/packages/config/src/configs/picassoAlphanet.ts @@ -15,7 +15,9 @@ export const picassoAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pica, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const picassoAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pica, balance: BalanceBuilder().substrate().system().account(), }, @@ -41,7 +45,9 @@ export const picassoAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/polkadot.ts b/packages/config/src/configs/polkadot.ts index 63eeb2b9..d0360153 100644 --- a/packages/config/src/configs/polkadot.ts +++ b/packages/config/src/configs/polkadot.ts @@ -15,7 +15,9 @@ export const polkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: dot, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/polkadotAssetHub.ts b/packages/config/src/configs/polkadotAssetHub.ts index e1232812..17f281ba 100644 --- a/packages/config/src/configs/polkadotAssetHub.ts +++ b/packages/config/src/configs/polkadotAssetHub.ts @@ -18,7 +18,9 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -38,7 +40,9 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdc, balance: BalanceBuilder().substrate().assets().account(), }, @@ -58,7 +62,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -78,7 +85,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -98,7 +108,9 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -118,7 +130,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -138,7 +153,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/robonomics.ts b/packages/config/src/configs/robonomics.ts index 7cb942b1..7718e3e6 100644 --- a/packages/config/src/configs/robonomics.ts +++ b/packages/config/src/configs/robonomics.ts @@ -15,7 +15,9 @@ export const robonomicsConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: xrt, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/shiden.ts b/packages/config/src/configs/shiden.ts index 6f1baece..a48e1115 100644 --- a/packages/config/src/configs/shiden.ts +++ b/packages/config/src/configs/shiden.ts @@ -15,7 +15,9 @@ export const shidenConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: sdn, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const shidenConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonriver, destinationFee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, balance: BalanceBuilder().substrate().assets().account(), }, diff --git a/packages/config/src/configs/subsocial.ts b/packages/config/src/configs/subsocial.ts index 882f87fa..d20b10a0 100644 --- a/packages/config/src/configs/subsocial.ts +++ b/packages/config/src/configs/subsocial.ts @@ -15,7 +15,9 @@ export const subsocialConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: sub, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/tinkernet.ts b/packages/config/src/configs/tinkernet.ts index fc13ae8f..75db28e5 100644 --- a/packages/config/src/configs/tinkernet.ts +++ b/packages/config/src/configs/tinkernet.ts @@ -15,7 +15,9 @@ export const tinkernetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: tnkr, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/config/src/configs/turing.ts b/packages/config/src/configs/turing.ts index 71c8806a..001cc3f4 100644 --- a/packages/config/src/configs/turing.ts +++ b/packages/config/src/configs/turing.ts @@ -15,7 +15,9 @@ export const turingConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonriver, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + }), asset: tur, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const turingConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonriver, destinationFee: { - amount: 0.00001, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: true, + }), asset: movr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/turingAlphanet.ts b/packages/config/src/configs/turingAlphanet.ts index 40994519..af9b671c 100644 --- a/packages/config/src/configs/turingAlphanet.ts +++ b/packages/config/src/configs/turingAlphanet.ts @@ -15,7 +15,9 @@ export const turingAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbaseAlpha, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tur, balance: BalanceBuilder().substrate().system().account(), }, @@ -29,7 +31,9 @@ export const turingAlphanetConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbaseAlpha, destinationFee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/config/src/configs/uniqueAlpha.ts b/packages/config/src/configs/uniqueAlpha.ts deleted file mode 100644 index 322a9266..00000000 --- a/packages/config/src/configs/uniqueAlpha.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { uniqueAlpha } from '../chains'; -import { ChainConfig } from '../types/ChainConfig'; - -// NOTE: Disabling because ws endpoint is not working -export const uniqueAlphaConfig = new ChainConfig({ - assets: [ - // new AssetConfig({ - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // destination: moonbaseAlpha, - // destinationFee: { - // amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // }, - // extrinsic: ExtrinsicBuilder().xTokens().transfer(), - // }), - ], - chain: uniqueAlpha, -}); diff --git a/packages/config/src/configs/zeitgeist.ts b/packages/config/src/configs/zeitgeist.ts index 329785cc..179d09c0 100644 --- a/packages/config/src/configs/zeitgeist.ts +++ b/packages/config/src/configs/zeitgeist.ts @@ -15,7 +15,9 @@ export const zeitgeistConfig = new ChainConfig({ balance: BalanceBuilder().substrate().system().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ztg, balance: BalanceBuilder().substrate().system().account(), }, @@ -26,7 +28,9 @@ export const zeitgeistConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, @@ -41,7 +45,9 @@ export const zeitgeistConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, balance: BalanceBuilder().substrate().tokens().accounts(), }, diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 5eb0154d..8474e34d 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,42 @@ # @moonbeam-network/xcm-sdk +## 2.6.3 + +### Patch Changes + +- Updated dependencies [[`5d308c3`](https://github.com/moonbeam-foundation/xcm-sdk/commit/5d308c3455126b5dfedb93c38a0afb18344a183e)]: + - @moonbeam-network/xcm-config@2.6.3 + +## 2.6.2 + +### Patch Changes + +- Updated dependencies [[`3f22072`](https://github.com/moonbeam-foundation/xcm-sdk/commit/3f22072c837a55e9109ad042efa555a46802e6e6)]: + - @moonbeam-network/xcm-config@2.6.2 + +## 2.6.1 + +### Patch Changes + +- Updated dependencies [[`4be5659`](https://github.com/moonbeam-foundation/xcm-sdk/commit/4be5659c05fe2487dd6f440c833fdf7cdc369917)]: + - @moonbeam-network/xcm-utils@2.2.0 + - @moonbeam-network/xcm-builder@2.5.1 + - @moonbeam-network/xcm-types@2.4.1 + - @moonbeam-network/xcm-config@2.6.1 + +## 2.6.0 + +### Minor Changes + +- [#351](https://github.com/moonbeam-foundation/xcm-sdk/pull/351) [`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769) Thanks [@mmaurello](https://github.com/mmaurello)! - Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha + +### Patch Changes + +- Updated dependencies [[`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769)]: + - @moonbeam-network/xcm-builder@2.5.0 + - @moonbeam-network/xcm-config@2.6.0 + - @moonbeam-network/xcm-types@2.4.0 + ## 2.5.14 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8fac1ed6..0fa62f2b 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "2.5.14", + "version": "2.6.3", "description": "The Moonbeam XCM SDK enables developers to easily deposit and withdraw assets to Moonbeam/Moonriver from the relay chain and other parachains in the Polkadot/Kusama ecosystem", "scripts": { "build": "tsup", @@ -51,10 +51,10 @@ "types": "./build/index.d.ts", "main": "./build/index.cjs", "dependencies": { - "@moonbeam-network/xcm-builder": "2.4.7", - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-types": "2.3.4", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-types": "2.4.1", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { diff --git a/packages/sdk/src/getTransferData/getDestinationData.ts b/packages/sdk/src/getTransferData/getDestinationData.ts index cb71f558..8fa9d064 100644 --- a/packages/sdk/src/getTransferData/getDestinationData.ts +++ b/packages/sdk/src/getTransferData/getDestinationData.ts @@ -80,6 +80,7 @@ export interface GetFeeParams { } export async function getFee({ + address, config, polkadot, }: GetFeeParams): Promise { @@ -98,8 +99,11 @@ export async function getFee({ } const cfg = (amount as FeeConfigBuilder).build({ + address, api: polkadot.api, - asset: polkadot.chain.getAssetId(asset), + chain: polkadot.chain, + feeAsset: polkadot.chain.getRegisteredAssetIdOrAddress(asset), + transferAsset: polkadot.chain.getRegisteredAssetIdOrAddress(config.asset), }); return zeroAmount.copyWith({ diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d1b8d0af..ddcb6d5b 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,5 +1,18 @@ # @moonbeam-network/xcm-types +## 2.4.1 + +### Patch Changes + +- Updated dependencies [[`4be5659`](https://github.com/moonbeam-foundation/xcm-sdk/commit/4be5659c05fe2487dd6f440c833fdf7cdc369917)]: + - @moonbeam-network/xcm-utils@2.2.0 + +## 2.4.0 + +### Minor Changes + +- [#351](https://github.com/moonbeam-foundation/xcm-sdk/pull/351) [`2a7ed04`](https://github.com/moonbeam-foundation/xcm-sdk/commit/2a7ed04887ee41e5a6c010f213265028a953a769) Thanks [@mmaurello](https://github.com/mmaurello)! - Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha + ## 2.3.4 ### Patch Changes diff --git a/packages/types/package.json b/packages/types/package.json index f8061f63..763f7a9a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-types", - "version": "2.3.4", + "version": "2.4.1", "description": "Moonbeam XCM Types", "scripts": { "build": "tsup", @@ -48,7 +48,7 @@ "types": "./build/index.d.ts", "main": "./build/index.cjs", "dependencies": { - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { diff --git a/packages/types/src/chain/parachain/Parachain.ts b/packages/types/src/chain/parachain/Parachain.ts index 6dc91e16..fc6221fc 100644 --- a/packages/types/src/chain/parachain/Parachain.ts +++ b/packages/types/src/chain/parachain/Parachain.ts @@ -81,6 +81,11 @@ export class Parachain extends Chain { return this.assetsData.get(asset.key)?.metadataId ?? this.getAssetId(asset); } + getRegisteredAssetIdOrAddress(asset: Asset): ChainAssetId { + const metadataId = this.assetsData.get(asset.key)?.metadataId; + return metadataId && metadataId !== 0 ? metadataId : this.getAssetId(asset); + } + getAssetPalletInstance(asset: Asset): number | undefined { return this.assetsData.get(asset.key)?.palletInstance; } diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 3e6b6321..602bb966 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,11 @@ # @moonbeam-network/xcm-utils +## 2.2.0 + +### Minor Changes + +- [#353](https://github.com/moonbeam-foundation/xcm-sdk/pull/353) [`4be5659`](https://github.com/moonbeam-foundation/xcm-sdk/commit/4be5659c05fe2487dd6f440c833fdf7cdc369917) Thanks [@mmaurello](https://github.com/mmaurello)! - Release minor version for xcm-utils with isHexString + ## 2.1.7 ### Patch Changes diff --git a/packages/utils/package.json b/packages/utils/package.json index 2e4fc897..25dad121 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-utils", - "version": "2.1.7", + "version": "2.2.0", "description": "Moonbeam XCM utilities", "scripts": { "build": "tsup", diff --git a/packages/utils/src/format/address.ts b/packages/utils/src/format/address.ts new file mode 100644 index 00000000..ed85a3e2 --- /dev/null +++ b/packages/utils/src/format/address.ts @@ -0,0 +1,3 @@ +export function isHexString(asset: unknown): boolean { + return typeof asset === 'string' && asset.startsWith('0x'); +} diff --git a/packages/utils/src/format/index.ts b/packages/utils/src/format/index.ts index ea2719dd..db085153 100644 --- a/packages/utils/src/format/index.ts +++ b/packages/utils/src/format/index.ts @@ -1 +1,2 @@ +export * from './address'; export * from './asset';