diff --git a/src/createXcmCalls/polkadotXcm/limitedReserveTransferAssets.ts b/src/createXcmCalls/polkadotXcm/limitedReserveTransferAssets.ts index 05e1fd12..92bc2510 100644 --- a/src/createXcmCalls/polkadotXcm/limitedReserveTransferAssets.ts +++ b/src/createXcmCalls/polkadotXcm/limitedReserveTransferAssets.ts @@ -51,7 +51,7 @@ export const limitedReserveTransferAssets = async ( isLiquidTokenTransfer, api, }); - const weightLimitType = typeCreator.createWeightLimit(api, { + const weightLimitType = typeCreator.createWeightLimit({ isLimited, weightLimit, }); diff --git a/src/createXcmCalls/polkadotXcm/limitedTeleportAssets.ts b/src/createXcmCalls/polkadotXcm/limitedTeleportAssets.ts index ade4ffa9..d491f5d9 100644 --- a/src/createXcmCalls/polkadotXcm/limitedTeleportAssets.ts +++ b/src/createXcmCalls/polkadotXcm/limitedTeleportAssets.ts @@ -49,7 +49,7 @@ export const limitedTeleportAssets = async ( isLiquidTokenTransfer: false, api, }); - const weightLimitType = typeCreator.createWeightLimit(api, { + const weightLimitType = typeCreator.createWeightLimit({ isLimited, weightLimit, }); diff --git a/src/createXcmCalls/xTokens/transferMultiAsset.ts b/src/createXcmCalls/xTokens/transferMultiAsset.ts index 2583f54b..1d090b28 100644 --- a/src/createXcmCalls/xTokens/transferMultiAsset.ts +++ b/src/createXcmCalls/xTokens/transferMultiAsset.ts @@ -43,7 +43,7 @@ export const transferMultiAsset = async ( const { isLimited, weightLimit, isForeignAssetsTransfer, isLiquidTokenTransfer } = opts; const ext = api.tx[xcmPallet].transferMultiasset; const typeCreator = createXcmTypes[direction]; - const destWeightLimit = typeCreator.createWeightLimit(api, { + const destWeightLimit = typeCreator.createWeightLimit({ isLimited, weightLimit, }); diff --git a/src/createXcmCalls/xTokens/transferMultiAssetWithFee.ts b/src/createXcmCalls/xTokens/transferMultiAssetWithFee.ts index 87a94064..4cd5ef86 100644 --- a/src/createXcmCalls/xTokens/transferMultiAssetWithFee.ts +++ b/src/createXcmCalls/xTokens/transferMultiAssetWithFee.ts @@ -43,7 +43,7 @@ export const transferMultiAssetWithFee = async ( const { isLimited, weightLimit, paysWithFeeDest, isForeignAssetsTransfer, isLiquidTokenTransfer } = opts; const ext = api.tx[xcmPallet].transferMultiassetWithFee; const typeCreator = createXcmTypes[direction]; - const destWeightLimit = typeCreator.createWeightLimit(api, { + const destWeightLimit = typeCreator.createWeightLimit({ isLimited, weightLimit, }); diff --git a/src/createXcmCalls/xTokens/transferMultiAssets.ts b/src/createXcmCalls/xTokens/transferMultiAssets.ts index 13fd76cf..a9cbbc1e 100644 --- a/src/createXcmCalls/xTokens/transferMultiAssets.ts +++ b/src/createXcmCalls/xTokens/transferMultiAssets.ts @@ -46,7 +46,7 @@ export const transferMultiAssets = async ( const ext = api.tx[xcmPallet].transferMultiassets; const typeCreator = createXcmTypes[direction]; - const destWeightLimit = typeCreator.createWeightLimit(api, { + const destWeightLimit = typeCreator.createWeightLimit({ isLimited, weightLimit, }); diff --git a/src/createXcmTypes/ParaToPara.spec.ts b/src/createXcmTypes/ParaToPara.spec.ts index 2630df94..2d5d27fa 100644 --- a/src/createXcmTypes/ParaToPara.spec.ts +++ b/src/createXcmTypes/ParaToPara.spec.ts @@ -189,25 +189,25 @@ describe('ParaToPara', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = ParaToPara.createWeightLimit(mockParachainApi, { + const weightLimit = ParaToPara.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - proofSize: 1000, - refTime: 100000000, + expect(weightLimit).toStrictEqual({ + Limited: { + proofSize: '1000', + refTime: '100000000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = ParaToPara.createWeightLimit(mockParachainApi, {}); + const weightLimit = ParaToPara.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/ParaToPara.ts b/src/createXcmTypes/ParaToPara.ts index a6fa3c92..5b3799ef 100644 --- a/src/createXcmTypes/ParaToPara.ts +++ b/src/createXcmTypes/ParaToPara.ts @@ -2,7 +2,6 @@ import type { ApiPromise } from '@polkadot/api'; import type { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; import { BaseError, BaseErrorsEnum } from '../errors'; @@ -20,7 +19,6 @@ import type { FungibleObjMultiAsset, FungibleStrMultiAsset, ICreateXcmType, - IWeightLimit, UnionXcAssetsMultiAsset, UnionXcAssetsMultiAssets, UnionXcAssetsMultiLocation, @@ -28,6 +26,7 @@ import type { XcmDestBenificiary, XcmDestBenificiaryXcAssets, XcmV3MultiLocation, + XcmWeight, } from './types'; import { constructForeignAssetMultiLocationFromAssetId } from './util/constructForeignAssetMultiLocationFromAssetId'; import { dedupeMultiAssets } from './util/dedupeMultiAssets'; @@ -144,18 +143,15 @@ export const ParaToPara: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit.refTime, - proofSize: opts.weightLimit.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit.refTime, + proofSize: opts.weightLimit.proofSize, + }, + } + : { Unlimited: null }; }, /** * returns the correct feeAssetItem based on XCM direction. diff --git a/src/createXcmTypes/ParaToSystem.spec.ts b/src/createXcmTypes/ParaToSystem.spec.ts index 954d6699..8eead2eb 100644 --- a/src/createXcmTypes/ParaToSystem.spec.ts +++ b/src/createXcmTypes/ParaToSystem.spec.ts @@ -189,25 +189,25 @@ describe('ParaToSystem', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = ParaToSystem.createWeightLimit(mockParachainApi, { + const weightLimit = ParaToSystem.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - proofSize: 1000, - refTime: 100000000, + expect(weightLimit).toStrictEqual({ + Limited: { + proofSize: '1000', + refTime: '100000000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = ParaToSystem.createWeightLimit(mockParachainApi, {}); + const weightLimit = ParaToSystem.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/ParaToSystem.ts b/src/createXcmTypes/ParaToSystem.ts index e5d7e915..fcbea0bc 100644 --- a/src/createXcmTypes/ParaToSystem.ts +++ b/src/createXcmTypes/ParaToSystem.ts @@ -2,7 +2,6 @@ import type { ApiPromise } from '@polkadot/api'; import type { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; import { BaseError, BaseErrorsEnum } from '../errors'; @@ -20,7 +19,6 @@ import type { FungibleObjMultiAsset, FungibleStrMultiAsset, ICreateXcmType, - IWeightLimit, UnionXcAssetsMultiAsset, UnionXcAssetsMultiAssets, UnionXcAssetsMultiLocation, @@ -28,6 +26,7 @@ import type { XcmDestBenificiary, XcmDestBenificiaryXcAssets, XcmV3MultiLocation, + XcmWeight, } from './types'; import { constructForeignAssetMultiLocationFromAssetId } from './util/constructForeignAssetMultiLocationFromAssetId'; import { dedupeMultiAssets } from './util/dedupeMultiAssets'; @@ -142,18 +141,15 @@ export const ParaToSystem: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit.refTime, - proofSize: opts.weightLimit.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit.refTime, + proofSize: opts.weightLimit.proofSize, + }, + } + : { Unlimited: null }; }, /** * returns the correct feeAssetItem based on XCM direction. diff --git a/src/createXcmTypes/RelayToPara.spec.ts b/src/createXcmTypes/RelayToPara.spec.ts index 25a18349..edff6817 100644 --- a/src/createXcmTypes/RelayToPara.spec.ts +++ b/src/createXcmTypes/RelayToPara.spec.ts @@ -192,25 +192,25 @@ describe('RelayToPara XcmVersioned Generation', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = RelayToPara.createWeightLimit(mockRelayApi, { + const weightLimit = RelayToPara.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - refTime: 100000000, - proofSize: 1000, + expect(weightLimit).toStrictEqual({ + Limited: { + refTime: '100000000', + proofSize: '1000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = RelayToPara.createWeightLimit(mockRelayApi, {}); + const weightLimit = RelayToPara.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/RelayToPara.ts b/src/createXcmTypes/RelayToPara.ts index 50ded754..fce23a89 100644 --- a/src/createXcmTypes/RelayToPara.ts +++ b/src/createXcmTypes/RelayToPara.ts @@ -2,16 +2,15 @@ import type { ApiPromise } from '@polkadot/api'; import { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { isEthereumAddress } from '@polkadot/util-crypto'; import { CreateWeightLimitOpts, ICreateXcmType, - IWeightLimit, UnionXcmMultiAssets, XcmDestBenificiary, XcmMultiAsset, + XcmWeight, } from './types'; /** @@ -127,18 +126,15 @@ export const RelayToPara: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit?.refTime, - proofSize: opts.weightLimit?.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit?.refTime, + proofSize: opts.weightLimit?.proofSize, + }, + } + : { Unlimited: null }; }, /** diff --git a/src/createXcmTypes/RelayToSystem.spec.ts b/src/createXcmTypes/RelayToSystem.spec.ts index a2a93c16..e645dc34 100644 --- a/src/createXcmTypes/RelayToSystem.spec.ts +++ b/src/createXcmTypes/RelayToSystem.spec.ts @@ -154,25 +154,25 @@ describe('RelayToSystem XcmVersioned Generation', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = RelayToSystem.createWeightLimit(mockRelayApi, { + const weightLimit = RelayToSystem.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - refTime: 100000000, - proofSize: 1000, + expect(weightLimit).toStrictEqual({ + Limited: { + refTime: '100000000', + proofSize: '1000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = RelayToSystem.createWeightLimit(mockRelayApi, {}); + const weightLimit = RelayToSystem.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/RelayToSystem.ts b/src/createXcmTypes/RelayToSystem.ts index ba756626..e2241060 100644 --- a/src/createXcmTypes/RelayToSystem.ts +++ b/src/createXcmTypes/RelayToSystem.ts @@ -2,15 +2,14 @@ import type { ApiPromise } from '@polkadot/api'; import { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { CreateWeightLimitOpts, ICreateXcmType, - IWeightLimit, UnionXcmMultiAssets, XcmDestBenificiary, XcmMultiAsset, + XcmWeight, } from './types'; /** * XCM type generation for transactions from the relay chain to a system parachain. @@ -130,18 +129,15 @@ export const RelayToSystem: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit?.refTime, - proofSize: opts.weightLimit?.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit?.refTime, + proofSize: opts.weightLimit?.proofSize, + }, + } + : { Unlimited: null }; }, /** diff --git a/src/createXcmTypes/SystemToPara.spec.ts b/src/createXcmTypes/SystemToPara.spec.ts index 81fa964b..9008e0a6 100644 --- a/src/createXcmTypes/SystemToPara.spec.ts +++ b/src/createXcmTypes/SystemToPara.spec.ts @@ -262,25 +262,25 @@ describe('SystemToPara XcmVersioned Generation', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = SystemToPara.createWeightLimit(mockSystemApi, { + const weightLimit = SystemToPara.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - refTime: 100000000, - proofSize: 1000, + expect(weightLimit).toStrictEqual({ + Limited: { + refTime: '100000000', + proofSize: '1000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = SystemToPara.createWeightLimit(mockSystemApi, {}); + const weightLimit = SystemToPara.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/SystemToPara.ts b/src/createXcmTypes/SystemToPara.ts index 300e2eec..15ec2545 100644 --- a/src/createXcmTypes/SystemToPara.ts +++ b/src/createXcmTypes/SystemToPara.ts @@ -2,7 +2,6 @@ import type { ApiPromise } from '@polkadot/api'; import type { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { isEthereumAddress } from '@polkadot/util-crypto'; import { BaseError, BaseErrorsEnum } from '../errors'; @@ -17,12 +16,12 @@ import type { CreateWeightLimitOpts, FungibleStrMultiAsset, ICreateXcmType, - IWeightLimit, UnionXcmMultiAssets, UnionXcmMultiLocation, XcmDestBenificiary, XcmV2Junctions, XcmV3Junctions, + XcmWeight, } from './types'; import { constructForeignAssetMultiLocationFromAssetId } from './util/constructForeignAssetMultiLocationFromAssetId'; import { dedupeMultiAssets } from './util/dedupeMultiAssets'; @@ -145,18 +144,15 @@ export const SystemToPara: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit?.refTime, - proofSize: opts.weightLimit?.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit?.refTime, + proofSize: opts.weightLimit?.proofSize, + }, + } + : { Unlimited: null }; }, /** diff --git a/src/createXcmTypes/SystemToRelay.spec.ts b/src/createXcmTypes/SystemToRelay.spec.ts index b52b1a36..8e87acde 100644 --- a/src/createXcmTypes/SystemToRelay.spec.ts +++ b/src/createXcmTypes/SystemToRelay.spec.ts @@ -148,25 +148,25 @@ describe('SystemToRelay XcmVersioned Generation', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = SystemToRelay.createWeightLimit(mockSystemApi, { + const weightLimit = SystemToRelay.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - refTime: 100000000, - proofSize: 1000, + expect(weightLimit).toStrictEqual({ + Limited: { + refTime: '100000000', + proofSize: '1000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = SystemToRelay.createWeightLimit(mockSystemApi, {}); + const weightLimit = SystemToRelay.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/SystemToRelay.ts b/src/createXcmTypes/SystemToRelay.ts index 03924712..a873c4ca 100644 --- a/src/createXcmTypes/SystemToRelay.ts +++ b/src/createXcmTypes/SystemToRelay.ts @@ -2,15 +2,14 @@ import type { ApiPromise } from '@polkadot/api'; import { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { CreateWeightLimitOpts, ICreateXcmType, - IWeightLimit, UnionXcmMultiAssets, XcmDestBenificiary, XcmMultiAsset, + XcmWeight, } from './types'; export const SystemToRelay: ICreateXcmType = { @@ -122,18 +121,15 @@ export const SystemToRelay: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit?.refTime, - proofSize: opts.weightLimit?.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit?.refTime, + proofSize: opts.weightLimit?.proofSize, + }, + } + : { Unlimited: null }; }, /** diff --git a/src/createXcmTypes/SystemToSystem.spec.ts b/src/createXcmTypes/SystemToSystem.spec.ts index 08e0af36..416cd6e8 100644 --- a/src/createXcmTypes/SystemToSystem.spec.ts +++ b/src/createXcmTypes/SystemToSystem.spec.ts @@ -195,25 +195,25 @@ describe('SystemToSystem XcmVersioned Generation', () => { const refTime = '100000000'; const proofSize = '1000'; - const weightLimit = SystemToSystem.createWeightLimit(mockSystemApi, { + const weightLimit = SystemToSystem.createWeightLimit({ isLimited, weightLimit: { refTime, proofSize, }, }); - expect(weightLimit.toJSON()).toStrictEqual({ - limited: { - refTime: 100000000, - proofSize: 1000, + expect(weightLimit).toStrictEqual({ + Limited: { + refTime: '100000000', + proofSize: '1000', }, }); }); it('Should work when isLimited is falsy', () => { - const weightLimit = SystemToSystem.createWeightLimit(mockSystemApi, {}); + const weightLimit = SystemToSystem.createWeightLimit({}); - expect(weightLimit.toJSON()).toStrictEqual({ - unlimited: null, + expect(weightLimit).toStrictEqual({ + Unlimited: null, }); }); }); diff --git a/src/createXcmTypes/SystemToSystem.ts b/src/createXcmTypes/SystemToSystem.ts index bc3789e0..d2609517 100644 --- a/src/createXcmTypes/SystemToSystem.ts +++ b/src/createXcmTypes/SystemToSystem.ts @@ -2,7 +2,6 @@ import type { ApiPromise } from '@polkadot/api'; import { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { BaseError, BaseErrorsEnum } from '../errors'; import type { Registry } from '../registry'; @@ -17,12 +16,12 @@ import { CreateWeightLimitOpts, FungibleStrMultiAsset, ICreateXcmType, - IWeightLimit, UnionXcmMultiAssets, UnionXcmMultiLocation, XcmDestBenificiary, XcmV2Junctions, XcmV3Junctions, + XcmWeight, } from './types'; import { dedupeMultiAssets } from './util/dedupeMultiAssets'; import { fetchPalletInstanceId } from './util/fetchPalletInstanceId'; @@ -139,18 +138,15 @@ export const SystemToSystem: ICreateXcmType = { * @param refTime amount of computation time * @param proofSize amount of storage to be used */ - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts): WeightLimitV2 => { - const limit: IWeightLimit = - opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize - ? { - Limited: { - refTime: opts.weightLimit?.refTime, - proofSize: opts.weightLimit?.proofSize, - }, - } - : { Unlimited: null }; - - return api.registry.createType('XcmV3WeightLimit', limit); + createWeightLimit: (opts: CreateWeightLimitOpts): XcmWeight => { + return opts.isLimited && opts.weightLimit?.refTime && opts.weightLimit?.proofSize + ? { + Limited: { + refTime: opts.weightLimit?.refTime, + proofSize: opts.weightLimit?.proofSize, + }, + } + : { Unlimited: null }; }, /** diff --git a/src/createXcmTypes/types.ts b/src/createXcmTypes/types.ts index 5d081742..3fb34d19 100644 --- a/src/createXcmTypes/types.ts +++ b/src/createXcmTypes/types.ts @@ -2,7 +2,6 @@ import type { ApiPromise } from '@polkadot/api'; import { u32 } from '@polkadot/types'; -import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; import type { Registry } from '../registry'; @@ -294,7 +293,7 @@ export interface ICreateXcmType { assets: string[], opts: CreateAssetsOpts ) => Promise; - createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts) => WeightLimitV2; + createWeightLimit: (opts: CreateWeightLimitOpts) => XcmWeight; createFeeAssetItem: (api: ApiPromise, opts: CreateFeeAssetItemOpts) => Promise; createXTokensBeneficiary?: (destChainId: string, accountId: string, xcmVersion: number) => XcmDestBenificiaryXcAssets; createXTokensAssets?: ( @@ -314,13 +313,3 @@ export interface ICreateXcmType { createXTokensWeightLimit?: (opts: CreateWeightLimitOpts) => XcmWeight; createXTokensFeeAssetItem?: (opts: CreateFeeAssetItemOpts) => UnionXcAssetsMultiLocation; } - -interface IWeightLimitBase { - Unlimited: null; - Limited: { - refTime: string; - proofSize: string; - }; -} - -export type IWeightLimit = RequireOnlyOne;