diff --git a/packages/types/src/interfaces/xcm/definitions.ts b/packages/types/src/interfaces/xcm/definitions.ts index 2d33defbd6..9c41e71039 100644 --- a/packages/types/src/interfaces/xcm/definitions.ts +++ b/packages/types/src/interfaces/xcm/definitions.ts @@ -6,6 +6,10 @@ import type { Definitions } from '../../types'; +import { v0 } from './v0'; +import { v1 } from './v1'; +import { v2 } from './v2'; + const xcm = { XcmOrigin: { _enum: { @@ -13,301 +17,10 @@ const xcm = { } }, Xcm: 'XcmV1', - XcmV0: { - _enum: { - WithdrawAsset: { - assets: 'Vec', - effects: 'Vec' - }, - ReserveAssetDeposit: { - assets: 'Vec', - effects: 'Vec' - }, - ReceiveTeleportedAsset: { - assets: 'Vec', - effects: 'Vec' - }, - QueryResponse: { - queryId: 'Compact', - response: 'ResponseV0' - }, - TransferAsset: { - assets: 'Vec', - dest: 'MultiLocationV0' - }, - TransferReserveAsset: { - assets: 'Vec', - dest: 'MultiLocationV0', - effects: 'Vec' - }, - Transact: { - originType: 'XcmOriginKind', - requireWeightAtMost: 'u64', - call: 'DoubleEncodedCall' - }, - HrmpNewChannelOpenRequest: { - sender: 'Compact', - maxMessageSize: 'Compact', - maxCapacity: 'Compact' - }, - HrmpChannelAccepted: { - recipient: 'Compact' - }, - HrmpChannelClosing: { - initiator: 'Compact', - sender: 'Compact', - recipient: 'Compact' - }, - RelayedFrom: { - who: 'MultiLocationV0', - message: 'XcmV0' - } - } - }, - XcmV1: { - _enum: { - WithdrawAsset: { - Vassets: 'MultiAssetsV1', - effects: 'Vec' - }, - ReserveAssetDeposit: { - Vassets: 'MultiAssetsV1', - effects: 'Vec' - }, - ReceiveTeleportedAsset: { - Vassets: 'MultiAssetsV1', - effects: 'Vec' - }, - QueryResponse: { - queryId: 'Compact', - response: 'ResponseV1' - }, - TransferAsset: { - Vassets: 'MultiAssetsV1', - dest: 'MultiLocationV1' - }, - TransferReserveAsset: { - Vassets: 'MultiAssetsV1', - dest: 'MultiLocationV1', - effects: 'Vec' - }, - Transact: { - originType: 'XcmOriginKind', - requireWeightAtMost: 'u64', - call: 'DoubleEncodedCall' - }, - HrmpNewChannelOpenRequest: { - sender: 'Compact', - maxMessageSize: 'Compact', - maxCapacity: 'Compact' - }, - HrmpChannelAccepted: { - recipient: 'Compact' - }, - HrmpChannelClosing: { - initiator: 'Compact', - sender: 'Compact', - recipient: 'Compact' - }, - RelayedFrom: { - who: 'MultiLocationV1', - message: 'XcmV1' - } - } - }, - XcmErrorV0: { - _enum: { - Undefined: 'Null', - Overflow: 'Null', - Unimplemented: 'Null', - UnhandledXcmVersion: 'Null', - UnhandledXcmMessage: 'Null', - UnhandledEffect: 'Null', - EscalationOfPrivilege: 'Null', - UntrustedReserveLocation: 'Null', - UntrustedTeleportLocation: 'Null', - DestinationBufferOverflow: 'Null', - SendFailed: 'Null', - CannotReachDestination: '(MultiLocation, Xcm)', - MultiLocationFull: 'Null', - FailedToDecode: 'Null', - BadOrigin: 'Null', - ExceedsMaxMessageSize: 'Null', - FailedToTransactAsset: 'Null', - WeightLimitReached: 'Weight', - Wildcard: 'Null', - TooMuchWeightRequired: 'Null', - NotHoldingFees: 'Null', - WeightNotComputable: 'Null', - Barrier: 'Null', - NotWithdrawable: 'Null', - LocationCannotHold: 'Null', - TooExpensive: 'Null' - } - }, - XcmErrorV1: { - _enum: { - Undefined: 'Null', - Overflow: 'Null', - Unimplemented: 'Null', - UnhandledXcmVersion: 'Null', - UnhandledXcmMessage: 'Null', - UnhandledEffect: 'Null', - EscalationOfPrivilege: 'Null', - UntrustedReserveLocation: 'Null', - UntrustedTeleportLocation: 'Null', - DestinationBufferOverflow: 'Null', - SendFailed: 'Null', - CannotReachDestination: '(MultiLocationV1, XcmV1)', - MultiLocationFull: 'Null', - FailedToDecode: 'Null', - BadOrigin: 'Null', - ExceedsMaxMessageSize: 'Null', - FailedToTransactAsset: 'Null', - WeightLimitReached: 'Weight', - Wildcard: 'Null', - TooMuchWeightRequired: 'Null', - NotHoldingFees: 'Null', - WeightNotComputable: 'Null', - Barrier: 'Null', - NotWithdrawable: 'Null', - LocationCannotHold: 'Null', - TooExpensive: 'Null', - AssetNotFound: 'Null', - DestinationUnsupported: 'Null', - RecursionLimitReached: 'Null' - } - }, - XcmErrorV2: { - _enum: { - Undefined: 'Null', - Overflow: 'Null', - Unimplemented: 'Null', - UnhandledXcmVersion: 'Null', - UnhandledXcmMessage: 'Null', - UnhandledEffect: 'Null', - EscalationOfPrivilege: 'Null', - UntrustedReserveLocation: 'Null', - UntrustedTeleportLocation: 'Null', - DestinationBufferOverflow: 'Null', - MultiLocationFull: 'Null', - MultiLocationNotInvertible: 'Null', - FailedToDecode: 'Null', - BadOrigin: 'Null', - ExceedsMaxMessageSize: 'Null', - FailedToTransactAsset: 'Null', - WeightLimitReached: 'Weight', - Wildcard: 'Null', - TooMuchWeightRequired: 'Null', - NotHoldingFees: 'Null', - WeightNotComputable: 'Null', - Barrier: 'Null', - NotWithdrawable: 'Null', - LocationCannotHold: 'Null', - TooExpensive: 'Null', - AssetNotFound: 'Null', - DestinationUnsupported: 'Null', - RecursionLimitReached: 'Null', - Transport: 'Null', - Unroutable: 'Null', - UnknownWeightRequired: 'Null', - Trap: 'u64', - UnknownClaim: 'Null' - } - }, XcmpMessageFormat: { _enum: ['ConcatenatedVersionedXcm', 'ConcatenatedEncodedBlob', 'Signals'] - } -}; - -const xmcOrder = { - XcmOrder: 'XcmOrderV1', - XcmOrderV0: { - _enum: { - Null: 'Null', - DepositAsset: { - assets: 'Vec', - dest: 'MultiLocationV0' - }, - DepositReserveAsset: { - assets: 'Vec', - dest: 'MultiLocationV0', - effects: 'Vec' - }, - ExchangeAsset: { - give: 'Vec', - receive: 'Vec' - }, - InitiateReserveWithdraw: { - assets: 'Vec', - reserve: 'MultiLocationV0', - effects: 'Vec' - }, - InitiateTeleport: { - assets: 'Vec', - dest: 'MultiLocationV0', - effects: 'Vec' - }, - QueryHolding: { - queryId: 'Compact', - dest: 'MultiLocationV0', - assets: 'Vec' - }, - BuyExecution: { - fees: 'MultiAsset', - weight: 'u64', - debt: 'u64', - haltOnError: 'bool', - xcm: 'Vec' - } - } }, - XcmOrderV1: { - _enum: { - Noop: 'Null', - DepositAsset: { - assets: 'MultiAssetFilterV1', - maxAssets: 'u32', - beneficiary: 'MultiLocationV1' - }, - DepositReserveAsset: { - assets: 'MultiAssetFilterV1', - maxAssets: 'u32', - dest: 'MultiLocationV1', - effects: 'Vec' - }, - ExchangeAsset: { - give: 'MultiAssetFilterV1', - receive: 'MultiAssetsV1' - }, - InitiateReserveWithdraw: { - assets: 'MultiAssetFilterV1', - reserve: 'MultiLocationV1', - effects: 'Vec' - }, - InitiateTeleport: { - assets: 'MultiAssetFilterV1', - dest: 'MultiLocationV1', - effects: 'Vec' - }, - QueryHolding: { - queryId: 'Compact', - dest: 'MultiLocationV1', - assets: 'MultiAssetFilterV1' - }, - BuyExecution: { - fees: 'MultiAsset', - weight: 'u64', - debt: 'u64', - haltOnError: 'bool', - orders: 'Vec', - instructions: 'Vec' - } - } - } -}; - -const multiAsset = { + XcmOrder: 'XcmOrderV1', XcmAssetId: { _enum: { Concrete: 'MultiLocation', @@ -315,32 +28,6 @@ const multiAsset = { } }, AssetInstance: 'AssetInstanceV1', - AssetInstanceV0: { - _enum: { - Undefined: 'Null', - Index8: 'u8', - Index16: 'Compact', - Index32: 'Compact', - Index64: 'Compact', - Index128: 'Compact', - Array4: '[u8; 4]', - Array8: '[u8; 8]', - Array16: '[u8; 16]', - Array32: '[u8; 32]', - Blob: 'Vec' - } - }, - AssetInstanceV1: { - _enum: { - Undefined: 'Null', - Index: 'Compact', - Array4: '[u8; 4]', - Array8: '[u8; 8]', - Array16: '[u8; 16]', - Array32: '[u8; 32]', - Blob: 'Bytes' - } - }, Fungibility: { _enum: { Fungible: 'u128', @@ -354,62 +41,12 @@ const multiAsset = { _enum: ['Ok', 'Suspended'] }, MultiAssetFilter: 'MultiAssetFilterV1', - MultiAssetFilterV1: { - _enum: { - Definite: 'MultiAssetsV1', - Wild: 'WildMultiAssetV1' - } - }, MultiAsset: 'MultiAssetV1', - MultiAssetV0: { - _enum: { - None: 'Null', - All: 'Null', - AllFungible: 'Null', - AllNonFungible: 'Null', - AllAbstractFungible: 'Vec', - AllAbstractNonFungible: 'Vec', - AllConcreteFungible: 'MultiLocationV0', - AllConcreteNonFungible: 'MultiLocationV0', - AbstractFungible: { - id: 'Vec', - instance: 'Compact' - }, - AbstractNonFungible: { - class: 'Vec', - instance: 'AssetInstanceV0' - }, - ConcreteFungible: { - id: 'MultiLocationV0', - amount: 'Compact' - }, - ConcreteNonFungible: { - class: 'MultiLocationV0', - instance: 'AssetInstanceV0' - } - } - }, - MultiAssetV1: { - id: 'XcmAssetId', - fungibility: 'Fungibility' - }, - MultiAssetV2: 'MultiAssetV1', MultiAssets: 'Vec', - MultiAssetsV1: 'Vec', - MultiAssetsV2: 'MultiAssetsV1', WildFungibility: { _enum: ['Fungible', 'NonFungible'] }, - WildMultiAsset: 'WildMultiAssetV1', - WildMultiAssetV1: { - _enum: { - All: 'Null', - AllOf: { - id: 'XcmAssetId', - fungibility: 'WildFungibility' - } - } - } + WildMultiAsset: 'WildMultiAssetV1' }; const location = { @@ -495,9 +132,10 @@ export default { rpc: {}, types: { ...location, - ...multiAsset, ...xcm, - ...xmcOrder, + ...v0, + ...v1, + ...v2, DoubleEncodedCall: { encoded: 'Vec' }, @@ -505,28 +143,6 @@ export default { _enum: ['Native', 'SovereignAccount', 'Superuser', 'Xcm'] }, Response: 'ResponseV1', - ResponseV0: { - _enum: { - Assets: 'Vec' - } - }, - ResponseV1: { - _enum: { - Assets: 'MultiAssetsV1' - } - }, - ResponseV2: { - _enum: { - Null: 'Null', - Assets: 'MultiAssetsV2', - ExecutionResult: 'ResponseV2Result' - } - }, - ResponseV2Error: '(u32, XcmErrorV2)', - ResponseV2Result: 'Result', - MultiLocationV0: 'MultiLocation', - MultiLocationV1: 'MultiLocation', - MultiLocationV2: 'MultiLocation', Outcome: { _enum: { Complete: 'Weight', diff --git a/packages/types/src/interfaces/xcm/v0.ts b/packages/types/src/interfaces/xcm/v0.ts new file mode 100644 index 0000000000..e1d8c67b67 --- /dev/null +++ b/packages/types/src/interfaces/xcm/v0.ts @@ -0,0 +1,180 @@ +// Copyright 2017-2021 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// order important in structs... :) +/* eslint-disable sort-keys */ + +import type { DefinitionsTypes } from '../../types'; + +export const v0: DefinitionsTypes = { + AssetInstanceV0: { + _enum: { + Undefined: 'Null', + Index8: 'u8', + Index16: 'Compact', + Index32: 'Compact', + Index64: 'Compact', + Index128: 'Compact', + Array4: '[u8; 4]', + Array8: '[u8; 8]', + Array16: '[u8; 16]', + Array32: '[u8; 32]', + Blob: 'Vec' + } + }, + MultiAssetV0: { + _enum: { + None: 'Null', + All: 'Null', + AllFungible: 'Null', + AllNonFungible: 'Null', + AllAbstractFungible: 'Vec', + AllAbstractNonFungible: 'Vec', + AllConcreteFungible: 'MultiLocationV0', + AllConcreteNonFungible: 'MultiLocationV0', + AbstractFungible: { + id: 'Vec', + instance: 'Compact' + }, + AbstractNonFungible: { + class: 'Vec', + instance: 'AssetInstanceV0' + }, + ConcreteFungible: { + id: 'MultiLocationV0', + amount: 'Compact' + }, + ConcreteNonFungible: { + class: 'MultiLocationV0', + instance: 'AssetInstanceV0' + } + } + }, + MultiLocationV0: 'MultiLocation', + ResponseV0: { + _enum: { + Assets: 'Vec' + } + }, + XcmV0: { + _enum: { + WithdrawAsset: { + assets: 'Vec', + effects: 'Vec' + }, + ReserveAssetDeposit: { + assets: 'Vec', + effects: 'Vec' + }, + ReceiveTeleportedAsset: { + assets: 'Vec', + effects: 'Vec' + }, + QueryResponse: { + queryId: 'Compact', + response: 'ResponseV0' + }, + TransferAsset: { + assets: 'Vec', + dest: 'MultiLocationV0' + }, + TransferReserveAsset: { + assets: 'Vec', + dest: 'MultiLocationV0', + effects: 'Vec' + }, + Transact: { + originType: 'XcmOriginKind', + requireWeightAtMost: 'u64', + call: 'DoubleEncodedCall' + }, + HrmpNewChannelOpenRequest: { + sender: 'Compact', + maxMessageSize: 'Compact', + maxCapacity: 'Compact' + }, + HrmpChannelAccepted: { + recipient: 'Compact' + }, + HrmpChannelClosing: { + initiator: 'Compact', + sender: 'Compact', + recipient: 'Compact' + }, + RelayedFrom: { + who: 'MultiLocationV0', + message: 'XcmV0' + } + } + }, + XcmErrorV0: { + _enum: { + Undefined: 'Null', + Overflow: 'Null', + Unimplemented: 'Null', + UnhandledXcmVersion: 'Null', + UnhandledXcmMessage: 'Null', + UnhandledEffect: 'Null', + EscalationOfPrivilege: 'Null', + UntrustedReserveLocation: 'Null', + UntrustedTeleportLocation: 'Null', + DestinationBufferOverflow: 'Null', + SendFailed: 'Null', + CannotReachDestination: '(MultiLocation, Xcm)', + MultiLocationFull: 'Null', + FailedToDecode: 'Null', + BadOrigin: 'Null', + ExceedsMaxMessageSize: 'Null', + FailedToTransactAsset: 'Null', + WeightLimitReached: 'Weight', + Wildcard: 'Null', + TooMuchWeightRequired: 'Null', + NotHoldingFees: 'Null', + WeightNotComputable: 'Null', + Barrier: 'Null', + NotWithdrawable: 'Null', + LocationCannotHold: 'Null', + TooExpensive: 'Null' + } + }, + XcmOrderV0: { + _enum: { + Null: 'Null', + DepositAsset: { + assets: 'Vec', + dest: 'MultiLocationV0' + }, + DepositReserveAsset: { + assets: 'Vec', + dest: 'MultiLocationV0', + effects: 'Vec' + }, + ExchangeAsset: { + give: 'Vec', + receive: 'Vec' + }, + InitiateReserveWithdraw: { + assets: 'Vec', + reserve: 'MultiLocationV0', + effects: 'Vec' + }, + InitiateTeleport: { + assets: 'Vec', + dest: 'MultiLocationV0', + effects: 'Vec' + }, + QueryHolding: { + queryId: 'Compact', + dest: 'MultiLocationV0', + assets: 'Vec' + }, + BuyExecution: { + fees: 'MultiAsset', + weight: 'u64', + debt: 'u64', + haltOnError: 'bool', + xcm: 'Vec' + } + } + } +}; diff --git a/packages/types/src/interfaces/xcm/v1.ts b/packages/types/src/interfaces/xcm/v1.ts new file mode 100644 index 0000000000..8b334a544b --- /dev/null +++ b/packages/types/src/interfaces/xcm/v1.ts @@ -0,0 +1,174 @@ +// Copyright 2017-2021 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// order important in structs... :) +/* eslint-disable sort-keys */ + +import type { DefinitionsTypes } from '../../types'; + +export const v1: DefinitionsTypes = { + AssetInstanceV1: { + _enum: { + Undefined: 'Null', + Index: 'Compact', + Array4: '[u8; 4]', + Array8: '[u8; 8]', + Array16: '[u8; 16]', + Array32: '[u8; 32]', + Blob: 'Bytes' + } + }, + MultiAssetsV1: 'Vec', + MultiAssetV1: { + id: 'XcmAssetId', + fungibility: 'Fungibility' + }, + MultiAssetFilterV1: { + _enum: { + Definite: 'MultiAssetsV1', + Wild: 'WildMultiAssetV1' + } + }, + MultiLocationV1: 'MultiLocation', + ResponseV1: { + _enum: { + Assets: 'MultiAssetsV1' + } + }, + WildMultiAssetV1: { + _enum: { + All: 'Null', + AllOf: { + id: 'XcmAssetId', + fungibility: 'WildFungibility' + } + } + }, + XcmV1: { + _enum: { + WithdrawAsset: { + Vassets: 'MultiAssetsV1', + effects: 'Vec' + }, + ReserveAssetDeposit: { + Vassets: 'MultiAssetsV1', + effects: 'Vec' + }, + ReceiveTeleportedAsset: { + Vassets: 'MultiAssetsV1', + effects: 'Vec' + }, + QueryResponse: { + queryId: 'Compact', + response: 'ResponseV1' + }, + TransferAsset: { + Vassets: 'MultiAssetsV1', + dest: 'MultiLocationV1' + }, + TransferReserveAsset: { + Vassets: 'MultiAssetsV1', + dest: 'MultiLocationV1', + effects: 'Vec' + }, + Transact: { + originType: 'XcmOriginKind', + requireWeightAtMost: 'u64', + call: 'DoubleEncodedCall' + }, + HrmpNewChannelOpenRequest: { + sender: 'Compact', + maxMessageSize: 'Compact', + maxCapacity: 'Compact' + }, + HrmpChannelAccepted: { + recipient: 'Compact' + }, + HrmpChannelClosing: { + initiator: 'Compact', + sender: 'Compact', + recipient: 'Compact' + }, + RelayedFrom: { + who: 'MultiLocationV1', + message: 'XcmV1' + } + } + }, + XcmErrorV1: { + _enum: { + Undefined: 'Null', + Overflow: 'Null', + Unimplemented: 'Null', + UnhandledXcmVersion: 'Null', + UnhandledXcmMessage: 'Null', + UnhandledEffect: 'Null', + EscalationOfPrivilege: 'Null', + UntrustedReserveLocation: 'Null', + UntrustedTeleportLocation: 'Null', + DestinationBufferOverflow: 'Null', + SendFailed: 'Null', + CannotReachDestination: '(MultiLocationV1, XcmV1)', + MultiLocationFull: 'Null', + FailedToDecode: 'Null', + BadOrigin: 'Null', + ExceedsMaxMessageSize: 'Null', + FailedToTransactAsset: 'Null', + WeightLimitReached: 'Weight', + Wildcard: 'Null', + TooMuchWeightRequired: 'Null', + NotHoldingFees: 'Null', + WeightNotComputable: 'Null', + Barrier: 'Null', + NotWithdrawable: 'Null', + LocationCannotHold: 'Null', + TooExpensive: 'Null', + AssetNotFound: 'Null', + DestinationUnsupported: 'Null', + RecursionLimitReached: 'Null' + } + }, + XcmOrderV1: { + _enum: { + Noop: 'Null', + DepositAsset: { + assets: 'MultiAssetFilterV1', + maxAssets: 'u32', + beneficiary: 'MultiLocationV1' + }, + DepositReserveAsset: { + assets: 'MultiAssetFilterV1', + maxAssets: 'u32', + dest: 'MultiLocationV1', + effects: 'Vec' + }, + ExchangeAsset: { + give: 'MultiAssetFilterV1', + receive: 'MultiAssetsV1' + }, + InitiateReserveWithdraw: { + assets: 'MultiAssetFilterV1', + reserve: 'MultiLocationV1', + effects: 'Vec' + }, + InitiateTeleport: { + assets: 'MultiAssetFilterV1', + dest: 'MultiLocationV1', + effects: 'Vec' + }, + QueryHolding: { + queryId: 'Compact', + dest: 'MultiLocationV1', + assets: 'MultiAssetFilterV1' + }, + BuyExecution: { + fees: 'MultiAsset', + weight: 'u64', + debt: 'u64', + haltOnError: 'bool', + orders: 'Vec', + instructions: 'Vec' + } + } + } +}; diff --git a/packages/types/src/interfaces/xcm/v2.ts b/packages/types/src/interfaces/xcm/v2.ts new file mode 100644 index 0000000000..47614f5c30 --- /dev/null +++ b/packages/types/src/interfaces/xcm/v2.ts @@ -0,0 +1,59 @@ +// Copyright 2017-2021 @polkadot/types authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// order important in structs... :) +/* eslint-disable sort-keys */ + +import type { DefinitionsTypes } from '../../types'; + +export const v2: DefinitionsTypes = { + MultiAssetsV2: 'MultiAssetsV1', + MultiAssetV2: 'MultiAssetV1', + MultiLocationV2: 'MultiLocation', + ResponseV2: { + _enum: { + Null: 'Null', + Assets: 'MultiAssetsV2', + ExecutionResult: 'ResponseV2Result' + } + }, + ResponseV2Error: '(u32, XcmErrorV2)', + ResponseV2Result: 'Result', + XcmErrorV2: { + _enum: { + Undefined: 'Null', + Overflow: 'Null', + Unimplemented: 'Null', + UnhandledXcmVersion: 'Null', + UnhandledXcmMessage: 'Null', + UnhandledEffect: 'Null', + EscalationOfPrivilege: 'Null', + UntrustedReserveLocation: 'Null', + UntrustedTeleportLocation: 'Null', + DestinationBufferOverflow: 'Null', + MultiLocationFull: 'Null', + MultiLocationNotInvertible: 'Null', + FailedToDecode: 'Null', + BadOrigin: 'Null', + ExceedsMaxMessageSize: 'Null', + FailedToTransactAsset: 'Null', + WeightLimitReached: 'Weight', + Wildcard: 'Null', + TooMuchWeightRequired: 'Null', + NotHoldingFees: 'Null', + WeightNotComputable: 'Null', + Barrier: 'Null', + NotWithdrawable: 'Null', + LocationCannotHold: 'Null', + TooExpensive: 'Null', + AssetNotFound: 'Null', + DestinationUnsupported: 'Null', + RecursionLimitReached: 'Null', + Transport: 'Null', + Unroutable: 'Null', + UnknownWeightRequired: 'Null', + Trap: 'u64', + UnknownClaim: 'Null' + } + } +};