Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Xcm versioned types (with xcm v2) #3916

Merged
merged 3 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/types/src/augment/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalanceOf, DestroyWitness, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { AssetInstance, AssetInstanceV0, AssetInstanceV1, BodyId, BodyPart, DoubleEncodedCall, Fungibility, InboundStatus, Junction, MultiAsset, MultiAssetFilter, MultiAssetFilterV1, MultiAssetV0, MultiAssetV1, MultiAssetV2, MultiAssets, MultiAssetsV1, MultiAssetsV2, MultiLocation, MultiLocationV0, MultiLocationV1, MultiLocationV2, NetworkId, OutboundStatus, Outcome, QueryId, QueryStatus, QueueConfigData, Response, ResponseV0, ResponseV1, ResponseV2, ResponseV2Error, ResponseV2Result, VersionMigrationStage, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WildFungibility, WildMultiAsset, WildMultiAssetV1, Xcm, XcmAssetId, XcmError, XcmErrorV0, XcmErrorV1, XcmErrorV2, XcmOrder, XcmOrderV0, XcmOrderV1, XcmOrigin, XcmOriginKind, XcmV0, XcmV1, XcmVersion, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
import type { AssetInstance, AssetInstanceV0, AssetInstanceV1, BodyId, BodyPart, DoubleEncodedCall, Fungibility, InboundStatus, InstructionV2, InteriorMultiLocation, Junction, Junctions, MultiAsset, MultiAssetFilter, MultiAssetFilterV1, MultiAssetFilterV2, MultiAssetV0, MultiAssetV1, MultiAssetV2, MultiAssets, MultiAssetsV1, MultiAssetsV2, MultiLocation, MultiLocationV0, MultiLocationV1, MultiLocationV2, NetworkId, OriginKindV0, OriginKindV1, OriginKindV2, OutboundStatus, Outcome, QueryId, QueryStatus, QueueConfigData, Response, ResponseV0, ResponseV1, ResponseV2, ResponseV2Error, ResponseV2Result, VersionMigrationStage, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WeightLimitV2, WildFungibility, WildMultiAsset, WildMultiAssetV1, Xcm, XcmAssetId, XcmError, XcmErrorV0, XcmErrorV1, XcmErrorV2, XcmOrder, XcmOrderV0, XcmOrderV1, XcmOrigin, XcmOriginKind, XcmV0, XcmV1, XcmV2, XcmVersion, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';

declare module '@polkadot/types/types/registry' {
export interface InterfaceTypes {
Expand Down Expand Up @@ -476,11 +476,14 @@ declare module '@polkadot/types/types/registry' {
InstanceMetadata: InstanceMetadata;
InstantiateRequest: InstantiateRequest;
InstantiateReturnValue: InstantiateReturnValue;
InstructionV2: InstructionV2;
InstructionWeights: InstructionWeights;
InteriorMultiLocation: InteriorMultiLocation;
InvalidDisputeStatementKind: InvalidDisputeStatementKind;
InvalidTransaction: InvalidTransaction;
Json: Json;
Junction: Junction;
Junctions: Junctions;
Justification: Justification;
JustificationNotification: JustificationNotification;
Justifications: Justifications;
Expand Down Expand Up @@ -549,6 +552,7 @@ declare module '@polkadot/types/types/registry' {
MultiAsset: MultiAsset;
MultiAssetFilter: MultiAssetFilter;
MultiAssetFilterV1: MultiAssetFilterV1;
MultiAssetFilterV2: MultiAssetFilterV2;
MultiAssets: MultiAssets;
MultiAssetsV1: MultiAssetsV1;
MultiAssetsV2: MultiAssetsV2;
Expand Down Expand Up @@ -594,6 +598,9 @@ declare module '@polkadot/types/types/registry' {
OperatingMode: OperatingMode;
Origin: Origin;
OriginCaller: OriginCaller;
OriginKindV0: OriginKindV0;
OriginKindV1: OriginKindV1;
OriginKindV2: OriginKindV2;
OutboundHrmpMessage: OutboundHrmpMessage;
OutboundLaneData: OutboundLaneData;
OutboundMessageFee: OutboundMessageFee;
Expand Down Expand Up @@ -982,6 +989,7 @@ declare module '@polkadot/types/types/registry' {
VrfOutput: VrfOutput;
VrfProof: VrfProof;
Weight: Weight;
WeightLimitV2: WeightLimitV2;
WeightMultiplier: WeightMultiplier;
WeightPerClass: WeightPerClass;
WeightToFeeCoefficient: WeightToFeeCoefficient;
Expand All @@ -1007,6 +1015,7 @@ declare module '@polkadot/types/types/registry' {
XcmpMessageFormat: XcmpMessageFormat;
XcmV0: XcmV0;
XcmV1: XcmV1;
XcmV2: XcmV2;
XcmVersion: XcmVersion;
}
}
31 changes: 17 additions & 14 deletions packages/types/src/interfaces/xcm/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ const location = {
}
}
},
InteriorMultiLocation: 'Junctions',
Junctions: {
_enum: {
Here: 'Null',
X1: 'Junction',
X2: '(Junction, Junction)',
X3: '(Junction, Junction, Junction)',
X4: '(Junction, Junction, Junction, Junction)',
X5: '(Junction, Junction, Junction, Junction, Junction)',
X6: '(Junction, Junction, Junction, Junction, Junction, Junction)',
X7: '(Junction, Junction, Junction, Junction, Junction, Junction, Junction)',
X8: '(Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction)'
}
},
Junction: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Junction type needs to be versioned as well AFAICT.
The Parent variant
was removed in v1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dangit, was hoping to catch them all by now :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr: #3932

_enum: {
Parent: 'Null',
Expand All @@ -106,19 +120,7 @@ const location = {
}
}
},
MultiLocation: {
_enum: {
Here: 'Null',
X1: 'Junction',
X2: '(Junction, Junction)',
X3: '(Junction, Junction, Junction)',
X4: '(Junction, Junction, Junction, Junction)',
X5: '(Junction, Junction, Junction, Junction, Junction)',
X6: '(Junction, Junction, Junction, Junction, Junction, Junction)',
X7: '(Junction, Junction, Junction, Junction, Junction, Junction, Junction)',
X8: '(Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction)'
}
},
MultiLocation: 'Junctions',
NetworkId: {
_enum: {
Any: 'Null',
Expand Down Expand Up @@ -209,7 +211,8 @@ export default {
VersionedXcm: {
_enum: {
V0: 'XcmV0',
V1: 'XcmV1'
V1: 'XcmV1',
V2: 'XcmV2'
}
},
XcmVersion: 'u32'
Expand Down
193 changes: 172 additions & 21 deletions packages/types/src/interfaces/xcm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,122 @@ export interface InboundStatus extends Enum {
readonly isSuspended: boolean;
}

/** @name InstructionV2 */
export interface InstructionV2 extends Enum {
readonly isWithdrawAsset: boolean;
readonly asWithdrawAsset: MultiAssetsV2;
readonly isReserveAssetDeposited: boolean;
readonly asReserveAssetDeposited: MultiAssetsV2;
readonly isReceiveTeleportedAsset: boolean;
readonly asReceiveTeleportedAsset: MultiAssetsV2;
readonly isQueryResponse: boolean;
readonly asQueryResponse: {
readonly queryId: Compact<u64>;
readonly response: ResponseV2;
readonly maxWeight: Compact<u64>;
} & Struct;
readonly isTransferAsset: boolean;
readonly asTransferAsset: {
readonly assets: MultiAssetsV2;
readonly beneficiary: MultiLocationV2;
} & Struct;
readonly isTransferReserveAsset: boolean;
readonly asTransferReserveAsset: {
readonly assets: MultiAssetsV2;
readonly dest: MultiLocationV2;
readonly xcm: XcmV2;
} & Struct;
readonly isTransact: boolean;
readonly asTransact: {
readonly originType: OriginKindV2;
readonly requireWeightAtMost: u64;
readonly call: DoubleEncodedCall;
} & Struct;
readonly isHrmpNewChannelOpenRequest: boolean;
readonly asHrmpNewChannelOpenRequest: {
readonly sender: Compact<u32>;
readonly maxMessageSize: Compact<u32>;
readonly maxCapacity: Compact<u32>;
} & Struct;
readonly isHrmpChannelAccepted: boolean;
readonly asHrmpChannelAccepted: {
readonly recipient: Compact<u32>;
} & Struct;
readonly isHrmpChannelClosing: boolean;
readonly asHrmpChannelClosing: {
readonly initiator: Compact<u32>;
readonly sender: Compact<u32>;
readonly recipient: Compact<u32>;
} & Struct;
readonly isClearOrigin: boolean;
readonly isDescendOrigin: boolean;
readonly asDescendOrigin: InteriorMultiLocation;
readonly isReportError: boolean;
readonly asReportError: {
readonly queryId: Compact<u64>;
readonly dest: MultiLocationV2;
readonly maxResponseWeight: Compact<u64>;
} & Struct;
readonly isDepositAsset: boolean;
readonly asDepositAsset: {
readonly assets: MultiAssetFilterV2;
readonly maxAssets: u32;
readonly beneficiary: MultiLocationV2;
} & Struct;
readonly isDepositReserveAsset: boolean;
readonly asDepositReserveAsset: {
readonly assets: MultiAssetFilterV2;
readonly maxAssets: u32;
readonly dest: MultiLocationV2;
readonly xcm: XcmV2;
} & Struct;
readonly isExchangeAsset: boolean;
readonly asExchangeAsset: {
readonly give: MultiAssetFilterV2;
readonly receive: MultiAssetsV2;
} & Struct;
readonly isInitiateReserveWithdraw: boolean;
readonly asInitiateReserveWithdraw: {
readonly assets: MultiAssetFilterV2;
readonly reserve: MultiLocationV2;
readonly xcm: XcmV2;
} & Struct;
readonly isInitiateTeleport: boolean;
readonly asInitiateTeleport: {
readonly assets: MultiAssetFilterV2;
readonly dest: MultiLocationV2;
readonly xcm: XcmV2;
} & Struct;
readonly isQueryHolding: boolean;
readonly asQueryHolding: {
readonly query_id: Compact<u64>;
readonly dest: MultiLocationV2;
readonly assets: MultiAssetFilterV2;
readonly maxResponse_Weight: Compact<u64>;
} & Struct;
readonly isBuyExecution: boolean;
readonly asBuyExecution: {
readonly fees: MultiAssetV2;
readonly weightLimit: WeightLimitV2;
} & Struct;
readonly isRefundSurplus: boolean;
readonly isSetErrorHandler: boolean;
readonly asSetErrorHandler: XcmV2;
readonly isSetAppendix: boolean;
readonly asSetAppendix: XcmV2;
readonly isClearError: boolean;
readonly isClaimAsset: boolean;
readonly asClaimAsset: {
readonly assets: MultiAssetsV2;
readonly ticket: MultiLocationV2;
} & Struct;
readonly isTrap: boolean;
readonly asTrap: u64;
}

/** @name InteriorMultiLocation */
export interface InteriorMultiLocation extends Junctions {}

/** @name Junction */
export interface Junction extends Enum {
readonly isParent: boolean;
Expand Down Expand Up @@ -138,6 +254,27 @@ export interface Junction extends Enum {
} & Struct;
}

/** @name Junctions */
export interface Junctions extends Enum {
readonly isHere: boolean;
readonly isX1: boolean;
readonly asX1: Junction;
readonly isX2: boolean;
readonly asX2: ITuple<[Junction, Junction]>;
readonly isX3: boolean;
readonly asX3: ITuple<[Junction, Junction, Junction]>;
readonly isX4: boolean;
readonly asX4: ITuple<[Junction, Junction, Junction, Junction]>;
readonly isX5: boolean;
readonly asX5: ITuple<[Junction, Junction, Junction, Junction, Junction]>;
readonly isX6: boolean;
readonly asX6: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction]>;
readonly isX7: boolean;
readonly asX7: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction, Junction]>;
readonly isX8: boolean;
readonly asX8: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction]>;
}

/** @name MultiAsset */
export interface MultiAsset extends MultiAssetV1 {}

Expand All @@ -152,6 +289,9 @@ export interface MultiAssetFilterV1 extends Enum {
readonly asWild: WildMultiAssetV1;
}

/** @name MultiAssetFilterV2 */
export interface MultiAssetFilterV2 extends MultiAssetFilterV1 {}

/** @name MultiAssets */
export interface MultiAssets extends Vec<MultiAsset> {}

Expand Down Expand Up @@ -207,34 +347,19 @@ export interface MultiAssetV1 extends Struct {
export interface MultiAssetV2 extends MultiAssetV1 {}

/** @name MultiLocation */
export interface MultiLocation extends Enum {
readonly isHere: boolean;
readonly isX1: boolean;
readonly asX1: Junction;
readonly isX2: boolean;
readonly asX2: ITuple<[Junction, Junction]>;
readonly isX3: boolean;
readonly asX3: ITuple<[Junction, Junction, Junction]>;
readonly isX4: boolean;
readonly asX4: ITuple<[Junction, Junction, Junction, Junction]>;
readonly isX5: boolean;
readonly asX5: ITuple<[Junction, Junction, Junction, Junction, Junction]>;
readonly isX6: boolean;
readonly asX6: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction]>;
readonly isX7: boolean;
readonly asX7: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction, Junction]>;
readonly isX8: boolean;
readonly asX8: ITuple<[Junction, Junction, Junction, Junction, Junction, Junction, Junction, Junction]>;
}
export interface MultiLocation extends Junctions {}

/** @name MultiLocationV0 */
export interface MultiLocationV0 extends MultiLocation {}

/** @name MultiLocationV1 */
export interface MultiLocationV1 extends MultiLocation {}
export interface MultiLocationV1 extends Struct {
readonly parents: u8;
readonly interior: Junctions;
}

/** @name MultiLocationV2 */
export interface MultiLocationV2 extends MultiLocation {}
export interface MultiLocationV2 extends MultiLocationV1 {}

/** @name NetworkId */
export interface NetworkId extends Enum {
Expand All @@ -245,6 +370,20 @@ export interface NetworkId extends Enum {
readonly isKusama: boolean;
}

/** @name OriginKindV0 */
export interface OriginKindV0 extends Enum {
readonly isNative: boolean;
readonly isSovereignAccount: boolean;
readonly isSuperuser: boolean;
readonly isXcm: boolean;
}

/** @name OriginKindV1 */
export interface OriginKindV1 extends OriginKindV0 {}

/** @name OriginKindV2 */
export interface OriginKindV2 extends OriginKindV1 {}

/** @name OutboundStatus */
export interface OutboundStatus extends Enum {
readonly isOk: boolean;
Expand Down Expand Up @@ -369,6 +508,8 @@ export interface VersionedXcm extends Enum {
readonly asV0: XcmV0;
readonly isV1: boolean;
readonly asV1: XcmV1;
readonly isV2: boolean;
readonly asV2: XcmV2;
}

/** @name VersionMigrationStage */
Expand All @@ -380,6 +521,13 @@ export interface VersionMigrationStage extends Enum {
readonly isMigrateAndNotifyOldTargets: boolean;
}

/** @name WeightLimitV2 */
export interface WeightLimitV2 extends Enum {
readonly isUnlimited: boolean;
readonly isLimited: boolean;
readonly asLimited: Compact<u64>;
}

/** @name WildFungibility */
export interface WildFungibility extends Enum {
readonly isFungible: boolean;
Expand Down Expand Up @@ -764,6 +912,9 @@ export interface XcmV1 extends Enum {
} & Struct;
}

/** @name XcmV2 */
export interface XcmV2 extends Vec<InstructionV2> {}

/** @name XcmVersion */
export interface XcmVersion extends u32 {}

Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/interfaces/xcm/v0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export const v0: DefinitionsTypes = {
}
},
MultiLocationV0: 'MultiLocation',
OriginKindV0: {
_enum: ['Native', 'SovereignAccount', 'Superuser', 'Xcm']
},
ResponseV0: {
_enum: {
Assets: 'Vec<MultiAssetV0>'
Expand Down
6 changes: 5 additions & 1 deletion packages/types/src/interfaces/xcm/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export const v1: DefinitionsTypes = {
Wild: 'WildMultiAssetV1'
}
},
MultiLocationV1: 'MultiLocation',
MultiLocationV1: {
parents: 'u8',
interior: 'Junctions'
},
OriginKindV1: 'OriginKindV0',
ResponseV1: {
_enum: {
Assets: 'MultiAssetsV1'
Expand Down
Loading