Skip to content

Commit a0612e5

Browse files
committed
always use unlimited weight limit to fix bifrost issues
1 parent 4e6e0f0 commit a0612e5

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

packages/builder/src/extrinsic/pallets/xTokens/xTokens.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const pallet = 'xTokens';
1212
export function xTokens() {
1313
return {
1414
transfer: (): ExtrinsicConfigBuilder => ({
15-
build: ({ address, amount, asset, destination, source }) =>
15+
build: ({ address, amount, asset, destination }) =>
1616
new ExtrinsicConfig({
1717
module: pallet,
1818
func: 'transfer',
@@ -23,7 +23,7 @@ export function xTokens() {
2323
asset,
2424
amount,
2525
getDestination(version, address, destination),
26-
getWeight(source.weight, func),
26+
getWeight(),
2727
];
2828
},
2929
}),
@@ -55,7 +55,7 @@ export function xTokens() {
5555
},
5656
},
5757
getDestination(version, address, destination),
58-
'Unlimited',
58+
getWeight(),
5959
];
6060
},
6161
}),
@@ -87,13 +87,13 @@ export function xTokens() {
8787
},
8888
},
8989
getDestination(version, address, destination),
90-
'Unlimited',
90+
getWeight(),
9191
];
9292
},
9393
}),
9494
}),
9595
X2: (): ExtrinsicConfigBuilder => ({
96-
build: ({ address, amount, asset, destination, source }) =>
96+
build: ({ address, amount, asset, destination }) =>
9797
new ExtrinsicConfig({
9898
module: pallet,
9999
func: funcName,
@@ -124,7 +124,7 @@ export function xTokens() {
124124
},
125125
},
126126
getDestination(version, address, destination),
127-
getWeight(source.weight, func),
127+
getWeight(),
128128
];
129129
},
130130
}),
@@ -143,7 +143,7 @@ export function xTokens() {
143143
],
144144
1,
145145
getDestination(XcmVersion.v3, address, destination),
146-
'Unlimited',
146+
getWeight(),
147147
],
148148
}),
149149
}),

packages/builder/src/extrinsic/pallets/xTokens/xTokens.utils.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
import { AnyChain } from '@moonbeam-network/xcm-types';
2-
import { SubmittableExtrinsicFunction } from '@polkadot/api/types';
32
import { XcmVersion } from '../../ExtrinsicBuilder.interfaces';
43
import { getExtrinsicAccount } from '../../ExtrinsicBuilder.utils';
54
import { XTokensWeightLimit } from './xTokens.interfaces';
65

76
/**
8-
* Workaround for weight parameter type change in xTokens pallet
9-
* https://github.com/open-web3-stack/open-runtime-module-library/pull/841
7+
* It is safer to always use unlimited
108
*/
11-
export function getWeight(
12-
weight: number,
13-
func?: SubmittableExtrinsicFunction<'promise'>,
14-
): XTokensWeightLimit {
15-
const type = func?.meta.args.at(-1)?.type;
16-
17-
if (!type) {
18-
return weight;
19-
}
20-
21-
if (type.eq('XcmV2WeightLimit')) {
22-
return {
23-
Limited: weight,
24-
};
25-
}
26-
27-
if (type.eq('XcmV3WeightLimit')) {
28-
return 'Unlimited';
29-
}
30-
31-
return weight;
9+
export function getWeight(): XTokensWeightLimit {
10+
return 'Unlimited';
3211
}
3312

3413
export function getDestination(

packages/types/src/chain/parachain/Parachain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class Parachain extends Chain {
2323

2424
readonly ss58Format: number;
2525

26-
readonly weight: number;
26+
readonly weight: number | undefined;
2727

2828
readonly ws: string;
2929

@@ -46,7 +46,7 @@ export class Parachain extends Chain {
4646
this.genesisHash = genesisHash;
4747
this.parachainId = parachainId;
4848
this.ss58Format = ss58Format;
49-
this.weight = weight ?? 1_000_000_000;
49+
this.weight = weight;
5050
this.ws = ws;
5151
}
5252

0 commit comments

Comments
 (0)