From a0612e53c7f7ad86d692b50bc205b27ddd367089 Mon Sep 17 00:00:00 2001 From: Mario J Maurello Date: Wed, 17 Jan 2024 19:29:33 +1300 Subject: [PATCH] always use unlimited weight limit to fix bifrost issues --- .../src/extrinsic/pallets/xTokens/xTokens.ts | 14 +++++----- .../pallets/xTokens/xTokens.utils.ts | 27 +++---------------- .../types/src/chain/parachain/Parachain.ts | 4 +-- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts index 5a55f22a..b05ec066 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts +++ b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts @@ -12,7 +12,7 @@ const pallet = 'xTokens'; export function xTokens() { return { transfer: (): ExtrinsicConfigBuilder => ({ - build: ({ address, amount, asset, destination, source }) => + build: ({ address, amount, asset, destination }) => new ExtrinsicConfig({ module: pallet, func: 'transfer', @@ -23,7 +23,7 @@ export function xTokens() { asset, amount, getDestination(version, address, destination), - getWeight(source.weight, func), + getWeight(), ]; }, }), @@ -55,7 +55,7 @@ export function xTokens() { }, }, getDestination(version, address, destination), - 'Unlimited', + getWeight(), ]; }, }), @@ -87,13 +87,13 @@ export function xTokens() { }, }, getDestination(version, address, destination), - 'Unlimited', + getWeight(), ]; }, }), }), X2: (): ExtrinsicConfigBuilder => ({ - build: ({ address, amount, asset, destination, source }) => + build: ({ address, amount, asset, destination }) => new ExtrinsicConfig({ module: pallet, func: funcName, @@ -124,7 +124,7 @@ export function xTokens() { }, }, getDestination(version, address, destination), - getWeight(source.weight, func), + getWeight(), ]; }, }), @@ -143,7 +143,7 @@ export function xTokens() { ], 1, getDestination(XcmVersion.v3, address, destination), - 'Unlimited', + getWeight(), ], }), }), diff --git a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts index 2b44f740..1a6518af 100644 --- a/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts +++ b/packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts @@ -1,34 +1,13 @@ import { AnyChain } from '@moonbeam-network/xcm-types'; -import { SubmittableExtrinsicFunction } from '@polkadot/api/types'; import { XcmVersion } from '../../ExtrinsicBuilder.interfaces'; import { getExtrinsicAccount } from '../../ExtrinsicBuilder.utils'; import { XTokensWeightLimit } from './xTokens.interfaces'; /** - * Workaround for weight parameter type change in xTokens pallet - * https://github.com/open-web3-stack/open-runtime-module-library/pull/841 + * It is safer to always use unlimited */ -export function getWeight( - weight: number, - func?: SubmittableExtrinsicFunction<'promise'>, -): XTokensWeightLimit { - const type = func?.meta.args.at(-1)?.type; - - if (!type) { - return weight; - } - - if (type.eq('XcmV2WeightLimit')) { - return { - Limited: weight, - }; - } - - if (type.eq('XcmV3WeightLimit')) { - return 'Unlimited'; - } - - return weight; +export function getWeight(): XTokensWeightLimit { + return 'Unlimited'; } export function getDestination( diff --git a/packages/types/src/chain/parachain/Parachain.ts b/packages/types/src/chain/parachain/Parachain.ts index b7f57950..03cb14ae 100644 --- a/packages/types/src/chain/parachain/Parachain.ts +++ b/packages/types/src/chain/parachain/Parachain.ts @@ -23,7 +23,7 @@ export class Parachain extends Chain { readonly ss58Format: number; - readonly weight: number; + readonly weight: number | undefined; readonly ws: string; @@ -46,7 +46,7 @@ export class Parachain extends Chain { this.genesisHash = genesisHash; this.parachainId = parachainId; this.ss58Format = ss58Format; - this.weight = weight ?? 1_000_000_000; + this.weight = weight; this.ws = ws; }