diff --git a/packages/api-base/src/types/submittable.ts b/packages/api-base/src/types/submittable.ts index aa48f83ad474..36265a7ead9b 100644 --- a/packages/api-base/src/types/submittable.ts +++ b/packages/api-base/src/types/submittable.ts @@ -16,7 +16,7 @@ export interface SignerOptions { nonce: AnyNumber | Codec; signer?: Signer; tip?: AnyNumber; - assetId?: AnyNumber; + assetId?: AnyNumber | object; } export type SubmittableDryRunResult = diff --git a/packages/types-augment/src/registry/interfaces.ts b/packages/types-augment/src/registry/interfaces.ts index 9f4da75a9f79..3fab113a7275 100644 --- a/packages/types-augment/src/registry/interfaces.ts +++ b/packages/types-augment/src/registry/interfaces.ts @@ -7,6 +7,7 @@ import '@polkadot/types/types/registry'; import type { Data, StorageKey } from '@polkadot/types'; import type { BitVec, Bool, Bytes, F32, F64, I128, I16, I256, I32, I64, I8, ISize, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, f32, f64, i128, i16, i256, i32, i64, i8, isize, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec'; +import type { TAssetConversion } from '@polkadot/types/interfaces/assetConversion'; import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets'; import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations'; import type { RawAuraPreDigest } from '@polkadot/types/interfaces/aura'; @@ -1092,6 +1093,7 @@ declare module '@polkadot/types/types/registry' { Tally: Tally; TaskAddress: TaskAddress; TAssetBalance: TAssetBalance; + TAssetConversion: TAssetConversion; TAssetDepositBalance: TAssetDepositBalance; Text: Text; Timepoint: Timepoint; diff --git a/packages/types-known/src/spec/index.ts b/packages/types-known/src/spec/index.ts index 619aa771995a..c6c63ab4d9a1 100644 --- a/packages/types-known/src/spec/index.ts +++ b/packages/types-known/src/spec/index.ts @@ -10,8 +10,10 @@ import { versioned as nodeTemplate } from './node-template.js'; import { versioned as polkadot } from './polkadot.js'; import { versioned as rococo } from './rococo.js'; import { versioned as shell } from './shell.js'; +import { versioned as statemine } from './statemine.js'; import { versioned as statemint } from './statemint.js'; import { versioned as westend } from './westend.js'; +import { versioned as westmint } from './westmint.js'; // Type overrides for specific spec types & versions as given in runtimeVersion export const typesSpec: Record = { @@ -22,8 +24,8 @@ export const typesSpec: Record = { polkadot, rococo, shell, - statemine: statemint, + statemine, statemint, westend, - westmint: statemint + westmint }; diff --git a/packages/types-known/src/spec/statemine.ts b/packages/types-known/src/spec/statemine.ts new file mode 100644 index 000000000000..b0d4f3f6df43 --- /dev/null +++ b/packages/types-known/src/spec/statemine.ts @@ -0,0 +1,62 @@ +// Copyright 2017-2023 @polkadot/types-known authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +/* eslint-disable sort-keys */ + +import type { OverrideVersionedType } from '@polkadot/types/types'; + +import { mapXcmTypes } from '@polkadot/types-create'; + +const sharedTypes = { + DispatchErrorModule: 'DispatchErrorModuleU8', + TAssetBalance: 'u128', + ProxyType: { + _enum: [ + 'Any', + 'NonTransfer', + 'CancelProxy', + 'Assets', + 'AssetOwner', + 'AssetManager', + 'Staking' + ] + }, + Weight: 'WeightV1' +}; + +// these are override types for Statemine, Westmint +export const versioned: OverrideVersionedType[] = [ + { + minmax: [0, 3], + types: { + // Enum was modified mid-flight - + // https://github.com/paritytech/substrate/pull/10382/files#diff-e4e016b33a82268b6208dc974eea841bad47597865a749fee2f937eb6fdf67b4R498 + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V0') + } + }, + { + minmax: [4, 5], + types: { + // As above, see https://github.com/polkadot-js/api/issues/5301 + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V1') + } + }, + { + // metadata V14 + minmax: [500, 9999], + types: { + Weight: 'WeightV1', + TAssetConversion: 'Option' + } + }, + { + minmax: [10000, undefined], + types: { + Weight: 'WeightV1' + } + } +]; diff --git a/packages/types-known/src/spec/statemint.ts b/packages/types-known/src/spec/statemint.ts index 9036c42fd377..e93a3aa06ae0 100644 --- a/packages/types-known/src/spec/statemint.ts +++ b/packages/types-known/src/spec/statemint.ts @@ -49,7 +49,8 @@ export const versioned: OverrideVersionedType[] = [ // metadata V14 minmax: [500, undefined], types: { - Weight: 'WeightV1' + Weight: 'WeightV1', + TAssetConversion: 'Option' } } // , diff --git a/packages/types-known/src/spec/westmint.ts b/packages/types-known/src/spec/westmint.ts new file mode 100644 index 000000000000..7d8dde1cb58b --- /dev/null +++ b/packages/types-known/src/spec/westmint.ts @@ -0,0 +1,62 @@ +// Copyright 2017-2023 @polkadot/types-known authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +/* eslint-disable sort-keys */ + +import type { OverrideVersionedType } from '@polkadot/types/types'; + +import { mapXcmTypes } from '@polkadot/types-create'; + +const sharedTypes = { + DispatchErrorModule: 'DispatchErrorModuleU8', + TAssetBalance: 'u128', + ProxyType: { + _enum: [ + 'Any', + 'NonTransfer', + 'CancelProxy', + 'Assets', + 'AssetOwner', + 'AssetManager', + 'Staking' + ] + }, + Weight: 'WeightV1' +}; + +// these are override types for Statemine, Westmint +export const versioned: OverrideVersionedType[] = [ + { + minmax: [0, 3], + types: { + // Enum was modified mid-flight - + // https://github.com/paritytech/substrate/pull/10382/files#diff-e4e016b33a82268b6208dc974eea841bad47597865a749fee2f937eb6fdf67b4R498 + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V0') + } + }, + { + minmax: [4, 5], + types: { + // As above, see https://github.com/polkadot-js/api/issues/5301 + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V1') + } + }, + { + // metadata V14 + minmax: [500, 9434], + types: { + Weight: 'WeightV1', + TAssetConversion: 'Option' + } + }, + { + minmax: [9435, undefined], + types: { + Weight: 'WeightV1' + } + } +]; diff --git a/packages/types/src/extrinsic/SignerPayload.spec.ts b/packages/types/src/extrinsic/SignerPayload.spec.ts index 55d681b19816..a0f0f35058e8 100644 --- a/packages/types/src/extrinsic/SignerPayload.spec.ts +++ b/packages/types/src/extrinsic/SignerPayload.spec.ts @@ -61,7 +61,10 @@ describe('SignerPayload', (): void => { }); it('handles Option correctly', (): void => { - const test = new SignerPayload(registry, { assetId: 123 }); + const test = new SignerPayload(registry, { + // eslint-disable-next-line sort-keys + assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } } + }); expect( [...test.keys()].includes('assetId') @@ -70,12 +73,18 @@ describe('SignerPayload', (): void => { expect( // @ts-expect-error We don't have getters for this field test.toPayload().assetId - ).toEqual(123); + ).toEqual({ + // eslint-disable-next-line sort-keys + parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } + }); expect( // @ts-expect-error We don't have getters for this field new SignerPayload(registry, { assetId: 0 }).toPayload().assetId - ).toEqual(0); + ).toEqual({ + // eslint-disable-next-line sort-keys + parents: 0, interior: { here: null } + }); expect( // @ts-expect-error We don't have getters for this field @@ -105,7 +114,11 @@ describe('SignerPayload', (): void => { }); it('can be used as a feed to ExtrinsicPayload', (): void => { - const signer = new SignerPayload(registry, { ...TEST, assetId: 123 }).toPayload(); + const signer = new SignerPayload(registry, { + ...TEST, + // eslint-disable-next-line sort-keys + assetId: { parents: 0, interior: { x2: [{ palletInstance: 50 }, { generalIndex: 123 }] } } + }).toPayload(); const payload = registry.createType('ExtrinsicPayload', signer, { version: signer.version }); expect(payload.era.toHex()).toEqual(TEST.era); @@ -114,6 +127,10 @@ describe('SignerPayload', (): void => { expect(payload.nonce.eq(TEST.nonce)).toBe(true); expect(payload.tip.eq(TEST.tip)).toBe(true); // @ts-expect-error assetId is of unknown type, so we don't know about "isSome" - expect(payload.inner?.get('assetId')?.isSome && payload.inner?.get('assetId')?.eq(123)).toBe(true); + expect(payload.inner?.get('assetId')?.isSome && payload.inner?.get('assetId') + ?.eq(registry.createType('MultiLocation', { + // eslint-disable-next-line sort-keys + parents: 0, interior: { X2: [{ palletInstance: 50 }, { generalIndex: 123 }] } + }))).toBe(true); }); }); diff --git a/packages/types/src/extrinsic/signedExtensions/statemint.ts b/packages/types/src/extrinsic/signedExtensions/statemint.ts index baad6fea7768..ae483a4d9828 100644 --- a/packages/types/src/extrinsic/signedExtensions/statemint.ts +++ b/packages/types/src/extrinsic/signedExtensions/statemint.ts @@ -8,7 +8,7 @@ export const statemint: ExtDef = { extrinsic: { tip: 'Compact', // eslint-disable-next-line sort-keys - assetId: 'Option' + assetId: 'TAssetConversion' }, payload: {} } diff --git a/packages/types/src/interfaces/assetConversion/definitions.ts b/packages/types/src/interfaces/assetConversion/definitions.ts index 391dc8020b2e..71dd913ab2ae 100644 --- a/packages/types/src/interfaces/assetConversion/definitions.ts +++ b/packages/types/src/interfaces/assetConversion/definitions.ts @@ -11,5 +11,7 @@ import { runtime } from './runtime.js'; export default { rpc: {}, runtime, - types: {} + types: { + TAssetConversion: 'Option' + } } as Definitions; diff --git a/packages/types/src/interfaces/assetConversion/types.ts b/packages/types/src/interfaces/assetConversion/types.ts index 1061fc47b6c7..c10fa76833f1 100644 --- a/packages/types/src/interfaces/assetConversion/types.ts +++ b/packages/types/src/interfaces/assetConversion/types.ts @@ -1,4 +1,10 @@ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit /* eslint-disable */ +import type { Option } from '@polkadot/types-codec'; +import type { MultiLocation } from '@polkadot/types/interfaces/xcm'; + +/** @name TAssetConversion */ +export interface TAssetConversion extends Option {} + export type PHANTOM_ASSETCONVERSION = 'assetConversion';