Skip to content

Commit

Permalink
reorg types
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Oct 25, 2023
1 parent 6527fbc commit 91e473d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 79 deletions.
5 changes: 3 additions & 2 deletions src/createXcmCalls/xTokens/transferMultiAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -51,7 +52,7 @@ export const transferMultiAssets = async (
});

let assets: UnionXcAssetsMultiAssets;
let beneficiary: XCMDestBenificiary;
let beneficiary: XcmDestBenificiary;

if (
typeCreator.createXTokensAssets &&
Expand Down
5 changes: 3 additions & 2 deletions src/createXcmTypes/ParaToPara.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: {
Expand Down
5 changes: 3 additions & 2 deletions src/createXcmTypes/ParaToSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: {
Expand Down
59 changes: 57 additions & 2 deletions src/createXcmTypes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -241,7 +296,7 @@ export interface ICreateXcmType {
) => Promise<UnionXcmMultiAssets>;
createWeightLimit: (api: ApiPromise, opts: CreateWeightLimitOpts) => WeightLimitV2;
createFeeAssetItem: (api: ApiPromise, opts: CreateFeeAssetItemOpts) => Promise<u32>;
createXTokensBeneficiary?: (destChainId: string, accountId: string, xcmVersion: number) => XCMDestBenificiary;
createXTokensBeneficiary?: (destChainId: string, accountId: string, xcmVersion: number) => XcmDestBenificiary;
createXTokensAssets?: (
amounts: string[],
xcmVersion: number,
Expand Down
71 changes: 0 additions & 71 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 91e473d

Please sign in to comment.