From 91e473d55bba6385266de6dbf1b0983b56be1b48 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Wed, 25 Oct 2023 14:18:50 -0400 Subject: [PATCH] reorg types --- .../xTokens/transferMultiAssets.ts | 5 +- src/createXcmTypes/ParaToPara.ts | 5 +- src/createXcmTypes/ParaToSystem.ts | 5 +- src/createXcmTypes/types.ts | 59 ++++++++++++++- src/types.ts | 71 ------------------- 5 files changed, 66 insertions(+), 79 deletions(-) diff --git a/src/createXcmCalls/xTokens/transferMultiAssets.ts b/src/createXcmCalls/xTokens/transferMultiAssets.ts index 6616b901..23bca6e5 100644 --- a/src/createXcmCalls/xTokens/transferMultiAssets.ts +++ b/src/createXcmCalls/xTokens/transferMultiAssets.ts @@ -5,10 +5,11 @@ import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types'; import type { ISubmittableResult } from '@polkadot/types/types'; import { createXcmTypes } from '../../createXcmTypes'; +import type { XcmDestBenificiary } from '../../createXcmTypes/types'; import { UnionXcAssetsMultiAssets } from '../../createXcmTypes/types'; import { BaseError, BaseErrorsEnum } from '../../errors'; import type { Registry } from '../../registry'; -import { XCMDestBenificiary, XcmDirection } from '../../types'; +import { XcmDirection } from '../../types'; import type { CreateXcmCallOpts } from '../types'; import { XcmPalletName } from '../util/establishXcmPallet'; @@ -51,7 +52,7 @@ export const transferMultiAssets = async ( }); let assets: UnionXcAssetsMultiAssets; - let beneficiary: XCMDestBenificiary; + let beneficiary: XcmDestBenificiary; if ( typeCreator.createXTokensAssets && diff --git a/src/createXcmTypes/ParaToPara.ts b/src/createXcmTypes/ParaToPara.ts index e7e48fe2..e9d46da9 100644 --- a/src/createXcmTypes/ParaToPara.ts +++ b/src/createXcmTypes/ParaToPara.ts @@ -5,10 +5,11 @@ import type { u32 } from '@polkadot/types'; import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; +import type { XcmDestBenificiary } from '../createXcmTypes/types'; import { BaseError, BaseErrorsEnum } from '../errors'; import { Registry } from '../registry'; import { SanitizedXcAssetsData, XCMAssetRegistryMultiLocation } from '../registry/types'; -import { Direction, XCMDestBenificiary } from '../types'; +import { Direction } from '../types'; import { getFeeAssetItemIndex } from '../util/getFeeAssetItemIndex'; import { normalizeArrToStr } from '../util/normalizeArrToStr'; import { resolveMultiLocation } from '../util/resolveMultiLocation'; @@ -195,7 +196,7 @@ export const ParaToPara: ICreateXcmType = { return api.registry.createType('u32', 0); }, - createXTokensBeneficiary: (destChainId: string, accountId: string, xcmVersion: number): XCMDestBenificiary => { + createXTokensBeneficiary: (destChainId: string, accountId: string, xcmVersion: number): XcmDestBenificiary => { if (xcmVersion === 2) { return { V2: { diff --git a/src/createXcmTypes/ParaToSystem.ts b/src/createXcmTypes/ParaToSystem.ts index 9407a2d5..f08693f5 100644 --- a/src/createXcmTypes/ParaToSystem.ts +++ b/src/createXcmTypes/ParaToSystem.ts @@ -5,10 +5,11 @@ import type { u32 } from '@polkadot/types'; import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; +import type { XcmDestBenificiary } from '../createXcmTypes/types'; import { BaseError, BaseErrorsEnum } from '../errors'; import { Registry } from '../registry'; import { SanitizedXcAssetsData, XCMAssetRegistryMultiLocation } from '../registry/types'; -import { Direction, XCMDestBenificiary } from '../types'; +import { Direction } from '../types'; import { getFeeAssetItemIndex } from '../util/getFeeAssetItemIndex'; import { normalizeArrToStr } from '../util/normalizeArrToStr'; import { resolveMultiLocation } from '../util/resolveMultiLocation'; @@ -193,7 +194,7 @@ export const ParaToSystem: ICreateXcmType = { return api.registry.createType('u32', 0); }, - createXTokensBeneficiary: (destChainId: string, accountId: string, xcmVersion: number): XCMDestBenificiary => { + createXTokensBeneficiary: (destChainId: string, accountId: string, xcmVersion: number): XcmDestBenificiary => { if (xcmVersion === 2) { return { V2: { diff --git a/src/createXcmTypes/types.ts b/src/createXcmTypes/types.ts index e316f83c..5692a6b7 100644 --- a/src/createXcmTypes/types.ts +++ b/src/createXcmTypes/types.ts @@ -6,7 +6,7 @@ import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import type { AnyJson } from '@polkadot/types/types'; import type { Registry } from '../registry'; -import type { RequireOnlyOne, XCMDestBenificiary, XcmWeight } from '../types'; +import type { RequireOnlyOne } from '../types'; export type XcmBase = { [x: string]: { @@ -199,6 +199,61 @@ export interface XcAssetsV3MultiLocation { }; } +export interface XcmV2DestBenificiary { + V2: { + parents: string | number; + interior: { + X1: { AccountId32: { id: string } }; + }; + }; +} + +export interface XcmV3DestBenificiary { + V3: { + parents: string | number; + interior: { + X1: { AccountId32: { id: string } }; + }; + }; +} + +export interface XcmV2ParachainDestBenificiary { + V2: { + parents: string | number; + interior: { + X2: [{ Parachain: string }, { AccountId32: { id: string } }]; + }; + }; +} + +export interface XcmV3ParachainDestBenificiary { + V3: { + parents: string | number; + interior: { + X2: [{ Parachain: string }, { AccountId32: { id: string } }]; + }; + }; +} + +export type XcmDestBenificiary = + | XcmV3DestBenificiary + | XcmV2DestBenificiary + | XcmV2ParachainDestBenificiary + | XcmV3ParachainDestBenificiary; + +export interface XcmWeightUnlimited { + Unlimited: null | undefined; +} + +export interface XcmWeightLimited { + Limited: { + refTime: string; + proofSize: string; + }; +} + +export type XcmWeight = XcmWeightUnlimited | XcmWeightLimited; + export interface CreateAssetsOpts { registry: Registry; isForeignAssetsTransfer: boolean; @@ -241,7 +296,7 @@ export interface ICreateXcmType { ) => Promise; createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts) => WeightLimitV2; createFeeAssetItem: (api: ApiPromise, opts: CreateFeeAssetItemOpts) => Promise; - createXTokensBeneficiary?: (destChainId: string, accountId: string, xcmVersion: number) => XCMDestBenificiary; + createXTokensBeneficiary?: (destChainId: string, accountId: string, xcmVersion: number) => XcmDestBenificiary; createXTokensAssets?: ( amounts: string[], xcmVersion: number, diff --git a/src/types.ts b/src/types.ts index daa7d711..a4fc1238 100644 --- a/src/types.ts +++ b/src/types.ts @@ -309,77 +309,6 @@ export interface LocalTarget { Id: string; } -export interface XCMV2DestBenificiary { - V2: { - parents: string | number; - interior: { - X1: { AccountId32: { id: string } }; - }; - }; -} - -export interface XCMV3DestBenificiary { - V3: { - parents: string | number; - interior: { - X1: { AccountId32: { id: string } }; - }; - }; -} - -export interface XCMV2ParachainDestBenificiary { - V2: { - parents: string | number; - interior: { - X2: [{ Parachain: string }, { AccountId32: { id: string } }]; - }; - }; -} - -export interface XCMV3ParachainDestBenificiary { - V3: { - parents: string | number; - interior: { - X2: [{ Parachain: string }, { AccountId32: { id: string } }]; - }; - }; -} - -export type XCMDestBenificiary = - | XCMV3DestBenificiary - | XCMV2DestBenificiary - | XCMV2ParachainDestBenificiary - | XCMV3ParachainDestBenificiary; - -export interface XcmWeightUnlimited { - Unlimited: null | undefined; -} - -export interface XcmWeightLimited { - Limited: { - refTime: string; - proofSize: string; - }; -} - -export type XcmWeight = XcmWeightUnlimited | XcmWeightLimited; - -export interface Args { - dest?: LocalDest; - beneficiary?: XCMDestBenificiary; - target?: LocalTarget; -} - -export interface Method { - args: Args; - method: string; - section: string; -} -export interface SubmittableMethodData { - isSigned: boolean; - method: Method; -} - export type AssetInfo = { id: string; symbol: string;