From 6b69eab6f7f7e0449ad33b25829f141c827ee566 Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Mon, 23 Sep 2024 13:54:39 +0200 Subject: [PATCH] remove assetTypeUnitsPerSecond function since it is not used now --- mkdocs/docs/reference/interfaces.md | 14 +++++++--- packages/builder/src/fee/FeeBuilder.ts | 27 ------------------ packages/config/src/configs/index.ts | 2 -- packages/config/src/configs/moonbaseAlpha.ts | 15 ---------- packages/config/src/configs/neuroweb.ts | 4 ++- packages/config/src/configs/nodle.ts | 4 ++- packages/config/src/configs/parallel.ts | 8 ++++-- packages/config/src/configs/peaq.ts | 28 ++++++++++++++----- packages/config/src/configs/peaqEvm.ts | 25 +++++++++++++---- packages/config/src/configs/pendulum.ts | 12 ++++++-- packages/config/src/configs/phala.ts | 8 ++++-- .../config/src/configs/polkadotAssetHub.ts | 28 ++++++++++++++----- packages/config/src/configs/subsocial.ts | 4 ++- packages/config/src/configs/uniqueAlpha.ts | 20 ------------- packages/config/src/configs/zeitgeist.ts | 12 ++++++-- 15 files changed, 110 insertions(+), 101 deletions(-) delete mode 100644 packages/config/src/configs/uniqueAlpha.ts 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.ts b/packages/builder/src/fee/FeeBuilder.ts index 731afce2..e2ead26b 100644 --- a/packages/builder/src/fee/FeeBuilder.ts +++ b/packages/builder/src/fee/FeeBuilder.ts @@ -1,11 +1,9 @@ /* 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, XcmPaymentFeeProps } from './FeeBuilder.interfaces'; import { - getAssetIdType, getBuyExecutionInstruction, getClearOriginInstruction, getDepositAssetInstruction, @@ -18,34 +16,9 @@ import { export function FeeBuilder() { return { - assetManager, xcmPaymentApi, }; } -// TODO remove after it's unused -function assetManager() { - return { - assetTypeUnitsPerSecond: (weight = 1_000_000_000): FeeConfigBuilder => ({ - build: ({ api, asset }) => - new SubstrateCallConfig({ - api, - call: async (): Promise => { - const type = await getAssetIdType(api, asset); - - const unwrappedType = type.unwrap(); - - const res = (await api.query.assetManager.assetTypeUnitsPerSecond( - unwrappedType, - )) as unknown as Option; - - const unitsPerSecond = res.unwrapOrDefault().toBigInt(); - - return (BigInt(weight) * unitsPerSecond) / BigInt(10 ** 12); - }, - }), - }), - }; -} function xcmPaymentApi() { return { 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/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/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/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/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/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/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/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/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/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(), },