From 66ae4fb17c3f9623ca43aeaa828daff5e4875d68 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:19:47 +0200 Subject: [PATCH] V3 next xcm payment api (#354) * Apply XcmPaymentApi fees in transactions to Moonbeam / Moonriver / Moonbase-Alpha (#351) * -wip- initial commit and initial configs * -wip- extract common code * -wip- fix some types * -wip- TODOs and refactoring * -wip- group all in a single function * -wip- apply to all Acala and Hydration routes * -wip- apply to manta routes * apply xcmv4 and solution for registered asset id for ERC20s * sort assets, handle different palletInstances and apply to several configs * remove unused property * remove logs * remove deleted routes from snapshots * apply new configuration to Kusama chains * add changeset * remove assetTypeUnitsPerSecond function since it is not used now * remove assetTypeUnitsPerSecond function since it is not used now * apply PR reviews * Version Packages (#352) Co-authored-by: github-actions[bot] * update snapshots * add asset ordering param to ibtc and kbtc * fix linting and spell checking * add changeset for xcm-utils (#353) * Version Packages (#355) Co-authored-by: github-actions[bot] * fix linting and spell checking * fix linting error * move palletInstance validation * fix TEER configuration in Integritee (#356) * Version Packages (#357) Co-authored-by: github-actions[bot] * change native asset checking and builder interface * fix error * Fix Asset Hub memecoings asset ordering in fee calculation (#359) * Version Packages (#360) Co-authored-by: github-actions[bot] * fix lint * change property name * rename properties --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] --- examples/sdk-simple/index.ts | 32 +-- mkdocs/docs/contribute.md | 4 +- mkdocs/docs/reference/interfaces.md | 12 +- packages/builder/CHANGELOG.md | 19 ++ packages/builder/package.json | 2 +- .../builder/src/fee/FeeBuilder.interfaces.ts | 20 +- packages/builder/src/fee/FeeBuilder.ts | 79 ++++-- packages/builder/src/fee/FeeBuilder.utils.ts | 253 ++++++++++++++++++ packages/config/CHANGELOG.md | 32 +++ packages/config/package.json | 2 +- packages/config/src/chains.ts | 14 +- packages/config/src/xcm-configs/acala.ts | 16 +- .../src/xcm-configs/alphanetAssetHub.ts | 4 +- .../config/src/xcm-configs/alphanetRelay.ts | 4 +- packages/config/src/xcm-configs/astar.ts | 8 +- .../config/src/xcm-configs/bifrostKusama.ts | 20 +- .../config/src/xcm-configs/bifrostPolkadot.ts | 36 ++- packages/config/src/xcm-configs/calamari.ts | 8 +- packages/config/src/xcm-configs/centrifuge.ts | 4 +- .../config/src/xcm-configs/crustShadow.ts | 8 +- packages/config/src/xcm-configs/darwinia.ts | 4 +- .../config/src/xcm-configs/darwiniaCrab.ts | 4 +- packages/config/src/xcm-configs/hydration.ts | 28 +- .../src/xcm-configs/hydrationAlphanet.ts | 16 +- packages/config/src/xcm-configs/index.ts | 2 - packages/config/src/xcm-configs/integritee.ts | 4 +- packages/config/src/xcm-configs/interlay.ts | 13 +- packages/config/src/xcm-configs/karura.ts | 12 +- packages/config/src/xcm-configs/khala.ts | 8 +- packages/config/src/xcm-configs/kintsugi.ts | 9 +- packages/config/src/xcm-configs/kusama.ts | 4 +- .../config/src/xcm-configs/kusamaAssetHub.ts | 8 +- .../config/src/xcm-configs/mangataKusama.ts | 8 +- .../config/src/xcm-configs/mantaParachain.ts | 8 +- .../config/src/xcm-configs/moonbaseAlpha.ts | 17 -- .../config/src/xcm-configs/moonbaseBeta.ts | 17 +- packages/config/src/xcm-configs/neuroweb.ts | 4 +- packages/config/src/xcm-configs/nodle.ts | 4 +- .../src/xcm-configs/originTrailAlphanet.ts | 4 +- packages/config/src/xcm-configs/parallel.ts | 8 +- packages/config/src/xcm-configs/peaq.ts | 28 +- .../config/src/xcm-configs/peaqAlphanet.ts | 12 +- packages/config/src/xcm-configs/peaqEvm.ts | 25 +- .../config/src/xcm-configs/peaqEvmAlphanet.ts | 9 +- packages/config/src/xcm-configs/pendulum.ts | 12 +- .../src/xcm-configs/pendulumAlphanet.ts | 8 +- packages/config/src/xcm-configs/phala.ts | 8 +- packages/config/src/xcm-configs/picasso.ts | 8 +- .../config/src/xcm-configs/picassoAlphanet.ts | 12 +- packages/config/src/xcm-configs/polkadot.ts | 4 +- .../src/xcm-configs/polkadotAssetHub.ts | 32 ++- packages/config/src/xcm-configs/robonomics.ts | 4 +- packages/config/src/xcm-configs/shiden.ts | 8 +- packages/config/src/xcm-configs/subsocial.ts | 4 +- packages/config/src/xcm-configs/tinkernet.ts | 4 +- packages/config/src/xcm-configs/turing.ts | 8 +- .../config/src/xcm-configs/turingAlphanet.ts | 8 +- .../config/src/xcm-configs/uniqueAlpha.ts | 23 -- packages/config/src/xcm-configs/zeitgeist.ts | 12 +- .../src/getTransferData/getMoonChainData.ts | 4 +- packages/sdk/CHANGELOG.md | 37 +++ packages/sdk/package.json | 2 +- .../src/getTransferData/getDestinationData.ts | 4 +- .../getTransferData/getTransferData.utils.ts | 19 +- .../acceptance/__snapshots__/sdk.test.ts.snap | 4 +- packages/types/CHANGELOG.md | 13 + packages/types/package.json | 2 +- packages/utils/CHANGELOG.md | 6 + packages/utils/package.json | 2 +- packages/utils/src/format/address.ts | 3 + packages/utils/src/format/index.ts | 1 + 71 files changed, 868 insertions(+), 217 deletions(-) create mode 100644 packages/builder/src/fee/FeeBuilder.utils.ts delete mode 100644 packages/config/src/xcm-configs/uniqueAlpha.ts create mode 100644 packages/utils/src/format/address.ts diff --git a/examples/sdk-simple/index.ts b/examples/sdk-simple/index.ts index 0a8f9912..145ac476 100644 --- a/examples/sdk-simple/index.ts +++ b/examples/sdk-simple/index.ts @@ -1,13 +1,13 @@ -import { dot, moonbeam, polkadot } from "@moonbeam-network/xcm-config"; -import { Sdk, type TransferData } from "@moonbeam-network/xcm-sdk"; -import { Keyring } from "@polkadot/api"; -import { cryptoWaitReady } from "@polkadot/util-crypto"; -import { http, type Address, createWalletClient } from "viem"; -import { privateKeyToAccount } from "viem/accounts"; +import { dot, moonbeam, polkadot } from '@moonbeam-network/xcm-config'; +import { Sdk, type TransferData } from '@moonbeam-network/xcm-sdk'; +import { Keyring } from '@polkadot/api'; +import { cryptoWaitReady } from '@polkadot/util-crypto'; +import { http, type Address, createWalletClient } from 'viem'; +import { privateKeyToAccount } from 'viem/accounts'; // Moonbeam Signer =========================================================== -const moonbeamPrivateKey = ""; +const moonbeamPrivateKey = ''; const account = privateKeyToAccount(moonbeamPrivateKey as Address); const walletClient = createWalletClient({ account, @@ -17,12 +17,12 @@ const walletClient = createWalletClient({ // Polkadot Signer =========================================================== -const polkadotPrivateKey = ""; +const polkadotPrivateKey = ''; await cryptoWaitReady(); const keyring = new Keyring({ ss58Format: polkadot.ss58Format, - type: "sr25519", + type: 'sr25519', }); const pair = keyring.createFromUri(polkadotPrivateKey); @@ -32,14 +32,14 @@ export function logBalances(data: TransferData): void { console.log( `Balance on ${data.source.chain.name} ${data.source.balance.toDecimal()} ${ data.source.balance.symbol - }` + }`, ); console.log( `Balance on ${ data.destination.chain.name } ${data.destination.balance.toDecimal()} ${ data.destination.balance.symbol - }` + }`, ); } @@ -57,12 +57,12 @@ export function logTxDetails(data: TransferData): void { data.source.chain.name } and ${data.destination.fee.toDecimal()} ${ data.destination.fee.symbol - } fee on ${data.destination.chain.name}.` + } fee on ${data.destination.chain.name}.`, ); } export async function fromPolkadot() { - console.log("\nTransfer from Polkadot to Moonbeam\n"); + console.log('\nTransfer from Polkadot to Moonbeam\n'); const data = await Sdk().getTransferData({ destinationAddress: account.address, @@ -86,7 +86,7 @@ export async function fromPolkadot() { } export async function fromMoonbeam() { - console.log("\nTransfer from Moonbeam to Polkadot\n"); + console.log('\nTransfer from Moonbeam to Polkadot\n'); const data = await Sdk() .assets() @@ -118,12 +118,12 @@ async function main() { console.log(`Polkadot address: ${pair.address}.`); await fromPolkadot(); - console.log("\nWaiting 30 seconds..."); + console.log('\nWaiting 30 seconds...'); await setTimeout(30000); await fromMoonbeam(); } main() - .then(() => console.log("done!")) + .then(() => console.log('done!')) .catch(console.error) .finally(() => process.exit()); diff --git a/mkdocs/docs/contribute.md b/mkdocs/docs/contribute.md index ae7c23d3..22f77cd1 100644 --- a/mkdocs/docs/contribute.md +++ b/mkdocs/docs/contribute.md @@ -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 b1058748..518addb0 100644 --- a/mkdocs/docs/reference/interfaces.md +++ b/mkdocs/docs/reference/interfaces.md @@ -691,7 +691,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(), }, @@ -761,7 +763,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(), }, @@ -831,7 +835,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/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 b9fe6e6b..29846191 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", diff --git a/packages/builder/src/fee/FeeBuilder.interfaces.ts b/packages/builder/src/fee/FeeBuilder.interfaces.ts index d81b7d4a..ae424bb7 100644 --- a/packages/builder/src/fee/FeeBuilder.interfaces.ts +++ b/packages/builder/src/fee/FeeBuilder.interfaces.ts @@ -1,5 +1,7 @@ -import type { ChainAssetId } from '@moonbeam-network/xcm-types'; +import type { AnyParachain, ChainAsset } from '@moonbeam-network/xcm-types'; import type { ApiPromise } from '@polkadot/api'; +import type { Enum } from '@polkadot/types'; +import type { StagingXcmV3MultiLocation } from '@polkadot/types/lookup'; import type { ConfigBuilder } from '../builder.interfaces'; import type { SubstrateCallConfig } from '../types/substrate/SubstrateCallConfig'; @@ -9,6 +11,20 @@ export type FeeConfigBuilder = ConfigBuilder< >; export interface FeeConfigBuilderPrams { - asset: ChainAssetId; + address: string; api: ApiPromise; + asset: ChainAsset; + destination: AnyParachain; + feeAsset: ChainAsset; +} + +export interface XcmPaymentFeeProps { + isAssetReserveChain: boolean; + shouldTransferAssetPrecedeFeeAsset?: 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 6f4cad13..3204595a 100644 --- a/packages/builder/src/fee/FeeBuilder.ts +++ b/packages/builder/src/fee/FeeBuilder.ts @@ -1,38 +1,77 @@ -import type { Option, u128 } from '@polkadot/types'; +/* eslint-disable sort-keys */ +/* eslint-disable @typescript-eslint/no-use-before-define */ + import { SubstrateCallConfig } from '../types/substrate/SubstrateCallConfig'; -import type { FeeConfigBuilder } from './FeeBuilder.interfaces'; +import type { + FeeConfigBuilder, + FeeConfigBuilderPrams, + 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, + shouldTransferAssetPrecedeFeeAsset = false, + }: XcmPaymentFeeProps): FeeConfigBuilder => ({ + build: ({ + address, + api, + asset, + destination, + feeAsset, + }: FeeConfigBuilderPrams) => new SubstrateCallConfig({ api, call: async (): Promise => { - const type = (await api.query.assetManager.assetIdType( + const versionedFeeAssetId = await getVersionedAssetId( + api, + feeAsset, + destination, + ); + const versionedTransferAssetId = await getVersionedAssetId( + api, asset, - // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this - )) as unknown as Option; - - if (type.isNone) { - throw new Error(`No asset type found for asset ${asset}`); - } - - const unwrappedType = type.unwrap(); + destination, + ); + const versionedAssets = shouldTransferAssetPrecedeFeeAsset + ? [versionedTransferAssetId, versionedFeeAssetId] + : [versionedFeeAssetId, versionedTransferAssetId]; - const res = (await api.query.assetManager.assetTypeUnitsPerSecond( - unwrappedType, - )) as unknown as Option; + const assets = + feeAsset === asset ? [versionedFeeAssetId] : versionedAssets; - const unitsPerSecond = res.unwrapOrDefault().toBigInt(); + const instructions = [ + isAssetReserveChain + ? getWithdrawAssetInstruction(assets) + : getReserveAssetDepositedInstruction(assets), + getClearOriginInstruction(), + getBuyExecutionInstruction(versionedFeeAssetId), + getDepositAssetInstruction(address, assets), + getSetTopicInstruction(), + ]; - return (BigInt(weight) * unitsPerSecond) / BigInt(10 ** 12); + return getFeeForXcmInstructionsAndAsset( + api, + instructions, + versionedFeeAssetId, + ); }, }), }), diff --git a/packages/builder/src/fee/FeeBuilder.utils.ts b/packages/builder/src/fee/FeeBuilder.utils.ts new file mode 100644 index 00000000..da5beb51 --- /dev/null +++ b/packages/builder/src/fee/FeeBuilder.utils.ts @@ -0,0 +1,253 @@ +import type { + AnyParachain, + ChainAsset, + ChainAssetId, +} from '@moonbeam-network/xcm-types'; +import { isHexString } from '@moonbeam-network/xcm-utils'; +import type { ApiPromise } from '@polkadot/api'; +import type { Option, Result, u128 } from '@polkadot/types'; +import type { + Error as PolkadotError, + Weight, +} from '@polkadot/types/interfaces'; +import type { AnyJson } from '@polkadot/types/types'; +import { XcmVersion } from '../extrinsic'; +import type { MoonbeamRuntimeXcmConfigAssetType } from './FeeBuilder.interfaces'; + +const DEFAULT_AMOUNT = 10 ** 6; +const DEFAULT_HEX_STRING = + '0xabcdef1234567890fedcba0987654321abcdef1234567890fedcba0987654321'; + +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: DEFAULT_HEX_STRING, + }; +} + +function applyConcreteWrapper(id: object) { + return { + Concrete: { ...id }, + }; +} + +// TODO this is for Moonbeam, when applying to all we have to +// configure the multilocation of the native asset in the chain +function getNativeAssetId(palletInstanceNumber: number | undefined): object { + if (!palletInstanceNumber) { + throw new Error( + 'No pallet instance configured for the native asset for XcmPaymentApi fee calculation', + ); + } + + const palletInstance = { + PalletInstance: palletInstanceNumber, + }; + const id = { + interior: { + X1: isXcmV4() ? [palletInstance] : palletInstance, + }, + parents: '0', + }; + + return isXcmV4() ? id : applyConcreteWrapper(id); +} + +function getConcreteAssetIdWithAccountKey20( + asset: ChainAssetId, + palletInstance: number | undefined, +): object { + if (!palletInstance) { + throw new Error( + `No pallet instance configured for the asset ${asset} for XcmPaymentApi fee calculation`, + ); + } + + const id = { + interior: { + X2: [ + { + PalletInstance: palletInstance, + }, + { + 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: ChainAsset, + chain: AnyParachain, +): Promise { + const assetId = asset.getAssetId(); + const palletInstance = asset.getAssetPalletInstance(); + + if (assetId === chain.nativeAsset.address) { + return getNativeAssetId(palletInstance); + } + + if (isHexString(assetId)) { + return getConcreteAssetIdWithAccountKey20(assetId, palletInstance); + } + + const assetType = await getAssetIdType(api, assetId); + 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 weightToForeignAssets = + await api.call.xcmPaymentApi.queryWeightToAssetFee< + Result + >(xcmToWeight, { + [XCM_VERSION]: { + ...versionedAssetId, + }, + }); + if (!weightToForeignAssets.isOk) { + throw new Error( + 'There was an error trying to get the fee with the weight and asset (weightToForeignAssets)', + ); + } + return weightToForeignAssets.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 53cb2003..1ce7d523 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", diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index f55b420f..659a338b 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -452,7 +452,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 fantomTestnet = new EvmChain({ @@ -590,7 +590,14 @@ export const hydrationAlphanet = new Parachain({ }); export const integritee = new Parachain({ - assets: [ChainAsset.fromAsset(teer, { decimals: 12 })], + assets: [ + ChainAsset.fromAsset(teer, { + decimals: 12, + ids: { + id: teer.originSymbol, + }, + }), + ], ecosystem: Ecosystem.Kusama, genesisHash: '0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da', @@ -1088,6 +1095,9 @@ export const moonbeam = new EvmParachain({ ChainAsset.fromAsset(fil, { address: '0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2', decimals: 18, + ids: { + id: '144012926827374458669278577633504620722', + }, }), ChainAsset.fromAsset(glmr, { address: '0x0000000000000000000000000000000000000802', diff --git a/packages/config/src/xcm-configs/acala.ts b/packages/config/src/xcm-configs/acala.ts index d0d42e88..ccae30a0 100644 --- a/packages/config/src/xcm-configs/acala.ts +++ b/packages/config/src/xcm-configs/acala.ts @@ -24,7 +24,9 @@ export const acalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aca, }, }, @@ -48,7 +50,9 @@ export const acalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aseed, }, }, @@ -72,7 +76,9 @@ export const acalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -96,7 +102,9 @@ export const acalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.005, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ldot, }, }, diff --git a/packages/config/src/xcm-configs/alphanetAssetHub.ts b/packages/config/src/xcm-configs/alphanetAssetHub.ts index b27c9514..5f8f0025 100644 --- a/packages/config/src/xcm-configs/alphanetAssetHub.ts +++ b/packages/config/src/xcm-configs/alphanetAssetHub.ts @@ -29,7 +29,9 @@ export const alphanetAssetHubRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tt1, }, }, diff --git a/packages/config/src/xcm-configs/alphanetRelay.ts b/packages/config/src/xcm-configs/alphanetRelay.ts index 7bc8590f..b91a949c 100644 --- a/packages/config/src/xcm-configs/alphanetRelay.ts +++ b/packages/config/src/xcm-configs/alphanetRelay.ts @@ -23,7 +23,9 @@ export const alphanetRelayRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: unit, }, }, diff --git a/packages/config/src/xcm-configs/astar.ts b/packages/config/src/xcm-configs/astar.ts index 8e8b121b..2766c631 100644 --- a/packages/config/src/xcm-configs/astar.ts +++ b/packages/config/src/xcm-configs/astar.ts @@ -23,7 +23,9 @@ export const astarRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: astr, }, }, @@ -49,7 +51,9 @@ export const astarRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/bifrostKusama.ts b/packages/config/src/xcm-configs/bifrostKusama.ts index 492df67c..f63503f3 100644 --- a/packages/config/src/xcm-configs/bifrostKusama.ts +++ b/packages/config/src/xcm-configs/bifrostKusama.ts @@ -24,7 +24,9 @@ export const bifrostKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -48,7 +50,9 @@ export const bifrostKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, @@ -72,7 +76,9 @@ export const bifrostKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -96,7 +102,9 @@ export const bifrostKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -120,7 +128,9 @@ export const bifrostKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, diff --git a/packages/config/src/xcm-configs/bifrostPolkadot.ts b/packages/config/src/xcm-configs/bifrostPolkadot.ts index 3c67ebab..be69cda9 100644 --- a/packages/config/src/xcm-configs/bifrostPolkadot.ts +++ b/packages/config/src/xcm-configs/bifrostPolkadot.ts @@ -34,7 +34,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -58,7 +60,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -82,7 +86,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -106,7 +112,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -130,7 +138,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: vdot, }, }, @@ -154,7 +164,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -178,7 +190,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -202,7 +216,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.2, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, @@ -226,7 +242,9 @@ export const bifrostPolkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.05, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: bnc, }, }, diff --git a/packages/config/src/xcm-configs/calamari.ts b/packages/config/src/xcm-configs/calamari.ts index e27475d0..df1986a6 100644 --- a/packages/config/src/xcm-configs/calamari.ts +++ b/packages/config/src/xcm-configs/calamari.ts @@ -24,7 +24,9 @@ export const calamariRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: kma, }, }, @@ -48,7 +50,9 @@ export const calamariRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/centrifuge.ts b/packages/config/src/xcm-configs/centrifuge.ts index 317df5b2..f56479f1 100644 --- a/packages/config/src/xcm-configs/centrifuge.ts +++ b/packages/config/src/xcm-configs/centrifuge.ts @@ -23,7 +23,9 @@ export const centrifugeRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: cfg, }, }, diff --git a/packages/config/src/xcm-configs/crustShadow.ts b/packages/config/src/xcm-configs/crustShadow.ts index d021e625..7962a3e7 100644 --- a/packages/config/src/xcm-configs/crustShadow.ts +++ b/packages/config/src/xcm-configs/crustShadow.ts @@ -23,7 +23,9 @@ export const crustShadowRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: csm, }, }, @@ -49,7 +51,9 @@ export const crustShadowRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/darwinia.ts b/packages/config/src/xcm-configs/darwinia.ts index aaf20e3c..bf531fd9 100644 --- a/packages/config/src/xcm-configs/darwinia.ts +++ b/packages/config/src/xcm-configs/darwinia.ts @@ -23,7 +23,9 @@ export const darwiniaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ring, }, }, diff --git a/packages/config/src/xcm-configs/darwiniaCrab.ts b/packages/config/src/xcm-configs/darwiniaCrab.ts index bd819f4f..dc10cd7c 100644 --- a/packages/config/src/xcm-configs/darwiniaCrab.ts +++ b/packages/config/src/xcm-configs/darwiniaCrab.ts @@ -23,7 +23,9 @@ export const darwiniaCrabRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: crab, }, }, diff --git a/packages/config/src/xcm-configs/hydration.ts b/packages/config/src/xcm-configs/hydration.ts index 496c01ff..107635f9 100644 --- a/packages/config/src/xcm-configs/hydration.ts +++ b/packages/config/src/xcm-configs/hydration.ts @@ -23,7 +23,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: hdx, }, }, @@ -42,7 +44,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -65,7 +69,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -88,7 +94,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -111,7 +119,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -134,7 +144,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -157,7 +169,9 @@ export const hydrationRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/hydrationAlphanet.ts b/packages/config/src/xcm-configs/hydrationAlphanet.ts index 3e944ec3..a2c8910d 100644 --- a/packages/config/src/xcm-configs/hydrationAlphanet.ts +++ b/packages/config/src/xcm-configs/hydrationAlphanet.ts @@ -24,7 +24,9 @@ export const hydrationAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: hdx, }, }, @@ -43,7 +45,9 @@ export const hydrationAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -66,7 +70,9 @@ export const hydrationAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -89,7 +95,9 @@ export const hydrationAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/index.ts b/packages/config/src/xcm-configs/index.ts index ec642f6b..328ebd71 100644 --- a/packages/config/src/xcm-configs/index.ts +++ b/packages/config/src/xcm-configs/index.ts @@ -47,7 +47,6 @@ import { subsocialRoutes } from './subsocial'; import { tinkernetRoutes } from './tinkernet'; import { turingRoutes } from './turing'; import { turingAlphanetRoutes } from './turingAlphanet'; -import { uniqueAlphaRoutes } from './uniqueAlpha'; import { zeitgeistRoutes } from './zeitgeist'; export const xcmRoutesList: ChainRoutes[] = [ @@ -98,7 +97,6 @@ export const xcmRoutesList: ChainRoutes[] = [ tinkernetRoutes, turingRoutes, turingAlphanetRoutes, - uniqueAlphaRoutes, zeitgeistRoutes, ]; diff --git a/packages/config/src/xcm-configs/integritee.ts b/packages/config/src/xcm-configs/integritee.ts index aed013f7..f2aa2742 100644 --- a/packages/config/src/xcm-configs/integritee.ts +++ b/packages/config/src/xcm-configs/integritee.ts @@ -23,7 +23,9 @@ export const integriteeRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: teer, }, }, diff --git a/packages/config/src/xcm-configs/interlay.ts b/packages/config/src/xcm-configs/interlay.ts index 52ff61cd..8b3f52b3 100644 --- a/packages/config/src/xcm-configs/interlay.ts +++ b/packages/config/src/xcm-configs/interlay.ts @@ -23,7 +23,9 @@ export const interlayRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: intr, }, }, @@ -46,7 +48,10 @@ export const interlayRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: intr, }, }, @@ -65,7 +70,9 @@ export const interlayRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/karura.ts b/packages/config/src/xcm-configs/karura.ts index 1b91cb5d..a0251217 100644 --- a/packages/config/src/xcm-configs/karura.ts +++ b/packages/config/src/xcm-configs/karura.ts @@ -24,7 +24,9 @@ export const karuraRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: kar, }, }, @@ -48,7 +50,9 @@ export const karuraRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: aseed, }, }, @@ -72,7 +76,9 @@ export const karuraRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/khala.ts b/packages/config/src/xcm-configs/khala.ts index 73665cd3..812636c3 100644 --- a/packages/config/src/xcm-configs/khala.ts +++ b/packages/config/src/xcm-configs/khala.ts @@ -23,7 +23,9 @@ export const khalaRouts = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pha, }, }, @@ -46,7 +48,9 @@ export const khalaRouts = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/kintsugi.ts b/packages/config/src/xcm-configs/kintsugi.ts index 32f77853..568e9a3b 100644 --- a/packages/config/src/xcm-configs/kintsugi.ts +++ b/packages/config/src/xcm-configs/kintsugi.ts @@ -23,7 +23,9 @@ export const kintsugiRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: kint, }, }, @@ -46,7 +48,10 @@ export const kintsugiRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: kint, }, }, diff --git a/packages/config/src/xcm-configs/kusama.ts b/packages/config/src/xcm-configs/kusama.ts index af98970d..3ce14e97 100644 --- a/packages/config/src/xcm-configs/kusama.ts +++ b/packages/config/src/xcm-configs/kusama.ts @@ -28,7 +28,9 @@ export const kusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ksm, }, }, diff --git a/packages/config/src/xcm-configs/kusamaAssetHub.ts b/packages/config/src/xcm-configs/kusamaAssetHub.ts index 88353cc6..8db6b234 100644 --- a/packages/config/src/xcm-configs/kusamaAssetHub.ts +++ b/packages/config/src/xcm-configs/kusamaAssetHub.ts @@ -32,7 +32,9 @@ export const kusamaAssetHubRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: rmrk, }, }, @@ -60,7 +62,9 @@ export const kusamaAssetHubRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, }, }, diff --git a/packages/config/src/xcm-configs/mangataKusama.ts b/packages/config/src/xcm-configs/mangataKusama.ts index ba379f8f..c4ccfbad 100644 --- a/packages/config/src/xcm-configs/mangataKusama.ts +++ b/packages/config/src/xcm-configs/mangataKusama.ts @@ -23,7 +23,9 @@ export const mangataKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: mgx, }, }, @@ -46,7 +48,9 @@ export const mangataKusamaRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.000008, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/mantaParachain.ts b/packages/config/src/xcm-configs/mantaParachain.ts index 3fb4b4f2..6b5ff889 100644 --- a/packages/config/src/xcm-configs/mantaParachain.ts +++ b/packages/config/src/xcm-configs/mantaParachain.ts @@ -24,7 +24,9 @@ export const mantaParachainRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: manta, }, }, @@ -48,7 +50,9 @@ export const mantaParachainRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/moonbaseAlpha.ts b/packages/config/src/xcm-configs/moonbaseAlpha.ts index 16ca63ce..d092fea6 100644 --- a/packages/config/src/xcm-configs/moonbaseAlpha.ts +++ b/packages/config/src/xcm-configs/moonbaseAlpha.ts @@ -131,23 +131,6 @@ export const moonbaseAlphaRoutes = new ChainRoutes({ }, contract: ContractBuilder().Xtokens().transferMultiCurrencies(), }, - // NOTE: Disabling because ws endpoint is not working - // new AssetConfig({ - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // contract: ContractBuilder().Xtokens().transfer(), - // destination: { - // chain: uniqueAlpha, - // fee:{ - // amount: 0, - // asset: auq, - // } - // }, - // fee: { - // asset: dev, - // balance: BalanceBuilder().substrate().system().account(), - // }, - // }), { source: { asset: ampe, diff --git a/packages/config/src/xcm-configs/moonbaseBeta.ts b/packages/config/src/xcm-configs/moonbaseBeta.ts index 98b21662..e0acf549 100644 --- a/packages/config/src/xcm-configs/moonbaseBeta.ts +++ b/packages/config/src/xcm-configs/moonbaseBeta.ts @@ -1,6 +1,7 @@ import { BalanceBuilder, ExtrinsicBuilder, + FeeBuilder, } from '@moonbeam-network/xcm-builder'; import { alan, betaDEV, dev, ftmwh, usdcwh } from '../assets'; import { moonbaseAlpha, moonbaseBeta } from '../chains'; @@ -26,7 +27,9 @@ export const moonbaseBetaRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -49,7 +52,9 @@ export const moonbaseBetaRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -72,7 +77,9 @@ export const moonbaseBetaRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -95,7 +102,9 @@ export const moonbaseBetaRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.002, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/neuroweb.ts b/packages/config/src/xcm-configs/neuroweb.ts index 9f54aa30..7df7ecc0 100644 --- a/packages/config/src/xcm-configs/neuroweb.ts +++ b/packages/config/src/xcm-configs/neuroweb.ts @@ -23,7 +23,9 @@ export const neurowebRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: neuro, }, }, diff --git a/packages/config/src/xcm-configs/nodle.ts b/packages/config/src/xcm-configs/nodle.ts index 0dd07a2b..08b2383d 100644 --- a/packages/config/src/xcm-configs/nodle.ts +++ b/packages/config/src/xcm-configs/nodle.ts @@ -23,7 +23,9 @@ export const nodleRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: nodl, }, }, diff --git a/packages/config/src/xcm-configs/originTrailAlphanet.ts b/packages/config/src/xcm-configs/originTrailAlphanet.ts index b8c4a9c3..e1347a3b 100644 --- a/packages/config/src/xcm-configs/originTrailAlphanet.ts +++ b/packages/config/src/xcm-configs/originTrailAlphanet.ts @@ -23,7 +23,9 @@ export const originTrailAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: otp, }, }, diff --git a/packages/config/src/xcm-configs/parallel.ts b/packages/config/src/xcm-configs/parallel.ts index f43c6847..b0d6e8a4 100644 --- a/packages/config/src/xcm-configs/parallel.ts +++ b/packages/config/src/xcm-configs/parallel.ts @@ -23,7 +23,9 @@ export const parallelRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: para, }, }, @@ -49,7 +51,9 @@ export const parallelRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/peaq.ts b/packages/config/src/xcm-configs/peaq.ts index c32527cd..184dc551 100644 --- a/packages/config/src/xcm-configs/peaq.ts +++ b/packages/config/src/xcm-configs/peaq.ts @@ -24,7 +24,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: peaq, }, }, @@ -44,7 +46,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -68,7 +72,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -92,7 +98,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -116,7 +124,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -140,7 +150,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -164,7 +176,9 @@ export const peaqRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/peaqAlphanet.ts b/packages/config/src/xcm-configs/peaqAlphanet.ts index 16adf200..c59ea39a 100644 --- a/packages/config/src/xcm-configs/peaqAlphanet.ts +++ b/packages/config/src/xcm-configs/peaqAlphanet.ts @@ -24,7 +24,9 @@ export const peaqAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: agng, }, }, @@ -44,7 +46,9 @@ export const peaqAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -68,7 +72,9 @@ export const peaqAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/peaqEvm.ts b/packages/config/src/xcm-configs/peaqEvm.ts index b1099291..25f022ee 100644 --- a/packages/config/src/xcm-configs/peaqEvm.ts +++ b/packages/config/src/xcm-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'; @@ -28,7 +29,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -52,7 +55,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -76,7 +81,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -100,7 +107,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -124,7 +133,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -148,7 +159,9 @@ export const peaqEvmRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/peaqEvmAlphanet.ts b/packages/config/src/xcm-configs/peaqEvmAlphanet.ts index b4dc0cb5..0ee91661 100644 --- a/packages/config/src/xcm-configs/peaqEvmAlphanet.ts +++ b/packages/config/src/xcm-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'; @@ -28,7 +29,9 @@ export const peaqEvmAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, @@ -52,7 +55,9 @@ export const peaqEvmAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/pendulum.ts b/packages/config/src/xcm-configs/pendulum.ts index 93742002..19f91395 100644 --- a/packages/config/src/xcm-configs/pendulum.ts +++ b/packages/config/src/xcm-configs/pendulum.ts @@ -23,7 +23,9 @@ export const pendulumRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pen, }, }, @@ -46,7 +48,9 @@ export const pendulumRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -69,7 +73,9 @@ export const pendulumRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/pendulumAlphanet.ts b/packages/config/src/xcm-configs/pendulumAlphanet.ts index fb3d50a9..9600a017 100644 --- a/packages/config/src/xcm-configs/pendulumAlphanet.ts +++ b/packages/config/src/xcm-configs/pendulumAlphanet.ts @@ -23,7 +23,9 @@ export const pendulumAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ampe, }, }, @@ -46,7 +48,9 @@ export const pendulumAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/phala.ts b/packages/config/src/xcm-configs/phala.ts index 98c79132..a477630d 100644 --- a/packages/config/src/xcm-configs/phala.ts +++ b/packages/config/src/xcm-configs/phala.ts @@ -23,7 +23,9 @@ export const phalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pha, }, }, @@ -46,7 +48,9 @@ export const phalaRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/config/src/xcm-configs/picasso.ts b/packages/config/src/xcm-configs/picasso.ts index b4161eaf..c2774b85 100644 --- a/packages/config/src/xcm-configs/picasso.ts +++ b/packages/config/src/xcm-configs/picasso.ts @@ -23,7 +23,9 @@ export const picassoRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pica, }, }, @@ -46,7 +48,9 @@ export const picassoRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/picassoAlphanet.ts b/packages/config/src/xcm-configs/picassoAlphanet.ts index d5a182d1..d9b17d4f 100644 --- a/packages/config/src/xcm-configs/picassoAlphanet.ts +++ b/packages/config/src/xcm-configs/picassoAlphanet.ts @@ -23,7 +23,9 @@ export const picassoAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pica, }, }, @@ -46,7 +48,9 @@ export const picassoAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: pica, }, }, @@ -69,7 +73,9 @@ export const picassoAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/polkadot.ts b/packages/config/src/xcm-configs/polkadot.ts index 8706112f..861500ec 100644 --- a/packages/config/src/xcm-configs/polkadot.ts +++ b/packages/config/src/xcm-configs/polkadot.ts @@ -28,7 +28,9 @@ export const polkadotRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: dot, }, }, diff --git a/packages/config/src/xcm-configs/polkadotAssetHub.ts b/packages/config/src/xcm-configs/polkadotAssetHub.ts index 38f6bd68..83da012f 100644 --- a/packages/config/src/xcm-configs/polkadotAssetHub.ts +++ b/packages/config/src/xcm-configs/polkadotAssetHub.ts @@ -32,7 +32,9 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, }, }, @@ -60,7 +62,9 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.03, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdc, }, }, @@ -88,7 +92,10 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: usdt, }, }, @@ -116,7 +123,10 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: usdt, }, }, @@ -144,7 +154,9 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.03, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: usdt, }, }, @@ -172,7 +184,10 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: usdt, }, }, @@ -200,7 +215,10 @@ export const polkadotAssetHubRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: 0.03, + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeFeeAsset: true, + }), asset: usdt, }, }, diff --git a/packages/config/src/xcm-configs/robonomics.ts b/packages/config/src/xcm-configs/robonomics.ts index 315c71ba..b3d9f0f7 100644 --- a/packages/config/src/xcm-configs/robonomics.ts +++ b/packages/config/src/xcm-configs/robonomics.ts @@ -23,7 +23,9 @@ export const robonomicsRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: xrt, }, }, diff --git a/packages/config/src/xcm-configs/shiden.ts b/packages/config/src/xcm-configs/shiden.ts index 9c122e17..5c66df57 100644 --- a/packages/config/src/xcm-configs/shiden.ts +++ b/packages/config/src/xcm-configs/shiden.ts @@ -23,7 +23,9 @@ export const shidenRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: sdn, }, }, @@ -49,7 +51,9 @@ export const shidenRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.0001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/subsocial.ts b/packages/config/src/xcm-configs/subsocial.ts index 0e32140d..622932ad 100644 --- a/packages/config/src/xcm-configs/subsocial.ts +++ b/packages/config/src/xcm-configs/subsocial.ts @@ -23,7 +23,9 @@ export const subsocialRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: sub, }, }, diff --git a/packages/config/src/xcm-configs/tinkernet.ts b/packages/config/src/xcm-configs/tinkernet.ts index 327708f5..2951f88a 100644 --- a/packages/config/src/xcm-configs/tinkernet.ts +++ b/packages/config/src/xcm-configs/tinkernet.ts @@ -23,7 +23,9 @@ export const tinkernetRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tnkr, }, }, diff --git a/packages/config/src/xcm-configs/turing.ts b/packages/config/src/xcm-configs/turing.ts index 98f43c5a..f1175bc3 100644 --- a/packages/config/src/xcm-configs/turing.ts +++ b/packages/config/src/xcm-configs/turing.ts @@ -23,7 +23,9 @@ export const turingRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tur, }, }, @@ -49,7 +51,9 @@ export const turingRoutes = new ChainRoutes({ chain: moonriver, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.00001, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: movr, }, }, diff --git a/packages/config/src/xcm-configs/turingAlphanet.ts b/packages/config/src/xcm-configs/turingAlphanet.ts index c70091ae..e33ff14f 100644 --- a/packages/config/src/xcm-configs/turingAlphanet.ts +++ b/packages/config/src/xcm-configs/turingAlphanet.ts @@ -23,7 +23,9 @@ export const turingAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: tur, }, }, @@ -49,7 +51,9 @@ export const turingAlphanetRoutes = new ChainRoutes({ chain: moonbaseAlpha, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.04, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: dev, }, }, diff --git a/packages/config/src/xcm-configs/uniqueAlpha.ts b/packages/config/src/xcm-configs/uniqueAlpha.ts deleted file mode 100644 index 497f59b2..00000000 --- a/packages/config/src/xcm-configs/uniqueAlpha.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { uniqueAlpha } from '../chains'; -import { ChainRoutes } from '../types/ChainRoutes'; - -// NOTE: Disabling because ws endpoint is not working -// The config might be invalid -export const uniqueAlphaRoutes = new ChainRoutes({ - chain: uniqueAlpha, - routes: [ - // new AssetConfig({ - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // destination: { - // chain: moonbaseAlpha, - // fee:{ - // amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), - // asset: auq, - // balance: BalanceBuilder().substrate().assets().account(), - // } - // }, - // extrinsic: ExtrinsicBuilder().xTokens().transfer(), - // }), - ], -}); diff --git a/packages/config/src/xcm-configs/zeitgeist.ts b/packages/config/src/xcm-configs/zeitgeist.ts index 588e0aaf..dd7c4265 100644 --- a/packages/config/src/xcm-configs/zeitgeist.ts +++ b/packages/config/src/xcm-configs/zeitgeist.ts @@ -23,7 +23,9 @@ export const zeitgeistRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().assets().account(), fee: { - amount: FeeBuilder().assetManager().assetTypeUnitsPerSecond(), + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: false }), asset: ztg, }, }, @@ -46,7 +48,9 @@ export const zeitgeistRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().evm().erc20(), fee: { - amount: 0.08, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, @@ -65,7 +69,9 @@ export const zeitgeistRoutes = new ChainRoutes({ chain: moonbeam, balance: BalanceBuilder().substrate().system().account(), fee: { - amount: 0.01, + amount: FeeBuilder() + .xcmPaymentApi() + .xcmPaymentFee({ isAssetReserveChain: true }), asset: glmr, }, }, diff --git a/packages/mrl/src/getTransferData/getMoonChainData.ts b/packages/mrl/src/getTransferData/getMoonChainData.ts index 24d2b6cb..529258a8 100644 --- a/packages/mrl/src/getTransferData/getMoonChainData.ts +++ b/packages/mrl/src/getTransferData/getMoonChainData.ts @@ -37,9 +37,11 @@ export async function getMoonChainData({ } const fee = await getDestinationFee({ - asset, + address: sourceAddress, // TODO not correct + asset: route.destination.fee.asset, chain: moonChain, fee: route.mrl.moonChain.fee.amount, + transferAsset: route.source.asset, }); let address = sourceAddress; 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 340df121..6794b3bc 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", diff --git a/packages/sdk/src/getTransferData/getDestinationData.ts b/packages/sdk/src/getTransferData/getDestinationData.ts index c64c615b..8dbba997 100644 --- a/packages/sdk/src/getTransferData/getDestinationData.ts +++ b/packages/sdk/src/getTransferData/getDestinationData.ts @@ -30,9 +30,11 @@ export async function getDestinationData({ chain: destination, }); const fee = await getDestinationFee({ + address: destinationAddress, asset: route.destination.fee.asset, - chain: destination, + destination, fee: route.destination.fee.amount, + transferAsset: route.source.asset, }); const existentialDeposit = await getExistentialDeposit(destination); diff --git a/packages/sdk/src/getTransferData/getTransferData.utils.ts b/packages/sdk/src/getTransferData/getTransferData.utils.ts index e1de03f8..ee56e94b 100644 --- a/packages/sdk/src/getTransferData/getTransferData.utils.ts +++ b/packages/sdk/src/getTransferData/getTransferData.utils.ts @@ -155,17 +155,21 @@ export function getMax({ } export interface GetDestinationFeeParams { + address: string; asset: Asset; - chain: AnyChain; + destination: AnyChain; fee: number | FeeConfigBuilder; + transferAsset: Asset; } export async function getDestinationFee({ + address, asset, - chain, + destination, fee, + transferAsset, }: GetDestinationFeeParams): Promise { - const zero = AssetAmount.fromChainAsset(chain.getChainAsset(asset), { + const zero = AssetAmount.fromChainAsset(destination.getChainAsset(asset), { amount: 0n, }); @@ -175,11 +179,14 @@ export async function getDestinationFee({ }); } - if (EvmParachain.isAnyParachain(chain)) { - const polkadot = await PolkadotService.create(chain); + if (EvmParachain.isAnyParachain(destination)) { + const polkadot = await PolkadotService.create(destination); const cfg = (fee as FeeConfigBuilder).build({ + address, api: polkadot.api, - asset: zero.getAssetId(), + asset: destination.getChainAsset(transferAsset), + feeAsset: destination.getChainAsset(asset), + destination, }); return zero.copyWith({ diff --git a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap index f7b9e1cd..b4f35a1c 100644 --- a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap +++ b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap @@ -614,7 +614,9 @@ exports[`sdk > getParachainBalances > on 'Moonbeam' for address: '0x4E82143Af671 "address": "0xfFFfFFFF6C57e17D210DF507c82807149fFd70B2", "amount": 0n, "decimals": 18, - "ids": undefined, + "ids": { + "id": "144012926827374458669278577633504620722", + }, "key": "fil", "min": undefined, "originSymbol": "FIL", 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 face0f2a..c10e0996 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", 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 febd2d9c..1e955efa 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';