Skip to content

Commit

Permalink
remove assetTypeUnitsPerSecond function since it is not used now
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Sep 23, 2024
1 parent a92c261 commit 6b69eab
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 101 deletions.
14 changes: 10 additions & 4 deletions mkdocs/docs/reference/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down Expand Up @@ -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(),
},
Expand Down Expand Up @@ -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(),
},
Expand Down Expand Up @@ -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 }),
}
```

Expand Down
27 changes: 0 additions & 27 deletions packages/builder/src/fee/FeeBuilder.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<bigint> => {
const type = await getAssetIdType(api, asset);

const unwrappedType = type.unwrap();

const res = (await api.query.assetManager.assetTypeUnitsPerSecond(
unwrappedType,
)) as unknown as Option<u128>;

const unitsPerSecond = res.unwrapOrDefault().toBigInt();

return (BigInt(weight) * unitsPerSecond) / BigInt(10 ** 12);
},
}),
}),
};
}

function xcmPaymentApi() {
return {
Expand Down
2 changes: 0 additions & 2 deletions packages/config/src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down Expand Up @@ -98,7 +97,6 @@ export const chainsConfigList: ChainConfig[] = [
tinkernetConfig,
turingConfig,
turingAlphanetConfig,
uniqueAlphaConfig,
zeitgeistConfig,
];

Expand Down
15 changes: 0 additions & 15 deletions packages/config/src/configs/moonbaseAlpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion packages/config/src/configs/neuroweb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down
4 changes: 3 additions & 1 deletion packages/config/src/configs/nodle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down
8 changes: 6 additions & 2 deletions packages/config/src/configs/parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
28 changes: 21 additions & 7 deletions packages/config/src/configs/peaq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
25 changes: 19 additions & 6 deletions packages/config/src/configs/peaqEvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
12 changes: 9 additions & 3 deletions packages/config/src/configs/pendulum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
8 changes: 6 additions & 2 deletions packages/config/src/configs/phala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand All @@ -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(),
},
Expand Down
Loading

0 comments on commit 6b69eab

Please sign in to comment.