From 2a7ed04887ee41e5a6c010f213265028a953a769 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:31:49 +0200 Subject: [PATCH 1/9] 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 --- .changeset/young-mice-shout.md | 8 + mkdocs/docs/contribute.md | 10 +- mkdocs/docs/reference/interfaces.md | 14 +- .../builder/src/fee/FeeBuilder.interfaces.ts | 20 +- packages/builder/src/fee/FeeBuilder.ts | 68 +++-- packages/builder/src/fee/FeeBuilder.utils.ts | 244 ++++++++++++++++++ packages/config/src/chains.ts | 4 +- packages/config/src/configs/acala.ts | 16 +- .../config/src/configs/alphanetAssetHub.ts | 4 +- packages/config/src/configs/alphanetRelay.ts | 4 +- packages/config/src/configs/astar.ts | 8 +- packages/config/src/configs/bifrostKusama.ts | 20 +- .../config/src/configs/bifrostPolkadot.ts | 36 ++- packages/config/src/configs/calamari.ts | 8 +- packages/config/src/configs/centrifuge.ts | 4 +- packages/config/src/configs/crustShadow.ts | 8 +- packages/config/src/configs/darwinia.ts | 4 +- packages/config/src/configs/darwiniaCrab.ts | 4 +- packages/config/src/configs/hydration.ts | 28 +- .../config/src/configs/hydrationAlphanet.ts | 16 +- packages/config/src/configs/index.ts | 2 - packages/config/src/configs/integritee.ts | 4 +- packages/config/src/configs/interlay.ts | 13 +- packages/config/src/configs/karura.ts | 12 +- packages/config/src/configs/khala.ts | 8 +- packages/config/src/configs/kintsugi.ts | 9 +- packages/config/src/configs/kusama.ts | 4 +- packages/config/src/configs/kusamaAssetHub.ts | 8 +- packages/config/src/configs/mangataKusama.ts | 8 +- packages/config/src/configs/mantaParachain.ts | 8 +- packages/config/src/configs/moonbaseAlpha.ts | 15 -- packages/config/src/configs/moonbaseBeta.ts | 41 +-- packages/config/src/configs/neuroweb.ts | 4 +- packages/config/src/configs/nodle.ts | 4 +- .../config/src/configs/originTrailAlphanet.ts | 4 +- packages/config/src/configs/parallel.ts | 8 +- packages/config/src/configs/peaq.ts | 28 +- packages/config/src/configs/peaqAlphanet.ts | 12 +- packages/config/src/configs/peaqEvm.ts | 25 +- .../config/src/configs/peaqEvmAlphanet.ts | 9 +- packages/config/src/configs/pendulum.ts | 12 +- .../config/src/configs/pendulumAlphanet.ts | 8 +- packages/config/src/configs/phala.ts | 8 +- packages/config/src/configs/picasso.ts | 8 +- .../config/src/configs/picassoAlphanet.ts | 12 +- packages/config/src/configs/polkadot.ts | 4 +- .../config/src/configs/polkadotAssetHub.ts | 28 +- packages/config/src/configs/robonomics.ts | 4 +- packages/config/src/configs/shiden.ts | 8 +- packages/config/src/configs/subsocial.ts | 4 +- packages/config/src/configs/tinkernet.ts | 4 +- packages/config/src/configs/turing.ts | 8 +- packages/config/src/configs/turingAlphanet.ts | 8 +- packages/config/src/configs/uniqueAlpha.ts | 20 -- packages/config/src/configs/zeitgeist.ts | 12 +- .../src/getTransferData/getDestinationData.ts | 6 +- .../acceptance/__snapshots__/sdk.test.ts.snap | 14 - .../types/src/chain/parachain/Parachain.ts | 5 + packages/utils/src/format/address.ts | 3 + packages/utils/src/format/index.ts | 1 + 60 files changed, 700 insertions(+), 231 deletions(-) create mode 100644 .changeset/young-mice-shout.md create mode 100644 packages/builder/src/fee/FeeBuilder.utils.ts delete mode 100644 packages/config/src/configs/uniqueAlpha.ts create mode 100644 packages/utils/src/format/address.ts diff --git a/.changeset/young-mice-shout.md b/.changeset/young-mice-shout.md new file mode 100644 index 00000000..110e61b5 --- /dev/null +++ b/.changeset/young-mice-shout.md @@ -0,0 +1,8 @@ +--- +'@moonbeam-network/xcm-builder': minor +'@moonbeam-network/xcm-config': minor +'@moonbeam-network/xcm-types': minor +'@moonbeam-network/xcm-sdk': minor +--- + +Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha 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/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/src/chains.ts b/packages/config/src/chains.ts index 9042a4f1..f1abd191 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -411,7 +411,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({ @@ -939,7 +939,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..f1b5a6aa 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,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(), }, @@ -78,7 +84,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(), }, @@ -98,7 +106,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 +128,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(), }, @@ -138,7 +150,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(), }, 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/src/getTransferData/getDestinationData.ts b/packages/sdk/src/getTransferData/getDestinationData.ts index fb53b65d..4d8967df 100644 --- a/packages/sdk/src/getTransferData/getDestinationData.ts +++ b/packages/sdk/src/getTransferData/getDestinationData.ts @@ -67,6 +67,7 @@ export interface GetFeeParams { } export async function getFee({ + address, config, polkadot, }: GetFeeParams): Promise { @@ -85,8 +86,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/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap index 3b630a5a..9315e298 100644 --- a/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap +++ b/packages/sdk/tests/acceptance/__snapshots__/sdk.test.ts.snap @@ -296,20 +296,6 @@ exports[`sdk > getParachainBalances > on 'Moonbase Alpha' for address: '0x4E8214 exports[`sdk > getParachainBalances > on 'Moonbase Beta' for address: '0x4E82143Af671Cc8201Bc7efCBbCED3A69e8…' > should get expected balances 1`] = ` [ - a { - "amount": 100000000000000000n, - "decimals": 18, - "key": "ftmwh", - "originSymbol": "FTM.wh", - "symbol": "FTM.wh", - }, - a { - "amount": 0n, - "decimals": 6, - "key": "usdcwh", - "originSymbol": "USDC.Wh", - "symbol": "USDC.Wh", - }, a { "amount": 1100000000000000000n, "decimals": 18, diff --git a/packages/types/src/chain/parachain/Parachain.ts b/packages/types/src/chain/parachain/Parachain.ts index a9ce7b1b..e7e54577 100644 --- a/packages/types/src/chain/parachain/Parachain.ts +++ b/packages/types/src/chain/parachain/Parachain.ts @@ -71,6 +71,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/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'; From 2d805511875ba787ef3b63cd6e6901f5cde59b5d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:34:29 +0200 Subject: [PATCH 2/9] Version Packages (#352) Co-authored-by: github-actions[bot] --- .changeset/young-mice-shout.md | 8 -------- examples/sdk-simple/package.json | 4 ++-- package-lock.json | 24 ++++++++++++------------ packages/builder/CHANGELOG.md | 11 +++++++++++ packages/builder/package.json | 4 ++-- packages/config/CHANGELOG.md | 12 ++++++++++++ packages/config/package.json | 6 +++--- packages/sdk/CHANGELOG.md | 13 +++++++++++++ packages/sdk/package.json | 8 ++++---- packages/types/CHANGELOG.md | 6 ++++++ packages/types/package.json | 2 +- 11 files changed, 66 insertions(+), 32 deletions(-) delete mode 100644 .changeset/young-mice-shout.md diff --git a/.changeset/young-mice-shout.md b/.changeset/young-mice-shout.md deleted file mode 100644 index 110e61b5..00000000 --- a/.changeset/young-mice-shout.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@moonbeam-network/xcm-builder': minor -'@moonbeam-network/xcm-config': minor -'@moonbeam-network/xcm-types': minor -'@moonbeam-network/xcm-sdk': minor ---- - -Implement XcmPaymentApi to calculate fees for routes going to Moonbeam / Moonriver / Moonbase-Alpha diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 9184d47f..732e09dd 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,8 +12,8 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-sdk": "2.5.14", + "@moonbeam-network/xcm-config": "2.6.0", + "@moonbeam-network/xcm-sdk": "2.6.0", "@moonbeam-network/xcm-utils": "2.1.7" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index 67505536..95892cda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,8 +50,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.5.12", - "@moonbeam-network/xcm-sdk": "2.5.14", + "@moonbeam-network/xcm-config": "2.6.0", + "@moonbeam-network/xcm-sdk": "2.6.0", "@moonbeam-network/xcm-utils": "2.1.7" }, "devDependencies": { @@ -19594,10 +19594,10 @@ }, "packages/builder": { "name": "@moonbeam-network/xcm-builder", - "version": "2.4.7", + "version": "2.5.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-types": "2.3.4", + "@moonbeam-network/xcm-types": "2.4.0", "@moonbeam-network/xcm-utils": "2.1.7", "big.js": "^6.2.1" }, @@ -19611,11 +19611,11 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "2.5.12", + "version": "2.6.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-builder": "2.4.7", - "@moonbeam-network/xcm-types": "2.3.4" + "@moonbeam-network/xcm-builder": "2.5.0", + "@moonbeam-network/xcm-types": "2.4.0" }, "peerDependencies": { "@polkadot/types": "^12.4.2", @@ -19625,12 +19625,12 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "2.5.14", + "version": "2.6.0", "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-builder": "2.5.0", + "@moonbeam-network/xcm-config": "2.6.0", + "@moonbeam-network/xcm-types": "2.4.0", "@moonbeam-network/xcm-utils": "2.1.7", "big.js": "^6.2.1" }, @@ -19645,7 +19645,7 @@ }, "packages/types": { "name": "@moonbeam-network/xcm-types", - "version": "2.3.4", + "version": "2.4.0", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-utils": "2.1.7", diff --git a/packages/builder/CHANGELOG.md b/packages/builder/CHANGELOG.md index ae6a9311..550a48b2 100644 --- a/packages/builder/CHANGELOG.md +++ b/packages/builder/CHANGELOG.md @@ -1,5 +1,16 @@ # @moonbeam-network/xcm-builder +## 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..cee7fc34 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.0", "description": "Moonbeam XCM builder", "scripts": { "build": "tsup", @@ -49,7 +49,7 @@ "types": "./build/index.d.ts", "main": "./build/index.cjs", "dependencies": { - "@moonbeam-network/xcm-types": "2.3.4", + "@moonbeam-network/xcm-types": "2.4.0", "@moonbeam-network/xcm-utils": "2.1.7", "big.js": "^6.2.1" }, diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index 63c1e6ab..9a0d46ab 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,17 @@ # @moonbeam-network/xcm-config +## 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..bf3bb216 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.0", "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.0", + "@moonbeam-network/xcm-types": "2.4.0" }, "peerDependencies": { "@polkadot/types": "^12.4.2", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 5eb0154d..de4df9d6 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,18 @@ # @moonbeam-network/xcm-sdk +## 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..60dbd61f 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.0", "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,9 +51,9 @@ "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-builder": "2.5.0", + "@moonbeam-network/xcm-config": "2.6.0", + "@moonbeam-network/xcm-types": "2.4.0", "@moonbeam-network/xcm-utils": "2.1.7", "big.js": "^6.2.1" }, diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d1b8d0af..7339a40d 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,5 +1,11 @@ # @moonbeam-network/xcm-types +## 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..e0af99bf 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.0", "description": "Moonbeam XCM Types", "scripts": { "build": "tsup", From 4be5659c05fe2487dd6f440c833fdf7cdc369917 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:54:06 +0200 Subject: [PATCH 3/9] add changeset for xcm-utils (#353) --- .changeset/clean-papayas-grow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clean-papayas-grow.md diff --git a/.changeset/clean-papayas-grow.md b/.changeset/clean-papayas-grow.md new file mode 100644 index 00000000..8c5c6d12 --- /dev/null +++ b/.changeset/clean-papayas-grow.md @@ -0,0 +1,5 @@ +--- +'@moonbeam-network/xcm-utils': minor +--- + +Release minor version for xcm-utils with isHexString From 08b60ba22c8b2922e6c660e19410e6b8ab08ff04 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:55:28 +0200 Subject: [PATCH 4/9] Version Packages (#355) Co-authored-by: github-actions[bot] --- .changeset/clean-papayas-grow.md | 5 ----- examples/sdk-simple/package.json | 6 +++--- package-lock.json | 34 ++++++++++++++++---------------- packages/builder/CHANGELOG.md | 8 ++++++++ packages/builder/package.json | 6 +++--- packages/config/CHANGELOG.md | 8 ++++++++ packages/config/package.json | 6 +++--- packages/sdk/CHANGELOG.md | 10 ++++++++++ packages/sdk/package.json | 10 +++++----- packages/types/CHANGELOG.md | 7 +++++++ packages/types/package.json | 4 ++-- packages/utils/CHANGELOG.md | 6 ++++++ packages/utils/package.json | 2 +- 13 files changed, 73 insertions(+), 39 deletions(-) delete mode 100644 .changeset/clean-papayas-grow.md diff --git a/.changeset/clean-papayas-grow.md b/.changeset/clean-papayas-grow.md deleted file mode 100644 index 8c5c6d12..00000000 --- a/.changeset/clean-papayas-grow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@moonbeam-network/xcm-utils': minor ---- - -Release minor version for xcm-utils with isHexString diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 732e09dd..8d288ce9 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.6.0", - "@moonbeam-network/xcm-sdk": "2.6.0", - "@moonbeam-network/xcm-utils": "2.1.7" + "@moonbeam-network/xcm-config": "2.6.1", + "@moonbeam-network/xcm-sdk": "2.6.1", + "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { "bun": "^1.1.25" diff --git a/package-lock.json b/package-lock.json index 95892cda..598885c7 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.6.0", - "@moonbeam-network/xcm-sdk": "2.6.0", - "@moonbeam-network/xcm-utils": "2.1.7" + "@moonbeam-network/xcm-config": "2.6.1", + "@moonbeam-network/xcm-sdk": "2.6.1", + "@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.5.0", + "version": "2.5.1", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-types": "2.4.0", - "@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.6.0", + "version": "2.6.1", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-builder": "2.5.0", - "@moonbeam-network/xcm-types": "2.4.0" + "@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.6.0", + "version": "2.6.1", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-builder": "2.5.0", - "@moonbeam-network/xcm-config": "2.6.0", - "@moonbeam-network/xcm-types": "2.4.0", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-config": "2.6.1", + "@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.4.0", + "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 550a48b2..79cd5891 100644 --- a/packages/builder/CHANGELOG.md +++ b/packages/builder/CHANGELOG.md @@ -1,5 +1,13 @@ # @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 diff --git a/packages/builder/package.json b/packages/builder/package.json index cee7fc34..7746065a 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-builder", - "version": "2.5.0", + "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.4.0", - "@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/config/CHANGELOG.md b/packages/config/CHANGELOG.md index 9a0d46ab..a5324562 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,13 @@ # @moonbeam-network/xcm-config +## 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 diff --git a/packages/config/package.json b/packages/config/package.json index bf3bb216..97427877 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "2.6.0", + "version": "2.6.1", "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.5.0", - "@moonbeam-network/xcm-types": "2.4.0" + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-types": "2.4.1" }, "peerDependencies": { "@polkadot/types": "^12.4.2", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index de4df9d6..f5080c02 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,15 @@ # @moonbeam-network/xcm-sdk +## 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 diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 60dbd61f..0747bbac 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "2.6.0", + "version": "2.6.1", "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.5.0", - "@moonbeam-network/xcm-config": "2.6.0", - "@moonbeam-network/xcm-types": "2.4.0", - "@moonbeam-network/xcm-utils": "2.1.7", + "@moonbeam-network/xcm-builder": "2.5.1", + "@moonbeam-network/xcm-config": "2.6.1", + "@moonbeam-network/xcm-types": "2.4.1", + "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 7339a40d..ddcb6d5b 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,5 +1,12 @@ # @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 diff --git a/packages/types/package.json b/packages/types/package.json index e0af99bf..763f7a9a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-types", - "version": "2.4.0", + "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/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", From 3f22072c837a55e9109ad042efa555a46802e6e6 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:07:58 +0200 Subject: [PATCH 5/9] fix TEER configuration in Integritee (#356) --- .changeset/ninety-pumas-sip.md | 5 +++++ packages/config/src/chains.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/ninety-pumas-sip.md diff --git a/.changeset/ninety-pumas-sip.md b/.changeset/ninety-pumas-sip.md new file mode 100644 index 00000000..2aade97f --- /dev/null +++ b/.changeset/ninety-pumas-sip.md @@ -0,0 +1,5 @@ +--- +'@moonbeam-network/xcm-config': patch +--- + +Fix TEER configuration in Integritee diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index f1abd191..179f3d1b 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -527,6 +527,13 @@ export const interlay = new Parachain({ }); export const integritee = new Parachain({ + assetsData: [ + { + asset: teer, + id: teer.originSymbol, + metadataId: 0, + }, + ], ecosystem: Ecosystem.Kusama, genesisHash: '0xcdedc8eadbfa209d3f207bba541e57c3c58a667b05a2e1d1e86353c9000758da', From da6ff5f4fbdf3689ce2c94396f211ca6d4400e47 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:28:45 +0200 Subject: [PATCH 6/9] Version Packages (#357) Co-authored-by: github-actions[bot] --- .changeset/ninety-pumas-sip.md | 5 ----- examples/sdk-simple/package.json | 4 ++-- package-lock.json | 10 +++++----- packages/config/CHANGELOG.md | 6 ++++++ packages/config/package.json | 2 +- packages/sdk/CHANGELOG.md | 7 +++++++ packages/sdk/package.json | 4 ++-- 7 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 .changeset/ninety-pumas-sip.md diff --git a/.changeset/ninety-pumas-sip.md b/.changeset/ninety-pumas-sip.md deleted file mode 100644 index 2aade97f..00000000 --- a/.changeset/ninety-pumas-sip.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@moonbeam-network/xcm-config': patch ---- - -Fix TEER configuration in Integritee diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 8d288ce9..71e1cbf8 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,8 +12,8 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.6.1", - "@moonbeam-network/xcm-sdk": "2.6.1", + "@moonbeam-network/xcm-config": "2.6.2", + "@moonbeam-network/xcm-sdk": "2.6.2", "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index 598885c7..ee1d491e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,8 +50,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.6.1", - "@moonbeam-network/xcm-sdk": "2.6.1", + "@moonbeam-network/xcm-config": "2.6.2", + "@moonbeam-network/xcm-sdk": "2.6.2", "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { @@ -19611,7 +19611,7 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "2.6.1", + "version": "2.6.2", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", @@ -19625,11 +19625,11 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "2.6.1", + "version": "2.6.2", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", - "@moonbeam-network/xcm-config": "2.6.1", + "@moonbeam-network/xcm-config": "2.6.2", "@moonbeam-network/xcm-types": "2.4.1", "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index a5324562..e6d6362e 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,11 @@ # @moonbeam-network/xcm-config +## 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 diff --git a/packages/config/package.json b/packages/config/package.json index 97427877..1586a226 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "2.6.1", + "version": "2.6.2", "description": "All necessary configuration to transfer assets from Moonbeam, Moonriver, Moonbase to other parachains and back", "scripts": { "build": "tsup", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index f5080c02..1a1d3581 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,12 @@ # @moonbeam-network/xcm-sdk +## 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 diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 0747bbac..769b72a5 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "2.6.1", + "version": "2.6.2", "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", @@ -52,7 +52,7 @@ "main": "./build/index.cjs", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", - "@moonbeam-network/xcm-config": "2.6.1", + "@moonbeam-network/xcm-config": "2.6.2", "@moonbeam-network/xcm-types": "2.4.1", "@moonbeam-network/xcm-utils": "2.2.0", "big.js": "^6.2.1" From 5d308c3455126b5dfedb93c38a0afb18344a183e Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:33:16 +0200 Subject: [PATCH 7/9] Fix Asset Hub memecoings asset ordering in fee calculation (#359) --- .changeset/serious-ants-shout.md | 5 ++++ .../config/src/configs/polkadotAssetHub.ts | 28 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 .changeset/serious-ants-shout.md diff --git a/.changeset/serious-ants-shout.md b/.changeset/serious-ants-shout.md new file mode 100644 index 00000000..4670249b --- /dev/null +++ b/.changeset/serious-ants-shout.md @@ -0,0 +1,5 @@ +--- +'@moonbeam-network/xcm-config': patch +--- + +Fix Asset Hub memecoins asset ordering in fee calculation diff --git a/packages/config/src/configs/polkadotAssetHub.ts b/packages/config/src/configs/polkadotAssetHub.ts index f1b5a6aa..17f281ba 100644 --- a/packages/config/src/configs/polkadotAssetHub.ts +++ b/packages/config/src/configs/polkadotAssetHub.ts @@ -62,9 +62,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder() - .xcmPaymentApi() - .xcmPaymentFee({ isAssetReserveChain: false }), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -84,9 +85,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder() - .xcmPaymentApi() - .xcmPaymentFee({ isAssetReserveChain: false }), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -128,9 +130,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder() - .xcmPaymentApi() - .xcmPaymentFee({ isAssetReserveChain: false }), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, @@ -150,9 +153,10 @@ export const polkadotAssetHubConfig = new ChainConfig({ balance: BalanceBuilder().substrate().assets().account(), destination: moonbeam, destinationFee: { - amount: FeeBuilder() - .xcmPaymentApi() - .xcmPaymentFee({ isAssetReserveChain: false }), + amount: FeeBuilder().xcmPaymentApi().xcmPaymentFee({ + isAssetReserveChain: false, + shouldTransferAssetPrecedeAsset: true, + }), asset: usdt, balance: BalanceBuilder().substrate().assets().account(), }, From 242c274182475b189effb5482506c4af734c0e52 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:36:58 +0200 Subject: [PATCH 8/9] Version Packages (#360) Co-authored-by: github-actions[bot] --- .changeset/serious-ants-shout.md | 5 ----- examples/sdk-simple/package.json | 4 ++-- package-lock.json | 10 +++++----- packages/config/CHANGELOG.md | 6 ++++++ packages/config/package.json | 2 +- packages/sdk/CHANGELOG.md | 7 +++++++ packages/sdk/package.json | 4 ++-- 7 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 .changeset/serious-ants-shout.md diff --git a/.changeset/serious-ants-shout.md b/.changeset/serious-ants-shout.md deleted file mode 100644 index 4670249b..00000000 --- a/.changeset/serious-ants-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@moonbeam-network/xcm-config': patch ---- - -Fix Asset Hub memecoins asset ordering in fee calculation diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 71e1cbf8..e2505945 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,8 +12,8 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.6.2", - "@moonbeam-network/xcm-sdk": "2.6.2", + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-sdk": "2.6.3", "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index ee1d491e..f9b0c34c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,8 +50,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "2.6.2", - "@moonbeam-network/xcm-sdk": "2.6.2", + "@moonbeam-network/xcm-config": "2.6.3", + "@moonbeam-network/xcm-sdk": "2.6.3", "@moonbeam-network/xcm-utils": "2.2.0" }, "devDependencies": { @@ -19611,7 +19611,7 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "2.6.2", + "version": "2.6.3", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", @@ -19625,11 +19625,11 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "2.6.2", + "version": "2.6.3", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", - "@moonbeam-network/xcm-config": "2.6.2", + "@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" diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index e6d6362e..9772ed0f 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,11 @@ # @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 diff --git a/packages/config/package.json b/packages/config/package.json index 1586a226..2210fafc 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "2.6.2", + "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/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 1a1d3581..8474e34d 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,12 @@ # @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 diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 769b72a5..0fa62f2b 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "2.6.2", + "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", @@ -52,7 +52,7 @@ "main": "./build/index.cjs", "dependencies": { "@moonbeam-network/xcm-builder": "2.5.1", - "@moonbeam-network/xcm-config": "2.6.2", + "@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" 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 9/9] 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';