Support for metadata v13 (#3465)

* Support for metadata v13

* Lint fixes

* Lastest tag as string

* Documentation

* MagicNumber opt

* NMap enum entry

* NMapTypeLatest

* Adjust for NMap type overrides

* Static from v13

* Basic NMap support

* lint

* Test expectations
This commit is contained in:
Jaco
2021-05-05 08:55:49 +02:00
committed by GitHub
parent b51149d895
commit 3de06c1d4c
22 changed files with 14881 additions and 118 deletions
+11 -2
View File
@@ -378,8 +378,16 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
key.section === creator.section && key.method === creator.method;
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
decorated.key = (...args: Arg[]): string =>
u8aToHex(compactStripLength(creator(
creator.meta.type.isPlain
? undefined
: creator.meta.type.isMap
? args[0]
: creator.meta.type.isDoubleMap
? [args[0], args[1]]
: args
))[1]);
decorated.keyPrefix = (key1?: Arg): string =>
u8aToHex(creator.keyPrefix(key1));
@@ -393,6 +401,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, arg1?: Arg, arg2?: Arg): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2), hash));
// FIXME NMap support
// .keys() & .entries() only available on map types
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
decorated.entries = decorateMethod(
+2 -2
View File
@@ -66,14 +66,14 @@ describe('extractStorageArgs', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.erasStakers, [])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 0 found');
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
});
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
expect(
(): any =>
extractStorageArgs(storage.staking.erasStakers, [123])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 1 found');
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
});
// Linked maps have been removed
+16 -5
View File
@@ -6,14 +6,14 @@ import type { StorageEntry } from '@polkadot/types/primitive/types';
import { assert, isUndefined } from '@polkadot/util';
function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
function sig ({ method, section }: StorageEntry, args: Type[]): string {
return `${section}.${method}(${args.join(', ')})`;
}
function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
const { key1, key2 } = creator.meta.type.asDoubleMap;
assert(args.length === 2, () => `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`);
assert(args.length === 2, () => `${sig(creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
// pass as tuple
return [creator, args as [any, any]];
@@ -22,7 +22,7 @@ function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [a
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
const { key } = creator.meta.type.asMap;
assert(args.length === 1, () => `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
assert(args.length === 1, () => `${sig(creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
// expand
return args.length
@@ -30,18 +30,29 @@ function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [Stora
: [creator];
}
function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
const { keyVec } = creator.meta.type.asNMap;
assert(args.length === keyVec.length, () => `${sig(creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
// pass as tuple
return [creator, args];
}
// sets up the arguments in the form of [creator, args] ready to be used in a storage
// call. Additionally, it verifies that the correct number of arguments have been passed
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, [any, any]] | [StorageEntry] | [StorageEntry, any] {
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
const args = _args.filter((arg) => !isUndefined(arg));
if (creator.meta.type.isDoubleMap) {
return doDoubleMap(creator, args);
} else if (creator.meta.type.isMap) {
return doMap(creator, args);
} else if (creator.meta.type.isNMap) {
return doNMap(creator, args);
}
assert(args.length === 0, () => `${sig(creator)} does not take any arguments, ${args.length} found`);
assert(args.length === 0, () => `${sig(creator, [])} does not take any arguments, ${args.length} found`);
// no args
return [creator];
+12 -2
View File
@@ -9,10 +9,20 @@ describe('MagicNumber', (): void => {
const registry = new TypeRegistry();
it('succeeds when the magic number matches', (): void => {
expect((): MagicNumber => new MagicNumber(registry, MAGIC_NUMBER)).not.toThrow();
expect(
() => new MagicNumber(registry, MAGIC_NUMBER)
).not.toThrow();
});
it('succeeds when the magic number is empty', (): void => {
expect(
() => new MagicNumber(registry)
).not.toThrow();
});
it('fails when the magic number mismatches', (): void => {
expect((): MagicNumber => new MagicNumber(registry, 0x12345)).toThrow(/MagicNumber/);
expect(
() => new MagicNumber(registry, 0x12345678)
).toThrow(/MagicNumber mismatch/);
});
});
+1 -3
View File
@@ -13,9 +13,7 @@ export class MagicNumber extends U32 {
super(registry, value);
if (!this.isEmpty) {
const magic = registry.createType('u32', MAGIC_NUMBER);
assert(this.eq(magic), () => `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`);
assert(this.eq(MAGIC_NUMBER), () => `MagicNumber mismatch: expected ${registry.createType('u32', MAGIC_NUMBER).toHex()}, found ${this.toHex()}`);
}
}
}
+25 -13
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12, MetadataV13 } from '@polkadot/types/interfaces/metadata';
import type { AnyJson, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types/codec';
@@ -10,13 +10,16 @@ import { assert } from '@polkadot/util';
import { toV10 } from './v9/toV10';
import { toV11 } from './v10/toV11';
import { toV12 } from './v11/toV12';
import { toLatest } from './v12/toLatest';
import { toV13 } from './v12/toV13';
import { toLatest } from './v13/toLatest';
import { MagicNumber } from './MagicNumber';
import { getUniqTypes, toCallsOnly } from './util';
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12;
type MetaVersions = 9 | 10 | 11 | 12 | 13;
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12 | MetadataV13;
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12' | 'asV13';
type MetaVersions = 'latest' | 9 | 10 | 11 | 12 | 13;
const LATEST_VERSION = 13;
/**
* @name MetadataVersioned
@@ -24,7 +27,7 @@ type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
* The versioned runtime metadata as a decoded structure
*/
export class MetadataVersioned extends Struct {
readonly #converted = new Map<number, MetaMapped>();
readonly #converted = new Map<MetaVersions, MetaMapped>();
constructor (registry: Registry, value?: unknown) {
super(registry, {
@@ -34,16 +37,18 @@ export class MetadataVersioned extends Struct {
}
#assertVersion = (version: number): boolean => {
assert(this.version <= version, () => `Cannot convert metadata from v${this.version} to v${version}`);
assert(this.version <= version, () => `Cannot convert metadata from version ${this.version} to ${version}`);
return this.version === version;
};
#getVersion = <T extends MetaMapped, F extends MetaMapped>(version: MetaVersions, fromPrev: (registry: Registry, input: F, metaVersion: number) => T): T => {
const asCurr = `asV${version}` as MetaAsX;
const asPrev = `asV${version - 1}` as MetaAsX;
const asPrev = version === 'latest'
? `asV${LATEST_VERSION}` as MetaAsX
: `asV${version - 1}` as MetaAsX;
if (this.#assertVersion(version)) {
if (version !== 'latest' && this.#assertVersion(version)) {
return this.#metadata()[asCurr] as T;
}
@@ -101,16 +106,23 @@ export class MetadataVersioned extends Struct {
return this.#getVersion(12, toV12);
}
/**
* @description Returns the wrapped values as a V13 object
*/
public get asV13 (): MetadataV13 {
return this.#getVersion(13, toV13);
}
/**
* @description Returns the wrapped values as a latest version object
*/
public get asLatest (): MetadataLatest {
// This is non-existent & latest - applied here to do the module-specific type conversions
return this.#getVersion(13, toLatest);
return this.#getVersion('latest', toLatest);
}
/**
* @description
* @description The magicNumber for the Metadata (known constant)
*/
public get magicNumber (): MagicNumber {
return this.get('magicNumber') as MagicNumber;
@@ -131,8 +143,8 @@ export class MetadataVersioned extends Struct {
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): Record<string, AnyJson> {
// HACK(y): ensure that we apply the aliasses if we have not done so already, this is
// needed to ensure we have the overrides as intended (only applied in toLatest)
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
// needed to ensure we have the correct overrides (which is only applied in toLatest)
// eslint-disable-next-line no-unused-expressions
this.asLatest;
@@ -49,4 +49,52 @@ describe('createFunction', (): void => {
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
);
});
it('allows creating of NMap keys (with Bytes)', (): void => {
const storageFn = createFunction(registry, {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
meta: {
type: {
asNMap: {
hashers: [
registry.createType('StorageHasher', 'Twox64Concat'),
registry.createType('StorageHasher', 'Blake2_256'),
registry.createType('StorageHasher', 'Blake2_256')
],
keyVec: [
new Text(registry, 'Bytes'),
new Text(registry, 'AccountId'),
new Text(registry, 'AccountId')
],
value: new Text(registry, 'SessionKeys5')
},
isNMap: true
}
} as any,
method: 'NextKeys',
prefix: 'Session',
section: 'session'
}, {});
expect(
u8aToHex(
storageFn([
// hex, without length prefix
'0x3a73657373696f6e3a6b657973',
// addresses
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4',
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4'
])
)
).toEqual(
'0x' +
'd901' + // length
'cec5070d609dd3497f72bde07fc96ba0' + // twox 128
'4c014e6bf8b8c2c011e7290b85696bb3' + // twox 128
'9fe6329cc0b39e09' + // twox 64
'343a73657373696f6e3a6b657973' + // twox 64 (concat, with length)
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' + // blake2
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
);
});
});
@@ -108,6 +108,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
const { meta: { type } } = itemFn;
// FIXME NMap support
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (arg?: any): Raw => {
assert(type.isDoubleMap || isUndefined(arg), 'Filtering arguments for keys/entries are only valid on double maps');
@@ -136,15 +137,18 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
// - storage.timestamp.blockPeriod()
// For higher-map queries the params are passed in as an tuple, [key1, key2]
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | CreateArgType[]) =>
type.isDoubleMap
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
type.isPlain
? options.skipHashing
? compactAddLength(u8aToU8a(options.key))
: createKey(registry, itemFn, [], [], [])
: type.isMap
? createKey(registry, itemFn, [type.asMap.key], [getHasher(type.asMap.hasher)], [arg as CreateArgType])
: options.skipHashing
? compactAddLength(u8aToU8a(options.key))
: createKey(registry, itemFn, [], [], [])
: type.isDoubleMap
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
);
// FIXME NMap support
if (type.isMap || type.isDoubleMap) {
extendPrefixedMap(registry, itemFn, storageFn);
}
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import metadata from './v12/static';
import metadata from './v13/static';
export default metadata;
+21 -11
View File
@@ -12,10 +12,11 @@ type Arg = { type: Type } & Codec;
type Item = {
type: {
isDoubleMap?: boolean;
isDoubleMap: boolean;
isMap: boolean;
isNMap: boolean;
isPlain: boolean;
asDoubleMap?: {
asDoubleMap: {
key1: Text;
key2: Text;
value: Text;
@@ -24,6 +25,10 @@ type Item = {
key: Text;
value: Text;
};
asNMap: {
keyVec: Text[];
value: Text;
},
asPlain: Text;
};
} & Codec;
@@ -106,20 +111,25 @@ function unwrapStorage (storage?: Storage): Item[] {
function getStorageNames ({ modules }: ExtractionMetadata): string[][][] {
return modules.map(({ storage }): string[][] =>
unwrapStorage(storage).map(({ type }) =>
type.isDoubleMap && type.asDoubleMap
type.isPlain
? [
type.asDoubleMap.key1.toString(),
type.asDoubleMap.key2.toString(),
type.asDoubleMap.value.toString()
type.asPlain.toString()
]
: type.isMap
? [
type.asMap.key.toString(),
type.asMap.value.toString()
]
: [
type.asPlain.toString()
type.asMap.value.toString(),
type.asMap.key.toString()
]
: type.isDoubleMap
? [
type.asDoubleMap.value.toString(),
type.asDoubleMap.key1.toString(),
type.asDoubleMap.key2.toString()
]
: [
type.asNMap.value.toString(),
...type.asNMap.keyVec.map((k) => k.toString())
]
)
);
}
+12
View File
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { MetadataV12, MetadataV13 } from '@polkadot/types/interfaces/metadata';
import type { Registry } from '@polkadot/types/types';
/**
* @internal
**/
export function toV13 (registry: Registry, metadata: MetadataV12): MetadataV13 {
return registry.createType('MetadataV13', metadata);
}
@@ -0,0 +1,18 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '@polkadot/types/create';
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
import substrateData from './static';
import substrateJson from './static-substrate.json';
describe('MetadataV13 (substrate)', (): void => {
const registry = new TypeRegistry();
decodeLatestSubstrate(registry, 13, substrateData, substrateJson);
toLatest(registry, 13, substrateData);
defaultValues(registry, substrateData, true, true);
});
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { EventMetadataLatest, EventMetadataV12, FunctionMetadataLatest, FunctionMetadataV12, MetadataLatest, MetadataV12, ModuleConstantMetadataLatest, ModuleConstantMetadataV12, ModuleMetadataLatest, ModuleMetadataV12, StorageEntryMetadataLatest, StorageMetadataLatest, StorageMetadataV12 } from '@polkadot/types/interfaces/metadata';
import type { EventMetadataLatest, EventMetadataV13, FunctionMetadataLatest, FunctionMetadataV13, MetadataLatest, MetadataV13, ModuleConstantMetadataLatest, ModuleConstantMetadataV13, ModuleMetadataLatest, ModuleMetadataV13, StorageEntryMetadataLatest, StorageMetadataLatest, StorageMetadataV13 } from '@polkadot/types/interfaces/metadata';
import type { OverrideModuleType, Registry } from '@polkadot/types/types';
import { Type } from '@polkadot/types/primitive';
@@ -16,11 +16,13 @@ const KNOWN_ORIGINS: Record<string, string> = {
TechnicalCommittee: 'CollectiveOrigin'
};
const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']];
/**
* Find and apply the correct type override
* @internal
**/
function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): void {
function setTypeOverride (sectionTypes: OverrideModuleType, types: Type[]): void {
types.forEach((type): void => {
const override = Object.keys(sectionTypes).find((aliased) => type.eq(aliased));
@@ -29,9 +31,11 @@ function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): v
} else {
// FIXME: NOT happy with this approach, but gets over the initial hump cased by (Vec<Announcement>,BalanceOf)
const orig = type.toString();
const alias = Object.entries(sectionTypes).reduce((result: string, [from, to]): string =>
[['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']].reduce((result, [one, two]): string =>
result.replace(`${one}${from}${two}`, `${one}${to}${two}`), result), orig);
const alias = Object
.entries(sectionTypes)
.reduce((result: string, [from, to]) =>
BOXES.reduce((result, [one, two]) =>
result.replace(`${one}${from}${two}`, `${one}${to}${two}`), result), orig);
if (orig !== alias) {
type.setOverride(alias);
@@ -44,9 +48,9 @@ function setTypeOverride (sectionTypes: OverrideModuleType, ...types: Type[]): v
* Apply module-specific type overrides (always be done as part of toLatest)
* @internal
**/
function convertCalls (registry: Registry, calls: FunctionMetadataV12[], sectionTypes: OverrideModuleType): FunctionMetadataLatest[] {
function convertCalls (registry: Registry, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): FunctionMetadataLatest[] {
return calls.map((c): FunctionMetadataLatest => {
c.args.forEach(({ type }) => setTypeOverride(sectionTypes, type));
setTypeOverride(sectionTypes, c.args.map(({ type }) => type));
return registry.createType('FunctionMetadataLatest', c);
});
@@ -56,9 +60,9 @@ function convertCalls (registry: Registry, calls: FunctionMetadataV12[], section
* Apply module-specific type overrides (always be done as part of toLatest)
* @internal
*/
function convertConstants (registry: Registry, constants: ModuleConstantMetadataV12[], sectionTypes: OverrideModuleType): ModuleConstantMetadataLatest[] {
function convertConstants (registry: Registry, constants: ModuleConstantMetadataV13[], sectionTypes: OverrideModuleType): ModuleConstantMetadataLatest[] {
return constants.map((c): ModuleConstantMetadataLatest => {
setTypeOverride(sectionTypes, c.type);
setTypeOverride(sectionTypes, [c.type]);
return registry.createType('ModuleConstantMetadataLatest', c);
});
@@ -68,9 +72,9 @@ function convertConstants (registry: Registry, constants: ModuleConstantMetadata
* Apply module-specific type overrides (always be done as part of toLatest)
* @internal
**/
function convertEvents (registry: Registry, events: EventMetadataV12[], sectionTypes: OverrideModuleType): EventMetadataLatest[] {
function convertEvents (registry: Registry, events: EventMetadataV13[], sectionTypes: OverrideModuleType): EventMetadataLatest[] {
return events.map((e): EventMetadataLatest => {
e.args.forEach((type) => setTypeOverride(sectionTypes, type));
setTypeOverride(sectionTypes, e.args.map((type) => type));
return registry.createType('EventMetadataLatest', e);
});
@@ -80,16 +84,18 @@ function convertEvents (registry: Registry, events: EventMetadataV12[], sectionT
* Apply module-specific storage type overrides (always part of toLatest)
* @internal
**/
function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV12, sectionTypes: OverrideModuleType): StorageMetadataLatest {
function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV13, sectionTypes: OverrideModuleType): StorageMetadataLatest {
return registry.createType('StorageMetadataLatest', {
items: items.map((s): StorageEntryMetadataLatest => {
if (s.type.isDoubleMap) {
setTypeOverride(sectionTypes, s.type.asDoubleMap.value, s.type.asDoubleMap.key1, s.type.asDoubleMap.key2);
} else if (s.type.isMap) {
setTypeOverride(sectionTypes, s.type.asMap.value, s.type.asMap.key);
} else {
setTypeOverride(sectionTypes, s.type.asPlain);
}
setTypeOverride(sectionTypes,
s.type.isPlain
? [s.type.asPlain]
: s.type.isMap
? [s.type.asMap.value, s.type.asMap.key]
: s.type.isDoubleMap
? [s.type.asDoubleMap.value, s.type.asDoubleMap.key1, s.type.asDoubleMap.key2]
: [s.type.asNMap.value, ...s.type.asNMap.keyVec]
);
return registry.createType('StorageEntryMetadataLatest', s);
}),
@@ -98,13 +104,15 @@ function convertStorage (registry: Registry, { items, prefix }: StorageMetadataV
}
// generate & register the OriginCaller type
function registerOriginCaller (registry: Registry, modules: ModuleMetadataV12[], metaVersion: number): void {
function registerOriginCaller (registry: Registry, modules: ModuleMetadataV13[], metaVersion: number): void {
registry.register({
OriginCaller: {
_enum: modules
.map((mod, index): [string, number] => [
mod.name.toString(),
metaVersion >= 12 ? mod.index.toNumber() : index
metaVersion >= 12
? mod.index.toNumber()
: index
])
.sort((a, b) => a[1] - b[1])
.reduce((result: Record<string, string>, [name, index]): Record<string, string> => {
@@ -121,7 +129,7 @@ function registerOriginCaller (registry: Registry, modules: ModuleMetadataV12[],
}
/** @internal */
function createModule (registry: Registry, mod: ModuleMetadataV12, { calls, constants, events, storage }: { calls: FunctionMetadataV12[] | null, constants: ModuleConstantMetadataV12[], events: EventMetadataV12[] | null, storage: StorageMetadataV12 | null }): ModuleMetadataLatest {
function createModule (registry: Registry, mod: ModuleMetadataV13, { calls, constants, events, storage }: { calls: FunctionMetadataV13[] | null, constants: ModuleConstantMetadataV13[], events: EventMetadataV13[] | null, storage: StorageMetadataV13 | null }): ModuleMetadataLatest {
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name));
return registry.createType('ModuleMetadataLatest', {
@@ -138,7 +146,7 @@ function createModule (registry: Registry, mod: ModuleMetadataV12, { calls, cons
* most-recent metadata, since it allows us a chance to actually apply call and storage specific type aliasses
* @internal
**/
export function toLatest (registry: Registry, { extrinsic, modules }: MetadataV12, metaVersion: number): MetadataLatest {
export function toLatest (registry: Registry, { extrinsic, modules }: MetadataV13, metaVersion: number): MetadataLatest {
registerOriginCaller(registry, modules, metaVersion);
return registry.createType('MetadataLatest', {
+29 -7
View File
@@ -25,38 +25,60 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
return ['', '', formatType(allDefs, outputType, imports)];
} else if (storageEntry.type.isMap) {
const map = storageEntry.type.asMap;
// Find similar types of the `key` type
const similarTypes = getSimilarTypes(registry, allDefs, storageEntry.type.asMap.key.toString(), imports);
const similarTypes = getSimilarTypes(registry, allDefs, map.key.toString(), imports);
setImports(allDefs, imports, [
...similarTypes,
storageEntry.type.asMap.value.toString()
map.value.toString()
]);
return [
formatType(allDefs, storageEntry.type.asMap.key.toString(), imports),
formatType(allDefs, map.key.toString(), imports),
`arg: ${similarTypes.join(' | ')}`,
formatType(allDefs, outputType, imports)
];
} else if (storageEntry.type.isDoubleMap) {
const dm = storageEntry.type.asDoubleMap;
// Find similar types of `key1` and `key2` types
const similarTypes1 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports);
const similarTypes2 = getSimilarTypes(registry, allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports);
const similarTypes1 = getSimilarTypes(registry, allDefs, dm.key1.toString(), imports);
const similarTypes2 = getSimilarTypes(registry, allDefs, dm.key2.toString(), imports);
setImports(allDefs, imports, [
...similarTypes1,
...similarTypes2,
storageEntry.type.asDoubleMap.value.toString()
dm.value.toString()
]);
const key1Types = similarTypes1.join(' | ');
const key2Types = similarTypes2.join(' | ');
return [
[formatType(allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports), formatType(allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports)].join(', '),
[formatType(allDefs, dm.key1.toString(), imports), formatType(allDefs, dm.key2.toString(), imports)].join(', '),
`key1: ${key1Types}, key2: ${key2Types}`,
formatType(allDefs, outputType, imports)
];
} else if (storageEntry.type.isNMap) {
const nmap = storageEntry.type.asNMap;
// Find similar types for all keys
const similarTypes = nmap.keyVec.map((k) => getSimilarTypes(registry, allDefs, k.toString(), imports));
setImports(allDefs, imports, [
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
nmap.value.toString()
]);
const keyTypes = similarTypes.map((t) => t.join(' | '));
return [
nmap.keyVec.map((k) => formatType(allDefs, k.toString(), imports)).join(', '),
keyTypes.map((t, i) => `key${i + 1}: ${t}`).join(', '),
formatType(allDefs, outputType, imports)
];
}
throw new Error(`entryArgs: Cannot parse args of entry ${storageEntry.name.toString()}`);
+3 -1
View File
@@ -210,7 +210,9 @@ function addStorage (metadata: MetadataLatest): string {
? ('`' + func.type.asMap.key.toString() + '`')
: func.type.isDoubleMap
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
: '';
: func.type.isNMap
? ('`' + func.type.asNMap.keyVec.map((k) => k.toString()).join(', ') + '`')
: '';
const methodName = stringLowerFirst(func.name);
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
+52 -1
View File
@@ -30,7 +30,7 @@ import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityPro
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV13, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV13, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, NMapTypeLatest, NMapTypeV13, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
@@ -334,6 +334,7 @@ declare module '@polkadot/types/types/registry' {
'Option<DoubleMapTypeV10>': Option<DoubleMapTypeV10>;
'Option<DoubleMapTypeV11>': Option<DoubleMapTypeV11>;
'Option<DoubleMapTypeV12>': Option<DoubleMapTypeV12>;
'Option<DoubleMapTypeV13>': Option<DoubleMapTypeV13>;
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
'Option<DoubleVoteReport>': Option<DoubleVoteReport>;
'Option<DownwardMessage>': Option<DownwardMessage>;
@@ -356,6 +357,7 @@ declare module '@polkadot/types/types/registry' {
'Option<ErrorMetadataV10>': Option<ErrorMetadataV10>;
'Option<ErrorMetadataV11>': Option<ErrorMetadataV11>;
'Option<ErrorMetadataV12>': Option<ErrorMetadataV12>;
'Option<ErrorMetadataV13>': Option<ErrorMetadataV13>;
'Option<ErrorMetadataV9>': Option<ErrorMetadataV9>;
'Option<EthAccount>': Option<EthAccount>;
'Option<EthBlock>': Option<EthBlock>;
@@ -396,6 +398,7 @@ declare module '@polkadot/types/types/registry' {
'Option<EventMetadataV10>': Option<EventMetadataV10>;
'Option<EventMetadataV11>': Option<EventMetadataV11>;
'Option<EventMetadataV12>': Option<EventMetadataV12>;
'Option<EventMetadataV13>': Option<EventMetadataV13>;
'Option<EventMetadataV9>': Option<EventMetadataV9>;
'Option<EventRecord>': Option<EventRecord>;
'Option<EvmAccount>': Option<EvmAccount>;
@@ -414,6 +417,7 @@ declare module '@polkadot/types/types/registry' {
'Option<ExtrinsicMetadataLatest>': Option<ExtrinsicMetadataLatest>;
'Option<ExtrinsicMetadataV11>': Option<ExtrinsicMetadataV11>;
'Option<ExtrinsicMetadataV12>': Option<ExtrinsicMetadataV12>;
'Option<ExtrinsicMetadataV13>': Option<ExtrinsicMetadataV13>;
'Option<ExtrinsicOrHash>': Option<ExtrinsicOrHash>;
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
'Option<ExtrinsicPayloadUnknown>': Option<ExtrinsicPayloadUnknown>;
@@ -437,11 +441,13 @@ declare module '@polkadot/types/types/registry' {
'Option<FunctionArgumentMetadataV10>': Option<FunctionArgumentMetadataV10>;
'Option<FunctionArgumentMetadataV11>': Option<FunctionArgumentMetadataV11>;
'Option<FunctionArgumentMetadataV12>': Option<FunctionArgumentMetadataV12>;
'Option<FunctionArgumentMetadataV13>': Option<FunctionArgumentMetadataV13>;
'Option<FunctionArgumentMetadataV9>': Option<FunctionArgumentMetadataV9>;
'Option<FunctionMetadataLatest>': Option<FunctionMetadataLatest>;
'Option<FunctionMetadataV10>': Option<FunctionMetadataV10>;
'Option<FunctionMetadataV11>': Option<FunctionMetadataV11>;
'Option<FunctionMetadataV12>': Option<FunctionMetadataV12>;
'Option<FunctionMetadataV13>': Option<FunctionMetadataV13>;
'Option<FunctionMetadataV9>': Option<FunctionMetadataV9>;
'Option<FundIndex>': Option<FundIndex>;
'Option<FundInfo>': Option<FundInfo>;
@@ -537,6 +543,7 @@ declare module '@polkadot/types/types/registry' {
'Option<MapTypeV10>': Option<MapTypeV10>;
'Option<MapTypeV11>': Option<MapTypeV11>;
'Option<MapTypeV12>': Option<MapTypeV12>;
'Option<MapTypeV13>': Option<MapTypeV13>;
'Option<MapTypeV9>': Option<MapTypeV9>;
'Option<MaybeRandomness>': Option<MaybeRandomness>;
'Option<MaybeVrf>': Option<MaybeVrf>;
@@ -551,6 +558,7 @@ declare module '@polkadot/types/types/registry' {
'Option<MetadataV10>': Option<MetadataV10>;
'Option<MetadataV11>': Option<MetadataV11>;
'Option<MetadataV12>': Option<MetadataV12>;
'Option<MetadataV13>': Option<MetadataV13>;
'Option<MetadataV9>': Option<MetadataV9>;
'Option<MmrLeafProof>': Option<MmrLeafProof>;
'Option<MmrRootHash>': Option<MmrRootHash>;
@@ -558,12 +566,14 @@ declare module '@polkadot/types/types/registry' {
'Option<ModuleConstantMetadataV10>': Option<ModuleConstantMetadataV10>;
'Option<ModuleConstantMetadataV11>': Option<ModuleConstantMetadataV11>;
'Option<ModuleConstantMetadataV12>': Option<ModuleConstantMetadataV12>;
'Option<ModuleConstantMetadataV13>': Option<ModuleConstantMetadataV13>;
'Option<ModuleConstantMetadataV9>': Option<ModuleConstantMetadataV9>;
'Option<ModuleId>': Option<ModuleId>;
'Option<ModuleMetadataLatest>': Option<ModuleMetadataLatest>;
'Option<ModuleMetadataV10>': Option<ModuleMetadataV10>;
'Option<ModuleMetadataV11>': Option<ModuleMetadataV11>;
'Option<ModuleMetadataV12>': Option<ModuleMetadataV12>;
'Option<ModuleMetadataV13>': Option<ModuleMetadataV13>;
'Option<ModuleMetadataV9>': Option<ModuleMetadataV9>;
'Option<Moment>': Option<Moment>;
'Option<MomentOf>': Option<MomentOf>;
@@ -589,6 +599,8 @@ declare module '@polkadot/types/types/registry' {
'Option<NextAuthority>': Option<NextAuthority>;
'Option<NextConfigDescriptor>': Option<NextConfigDescriptor>;
'Option<NextConfigDescriptorV1>': Option<NextConfigDescriptorV1>;
'Option<NMapTypeLatest>': Option<NMapTypeLatest>;
'Option<NMapTypeV13>': Option<NMapTypeV13>;
'Option<NodeRole>': Option<NodeRole>;
'Option<Nominations>': Option<Nominations>;
'Option<NominatorIndex>': Option<NominatorIndex>;
@@ -805,21 +817,25 @@ declare module '@polkadot/types/types/registry' {
'Option<StorageEntryMetadataV10>': Option<StorageEntryMetadataV10>;
'Option<StorageEntryMetadataV11>': Option<StorageEntryMetadataV11>;
'Option<StorageEntryMetadataV12>': Option<StorageEntryMetadataV12>;
'Option<StorageEntryMetadataV13>': Option<StorageEntryMetadataV13>;
'Option<StorageEntryMetadataV9>': Option<StorageEntryMetadataV9>;
'Option<StorageEntryModifierLatest>': Option<StorageEntryModifierLatest>;
'Option<StorageEntryModifierV10>': Option<StorageEntryModifierV10>;
'Option<StorageEntryModifierV11>': Option<StorageEntryModifierV11>;
'Option<StorageEntryModifierV12>': Option<StorageEntryModifierV12>;
'Option<StorageEntryModifierV13>': Option<StorageEntryModifierV13>;
'Option<StorageEntryModifierV9>': Option<StorageEntryModifierV9>;
'Option<StorageEntryTypeLatest>': Option<StorageEntryTypeLatest>;
'Option<StorageEntryTypeV10>': Option<StorageEntryTypeV10>;
'Option<StorageEntryTypeV11>': Option<StorageEntryTypeV11>;
'Option<StorageEntryTypeV12>': Option<StorageEntryTypeV12>;
'Option<StorageEntryTypeV13>': Option<StorageEntryTypeV13>;
'Option<StorageEntryTypeV9>': Option<StorageEntryTypeV9>;
'Option<StorageHasher>': Option<StorageHasher>;
'Option<StorageHasherV10>': Option<StorageHasherV10>;
'Option<StorageHasherV11>': Option<StorageHasherV11>;
'Option<StorageHasherV12>': Option<StorageHasherV12>;
'Option<StorageHasherV13>': Option<StorageHasherV13>;
'Option<StorageHasherV9>': Option<StorageHasherV9>;
'Option<StorageKey>': Option<StorageKey>;
'Option<StorageKind>': Option<StorageKind>;
@@ -827,6 +843,7 @@ declare module '@polkadot/types/types/registry' {
'Option<StorageMetadataV10>': Option<StorageMetadataV10>;
'Option<StorageMetadataV11>': Option<StorageMetadataV11>;
'Option<StorageMetadataV12>': Option<StorageMetadataV12>;
'Option<StorageMetadataV13>': Option<StorageMetadataV13>;
'Option<StorageMetadataV9>': Option<StorageMetadataV9>;
'Option<StorageProof>': Option<StorageProof>;
'Option<StoredPendingChange>': Option<StoredPendingChange>;
@@ -1135,6 +1152,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<DoubleMapTypeV10>': Vec<DoubleMapTypeV10>;
'Vec<DoubleMapTypeV11>': Vec<DoubleMapTypeV11>;
'Vec<DoubleMapTypeV12>': Vec<DoubleMapTypeV12>;
'Vec<DoubleMapTypeV13>': Vec<DoubleMapTypeV13>;
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
'Vec<DoubleVoteReport>': Vec<DoubleVoteReport>;
'Vec<DownwardMessage>': Vec<DownwardMessage>;
@@ -1157,6 +1175,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<ErrorMetadataV10>': Vec<ErrorMetadataV10>;
'Vec<ErrorMetadataV11>': Vec<ErrorMetadataV11>;
'Vec<ErrorMetadataV12>': Vec<ErrorMetadataV12>;
'Vec<ErrorMetadataV13>': Vec<ErrorMetadataV13>;
'Vec<ErrorMetadataV9>': Vec<ErrorMetadataV9>;
'Vec<EthAccount>': Vec<EthAccount>;
'Vec<EthBlock>': Vec<EthBlock>;
@@ -1197,6 +1216,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<EventMetadataV10>': Vec<EventMetadataV10>;
'Vec<EventMetadataV11>': Vec<EventMetadataV11>;
'Vec<EventMetadataV12>': Vec<EventMetadataV12>;
'Vec<EventMetadataV13>': Vec<EventMetadataV13>;
'Vec<EventMetadataV9>': Vec<EventMetadataV9>;
'Vec<EventRecord>': Vec<EventRecord>;
'Vec<EvmAccount>': Vec<EvmAccount>;
@@ -1215,6 +1235,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<ExtrinsicMetadataLatest>': Vec<ExtrinsicMetadataLatest>;
'Vec<ExtrinsicMetadataV11>': Vec<ExtrinsicMetadataV11>;
'Vec<ExtrinsicMetadataV12>': Vec<ExtrinsicMetadataV12>;
'Vec<ExtrinsicMetadataV13>': Vec<ExtrinsicMetadataV13>;
'Vec<ExtrinsicOrHash>': Vec<ExtrinsicOrHash>;
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
'Vec<ExtrinsicPayloadUnknown>': Vec<ExtrinsicPayloadUnknown>;
@@ -1238,11 +1259,13 @@ declare module '@polkadot/types/types/registry' {
'Vec<FunctionArgumentMetadataV10>': Vec<FunctionArgumentMetadataV10>;
'Vec<FunctionArgumentMetadataV11>': Vec<FunctionArgumentMetadataV11>;
'Vec<FunctionArgumentMetadataV12>': Vec<FunctionArgumentMetadataV12>;
'Vec<FunctionArgumentMetadataV13>': Vec<FunctionArgumentMetadataV13>;
'Vec<FunctionArgumentMetadataV9>': Vec<FunctionArgumentMetadataV9>;
'Vec<FunctionMetadataLatest>': Vec<FunctionMetadataLatest>;
'Vec<FunctionMetadataV10>': Vec<FunctionMetadataV10>;
'Vec<FunctionMetadataV11>': Vec<FunctionMetadataV11>;
'Vec<FunctionMetadataV12>': Vec<FunctionMetadataV12>;
'Vec<FunctionMetadataV13>': Vec<FunctionMetadataV13>;
'Vec<FunctionMetadataV9>': Vec<FunctionMetadataV9>;
'Vec<FundIndex>': Vec<FundIndex>;
'Vec<FundInfo>': Vec<FundInfo>;
@@ -1338,6 +1361,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<MapTypeV10>': Vec<MapTypeV10>;
'Vec<MapTypeV11>': Vec<MapTypeV11>;
'Vec<MapTypeV12>': Vec<MapTypeV12>;
'Vec<MapTypeV13>': Vec<MapTypeV13>;
'Vec<MapTypeV9>': Vec<MapTypeV9>;
'Vec<MaybeRandomness>': Vec<MaybeRandomness>;
'Vec<MaybeVrf>': Vec<MaybeVrf>;
@@ -1352,6 +1376,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<MetadataV10>': Vec<MetadataV10>;
'Vec<MetadataV11>': Vec<MetadataV11>;
'Vec<MetadataV12>': Vec<MetadataV12>;
'Vec<MetadataV13>': Vec<MetadataV13>;
'Vec<MetadataV9>': Vec<MetadataV9>;
'Vec<MmrLeafProof>': Vec<MmrLeafProof>;
'Vec<MmrRootHash>': Vec<MmrRootHash>;
@@ -1359,12 +1384,14 @@ declare module '@polkadot/types/types/registry' {
'Vec<ModuleConstantMetadataV10>': Vec<ModuleConstantMetadataV10>;
'Vec<ModuleConstantMetadataV11>': Vec<ModuleConstantMetadataV11>;
'Vec<ModuleConstantMetadataV12>': Vec<ModuleConstantMetadataV12>;
'Vec<ModuleConstantMetadataV13>': Vec<ModuleConstantMetadataV13>;
'Vec<ModuleConstantMetadataV9>': Vec<ModuleConstantMetadataV9>;
'Vec<ModuleId>': Vec<ModuleId>;
'Vec<ModuleMetadataLatest>': Vec<ModuleMetadataLatest>;
'Vec<ModuleMetadataV10>': Vec<ModuleMetadataV10>;
'Vec<ModuleMetadataV11>': Vec<ModuleMetadataV11>;
'Vec<ModuleMetadataV12>': Vec<ModuleMetadataV12>;
'Vec<ModuleMetadataV13>': Vec<ModuleMetadataV13>;
'Vec<ModuleMetadataV9>': Vec<ModuleMetadataV9>;
'Vec<Moment>': Vec<Moment>;
'Vec<MomentOf>': Vec<MomentOf>;
@@ -1390,6 +1417,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<NextAuthority>': Vec<NextAuthority>;
'Vec<NextConfigDescriptor>': Vec<NextConfigDescriptor>;
'Vec<NextConfigDescriptorV1>': Vec<NextConfigDescriptorV1>;
'Vec<NMapTypeLatest>': Vec<NMapTypeLatest>;
'Vec<NMapTypeV13>': Vec<NMapTypeV13>;
'Vec<NodeRole>': Vec<NodeRole>;
'Vec<Nominations>': Vec<Nominations>;
'Vec<NominatorIndex>': Vec<NominatorIndex>;
@@ -1606,21 +1635,25 @@ declare module '@polkadot/types/types/registry' {
'Vec<StorageEntryMetadataV10>': Vec<StorageEntryMetadataV10>;
'Vec<StorageEntryMetadataV11>': Vec<StorageEntryMetadataV11>;
'Vec<StorageEntryMetadataV12>': Vec<StorageEntryMetadataV12>;
'Vec<StorageEntryMetadataV13>': Vec<StorageEntryMetadataV13>;
'Vec<StorageEntryMetadataV9>': Vec<StorageEntryMetadataV9>;
'Vec<StorageEntryModifierLatest>': Vec<StorageEntryModifierLatest>;
'Vec<StorageEntryModifierV10>': Vec<StorageEntryModifierV10>;
'Vec<StorageEntryModifierV11>': Vec<StorageEntryModifierV11>;
'Vec<StorageEntryModifierV12>': Vec<StorageEntryModifierV12>;
'Vec<StorageEntryModifierV13>': Vec<StorageEntryModifierV13>;
'Vec<StorageEntryModifierV9>': Vec<StorageEntryModifierV9>;
'Vec<StorageEntryTypeLatest>': Vec<StorageEntryTypeLatest>;
'Vec<StorageEntryTypeV10>': Vec<StorageEntryTypeV10>;
'Vec<StorageEntryTypeV11>': Vec<StorageEntryTypeV11>;
'Vec<StorageEntryTypeV12>': Vec<StorageEntryTypeV12>;
'Vec<StorageEntryTypeV13>': Vec<StorageEntryTypeV13>;
'Vec<StorageEntryTypeV9>': Vec<StorageEntryTypeV9>;
'Vec<StorageHasher>': Vec<StorageHasher>;
'Vec<StorageHasherV10>': Vec<StorageHasherV10>;
'Vec<StorageHasherV11>': Vec<StorageHasherV11>;
'Vec<StorageHasherV12>': Vec<StorageHasherV12>;
'Vec<StorageHasherV13>': Vec<StorageHasherV13>;
'Vec<StorageHasherV9>': Vec<StorageHasherV9>;
'Vec<StorageKey>': Vec<StorageKey>;
'Vec<StorageKind>': Vec<StorageKind>;
@@ -1628,6 +1661,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<StorageMetadataV10>': Vec<StorageMetadataV10>;
'Vec<StorageMetadataV11>': Vec<StorageMetadataV11>;
'Vec<StorageMetadataV12>': Vec<StorageMetadataV12>;
'Vec<StorageMetadataV13>': Vec<StorageMetadataV13>;
'Vec<StorageMetadataV9>': Vec<StorageMetadataV9>;
'Vec<StorageProof>': Vec<StorageProof>;
'Vec<StoredPendingChange>': Vec<StoredPendingChange>;
@@ -1936,6 +1970,7 @@ declare module '@polkadot/types/types/registry' {
DoubleMapTypeV10: DoubleMapTypeV10;
DoubleMapTypeV11: DoubleMapTypeV11;
DoubleMapTypeV12: DoubleMapTypeV12;
DoubleMapTypeV13: DoubleMapTypeV13;
DoubleMapTypeV9: DoubleMapTypeV9;
DoubleVoteReport: DoubleVoteReport;
DownwardMessage: DownwardMessage;
@@ -1958,6 +1993,7 @@ declare module '@polkadot/types/types/registry' {
ErrorMetadataV10: ErrorMetadataV10;
ErrorMetadataV11: ErrorMetadataV11;
ErrorMetadataV12: ErrorMetadataV12;
ErrorMetadataV13: ErrorMetadataV13;
ErrorMetadataV9: ErrorMetadataV9;
EthAccount: EthAccount;
EthBlock: EthBlock;
@@ -1998,6 +2034,7 @@ declare module '@polkadot/types/types/registry' {
EventMetadataV10: EventMetadataV10;
EventMetadataV11: EventMetadataV11;
EventMetadataV12: EventMetadataV12;
EventMetadataV13: EventMetadataV13;
EventMetadataV9: EventMetadataV9;
EventRecord: EventRecord;
EvmAccount: EvmAccount;
@@ -2016,6 +2053,7 @@ declare module '@polkadot/types/types/registry' {
ExtrinsicMetadataLatest: ExtrinsicMetadataLatest;
ExtrinsicMetadataV11: ExtrinsicMetadataV11;
ExtrinsicMetadataV12: ExtrinsicMetadataV12;
ExtrinsicMetadataV13: ExtrinsicMetadataV13;
ExtrinsicOrHash: ExtrinsicOrHash;
ExtrinsicPayload: ExtrinsicPayload;
ExtrinsicPayloadUnknown: ExtrinsicPayloadUnknown;
@@ -2039,11 +2077,13 @@ declare module '@polkadot/types/types/registry' {
FunctionArgumentMetadataV10: FunctionArgumentMetadataV10;
FunctionArgumentMetadataV11: FunctionArgumentMetadataV11;
FunctionArgumentMetadataV12: FunctionArgumentMetadataV12;
FunctionArgumentMetadataV13: FunctionArgumentMetadataV13;
FunctionArgumentMetadataV9: FunctionArgumentMetadataV9;
FunctionMetadataLatest: FunctionMetadataLatest;
FunctionMetadataV10: FunctionMetadataV10;
FunctionMetadataV11: FunctionMetadataV11;
FunctionMetadataV12: FunctionMetadataV12;
FunctionMetadataV13: FunctionMetadataV13;
FunctionMetadataV9: FunctionMetadataV9;
FundIndex: FundIndex;
FundInfo: FundInfo;
@@ -2139,6 +2179,7 @@ declare module '@polkadot/types/types/registry' {
MapTypeV10: MapTypeV10;
MapTypeV11: MapTypeV11;
MapTypeV12: MapTypeV12;
MapTypeV13: MapTypeV13;
MapTypeV9: MapTypeV9;
MaybeRandomness: MaybeRandomness;
MaybeVrf: MaybeVrf;
@@ -2153,6 +2194,7 @@ declare module '@polkadot/types/types/registry' {
MetadataV10: MetadataV10;
MetadataV11: MetadataV11;
MetadataV12: MetadataV12;
MetadataV13: MetadataV13;
MetadataV9: MetadataV9;
MmrLeafProof: MmrLeafProof;
MmrRootHash: MmrRootHash;
@@ -2160,12 +2202,14 @@ declare module '@polkadot/types/types/registry' {
ModuleConstantMetadataV10: ModuleConstantMetadataV10;
ModuleConstantMetadataV11: ModuleConstantMetadataV11;
ModuleConstantMetadataV12: ModuleConstantMetadataV12;
ModuleConstantMetadataV13: ModuleConstantMetadataV13;
ModuleConstantMetadataV9: ModuleConstantMetadataV9;
ModuleId: ModuleId;
ModuleMetadataLatest: ModuleMetadataLatest;
ModuleMetadataV10: ModuleMetadataV10;
ModuleMetadataV11: ModuleMetadataV11;
ModuleMetadataV12: ModuleMetadataV12;
ModuleMetadataV13: ModuleMetadataV13;
ModuleMetadataV9: ModuleMetadataV9;
Moment: Moment;
MomentOf: MomentOf;
@@ -2191,6 +2235,8 @@ declare module '@polkadot/types/types/registry' {
NextAuthority: NextAuthority;
NextConfigDescriptor: NextConfigDescriptor;
NextConfigDescriptorV1: NextConfigDescriptorV1;
NMapTypeLatest: NMapTypeLatest;
NMapTypeV13: NMapTypeV13;
NodeRole: NodeRole;
Nominations: Nominations;
NominatorIndex: NominatorIndex;
@@ -2407,21 +2453,25 @@ declare module '@polkadot/types/types/registry' {
StorageEntryMetadataV10: StorageEntryMetadataV10;
StorageEntryMetadataV11: StorageEntryMetadataV11;
StorageEntryMetadataV12: StorageEntryMetadataV12;
StorageEntryMetadataV13: StorageEntryMetadataV13;
StorageEntryMetadataV9: StorageEntryMetadataV9;
StorageEntryModifierLatest: StorageEntryModifierLatest;
StorageEntryModifierV10: StorageEntryModifierV10;
StorageEntryModifierV11: StorageEntryModifierV11;
StorageEntryModifierV12: StorageEntryModifierV12;
StorageEntryModifierV13: StorageEntryModifierV13;
StorageEntryModifierV9: StorageEntryModifierV9;
StorageEntryTypeLatest: StorageEntryTypeLatest;
StorageEntryTypeV10: StorageEntryTypeV10;
StorageEntryTypeV11: StorageEntryTypeV11;
StorageEntryTypeV12: StorageEntryTypeV12;
StorageEntryTypeV13: StorageEntryTypeV13;
StorageEntryTypeV9: StorageEntryTypeV9;
StorageHasher: StorageHasher;
StorageHasherV10: StorageHasherV10;
StorageHasherV11: StorageHasherV11;
StorageHasherV12: StorageHasherV12;
StorageHasherV13: StorageHasherV13;
StorageHasherV9: StorageHasherV9;
StorageKey: StorageKey;
StorageKind: StorageKind;
@@ -2429,6 +2479,7 @@ declare module '@polkadot/types/types/registry' {
StorageMetadataV10: StorageMetadataV10;
StorageMetadataV11: StorageMetadataV11;
StorageMetadataV12: StorageMetadataV12;
StorageMetadataV13: StorageMetadataV13;
StorageMetadataV9: StorageMetadataV9;
StorageProof: StorageProof;
StoredPendingChange: StoredPendingChange;
@@ -246,22 +246,72 @@ export default {
StorageMetadataV12: 'StorageMetadataV11',
StorageHasherV12: 'StorageHasherV11',
// v13
DoubleMapTypeV13: 'DoubleMapTypeV12',
ErrorMetadataV13: 'ErrorMetadataV12',
EventMetadataV13: 'EventMetadataV12',
ExtrinsicMetadataV13: 'ExtrinsicMetadataV12',
FunctionArgumentMetadataV13: 'FunctionArgumentMetadataV12',
FunctionMetadataV13: 'FunctionMetadataV12',
MapTypeV13: 'MapTypeV12',
MetadataV13: {
modules: 'Vec<ModuleMetadataV13>',
extrinsic: 'ExtrinsicMetadataV13'
},
ModuleConstantMetadataV13: 'ModuleConstantMetadataV12',
ModuleMetadataV13: {
name: 'Text',
storage: 'Option<StorageMetadataV13>',
calls: 'Option<Vec<FunctionMetadataV13>>',
events: 'Option<Vec<EventMetadataV13>>',
constants: 'Vec<ModuleConstantMetadataV13>',
errors: 'Vec<ErrorMetadataV13>',
index: 'u8'
},
NMapTypeV13: {
hashers: 'Vec<StorageHasherV13>',
keyVec: 'Vec<Type>',
value: 'Type'
},
StorageEntryModifierV13: 'StorageEntryModifierV12',
StorageEntryMetadataV13: {
name: 'Text',
modifier: 'StorageEntryModifierV13',
type: 'StorageEntryTypeV13',
fallback: 'Bytes',
documentation: 'Vec<Text>'
},
StorageEntryTypeV13: {
_enum: {
Plain: 'Type',
Map: 'MapTypeV13',
DoubleMap: 'DoubleMapTypeV13',
NMap: 'NMapTypeV13'
}
},
StorageMetadataV13: {
prefix: 'Text',
items: 'Vec<StorageEntryMetadataV13>'
},
StorageHasherV13: 'StorageHasherV12',
// This always maps to the latest
DoubleMapTypeLatest: 'DoubleMapTypeV12',
ErrorMetadataLatest: 'ErrorMetadataV12',
EventMetadataLatest: 'EventMetadataV12',
ExtrinsicMetadataLatest: 'ExtrinsicMetadataV12',
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV12',
FunctionMetadataLatest: 'FunctionMetadataV12',
MapTypeLatest: 'MapTypeV12',
MetadataLatest: 'MetadataV12',
ModuleConstantMetadataLatest: 'ModuleConstantMetadataV12',
ModuleMetadataLatest: 'ModuleMetadataV12',
StorageEntryMetadataLatest: 'StorageEntryMetadataV12',
StorageEntryModifierLatest: 'StorageEntryModifierV12',
StorageEntryTypeLatest: 'StorageEntryTypeV12',
StorageMetadataLatest: 'StorageMetadataV12',
StorageHasher: 'StorageHasherV12',
DoubleMapTypeLatest: 'DoubleMapTypeV13',
ErrorMetadataLatest: 'ErrorMetadataV13',
EventMetadataLatest: 'EventMetadataV13',
ExtrinsicMetadataLatest: 'ExtrinsicMetadataV13',
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV13',
FunctionMetadataLatest: 'FunctionMetadataV13',
MapTypeLatest: 'MapTypeV13',
MetadataLatest: 'MetadataV13',
ModuleConstantMetadataLatest: 'ModuleConstantMetadataV13',
ModuleMetadataLatest: 'ModuleMetadataV13',
NMapTypeLatest: 'NMapTypeV13',
StorageEntryMetadataLatest: 'StorageEntryMetadataV13',
StorageEntryModifierLatest: 'StorageEntryModifierV13',
StorageEntryTypeLatest: 'StorageEntryTypeV13',
StorageMetadataLatest: 'StorageMetadataV13',
StorageHasher: 'StorageHasherV13',
// the enum containing all the mappings
MetadataAll: {
@@ -279,7 +329,8 @@ export default {
V9: 'MetadataV9',
V10: 'MetadataV10',
V11: 'MetadataV11',
V12: 'MetadataV12'
V12: 'MetadataV12',
V13: 'MetadataV13'
}
}
}
+101 -15
View File
@@ -4,7 +4,7 @@
import type { Bytes, Enum, Option, Struct, Text, Type, Vec, bool, u8 } from '@polkadot/types';
/** @name DoubleMapTypeLatest */
export interface DoubleMapTypeLatest extends DoubleMapTypeV12 {}
export interface DoubleMapTypeLatest extends DoubleMapTypeV13 {}
/** @name DoubleMapTypeV10 */
export interface DoubleMapTypeV10 extends Struct {
@@ -27,6 +27,9 @@ export interface DoubleMapTypeV11 extends Struct {
/** @name DoubleMapTypeV12 */
export interface DoubleMapTypeV12 extends DoubleMapTypeV11 {}
/** @name DoubleMapTypeV13 */
export interface DoubleMapTypeV13 extends DoubleMapTypeV12 {}
/** @name DoubleMapTypeV9 */
export interface DoubleMapTypeV9 extends Struct {
readonly hasher: StorageHasherV9;
@@ -37,7 +40,7 @@ export interface DoubleMapTypeV9 extends Struct {
}
/** @name ErrorMetadataLatest */
export interface ErrorMetadataLatest extends ErrorMetadataV12 {}
export interface ErrorMetadataLatest extends ErrorMetadataV13 {}
/** @name ErrorMetadataV10 */
export interface ErrorMetadataV10 extends ErrorMetadataV9 {}
@@ -48,6 +51,9 @@ export interface ErrorMetadataV11 extends ErrorMetadataV10 {}
/** @name ErrorMetadataV12 */
export interface ErrorMetadataV12 extends ErrorMetadataV11 {}
/** @name ErrorMetadataV13 */
export interface ErrorMetadataV13 extends ErrorMetadataV12 {}
/** @name ErrorMetadataV9 */
export interface ErrorMetadataV9 extends Struct {
readonly name: Text;
@@ -55,7 +61,7 @@ export interface ErrorMetadataV9 extends Struct {
}
/** @name EventMetadataLatest */
export interface EventMetadataLatest extends EventMetadataV12 {}
export interface EventMetadataLatest extends EventMetadataV13 {}
/** @name EventMetadataV10 */
export interface EventMetadataV10 extends EventMetadataV9 {}
@@ -66,6 +72,9 @@ export interface EventMetadataV11 extends EventMetadataV10 {}
/** @name EventMetadataV12 */
export interface EventMetadataV12 extends EventMetadataV11 {}
/** @name EventMetadataV13 */
export interface EventMetadataV13 extends EventMetadataV12 {}
/** @name EventMetadataV9 */
export interface EventMetadataV9 extends Struct {
readonly name: Text;
@@ -74,7 +83,7 @@ export interface EventMetadataV9 extends Struct {
}
/** @name ExtrinsicMetadataLatest */
export interface ExtrinsicMetadataLatest extends ExtrinsicMetadataV12 {}
export interface ExtrinsicMetadataLatest extends ExtrinsicMetadataV13 {}
/** @name ExtrinsicMetadataV11 */
export interface ExtrinsicMetadataV11 extends Struct {
@@ -85,8 +94,11 @@ export interface ExtrinsicMetadataV11 extends Struct {
/** @name ExtrinsicMetadataV12 */
export interface ExtrinsicMetadataV12 extends ExtrinsicMetadataV11 {}
/** @name ExtrinsicMetadataV13 */
export interface ExtrinsicMetadataV13 extends ExtrinsicMetadataV12 {}
/** @name FunctionArgumentMetadataLatest */
export interface FunctionArgumentMetadataLatest extends FunctionArgumentMetadataV12 {}
export interface FunctionArgumentMetadataLatest extends FunctionArgumentMetadataV13 {}
/** @name FunctionArgumentMetadataV10 */
export interface FunctionArgumentMetadataV10 extends FunctionArgumentMetadataV9 {}
@@ -97,6 +109,9 @@ export interface FunctionArgumentMetadataV11 extends FunctionArgumentMetadataV10
/** @name FunctionArgumentMetadataV12 */
export interface FunctionArgumentMetadataV12 extends FunctionArgumentMetadataV11 {}
/** @name FunctionArgumentMetadataV13 */
export interface FunctionArgumentMetadataV13 extends FunctionArgumentMetadataV12 {}
/** @name FunctionArgumentMetadataV9 */
export interface FunctionArgumentMetadataV9 extends Struct {
readonly name: Text;
@@ -104,7 +119,7 @@ export interface FunctionArgumentMetadataV9 extends Struct {
}
/** @name FunctionMetadataLatest */
export interface FunctionMetadataLatest extends FunctionMetadataV12 {}
export interface FunctionMetadataLatest extends FunctionMetadataV13 {}
/** @name FunctionMetadataV10 */
export interface FunctionMetadataV10 extends FunctionMetadataV9 {}
@@ -115,6 +130,9 @@ export interface FunctionMetadataV11 extends FunctionMetadataV10 {}
/** @name FunctionMetadataV12 */
export interface FunctionMetadataV12 extends FunctionMetadataV11 {}
/** @name FunctionMetadataV13 */
export interface FunctionMetadataV13 extends FunctionMetadataV12 {}
/** @name FunctionMetadataV9 */
export interface FunctionMetadataV9 extends Struct {
readonly name: Text;
@@ -123,7 +141,7 @@ export interface FunctionMetadataV9 extends Struct {
}
/** @name MapTypeLatest */
export interface MapTypeLatest extends MapTypeV12 {}
export interface MapTypeLatest extends MapTypeV13 {}
/** @name MapTypeV10 */
export interface MapTypeV10 extends Struct {
@@ -144,6 +162,9 @@ export interface MapTypeV11 extends Struct {
/** @name MapTypeV12 */
export interface MapTypeV12 extends MapTypeV11 {}
/** @name MapTypeV13 */
export interface MapTypeV13 extends MapTypeV12 {}
/** @name MapTypeV9 */
export interface MapTypeV9 extends Struct {
readonly hasher: StorageHasherV9;
@@ -162,10 +183,12 @@ export interface MetadataAll extends Enum {
readonly asV11: MetadataV11;
readonly isV12: boolean;
readonly asV12: MetadataV12;
readonly isV13: boolean;
readonly asV13: MetadataV13;
}
/** @name MetadataLatest */
export interface MetadataLatest extends MetadataV12 {}
export interface MetadataLatest extends MetadataV13 {}
/** @name MetadataV10 */
export interface MetadataV10 extends Struct {
@@ -184,13 +207,19 @@ export interface MetadataV12 extends Struct {
readonly extrinsic: ExtrinsicMetadataV12;
}
/** @name MetadataV13 */
export interface MetadataV13 extends Struct {
readonly modules: Vec<ModuleMetadataV13>;
readonly extrinsic: ExtrinsicMetadataV13;
}
/** @name MetadataV9 */
export interface MetadataV9 extends Struct {
readonly modules: Vec<ModuleMetadataV9>;
}
/** @name ModuleConstantMetadataLatest */
export interface ModuleConstantMetadataLatest extends ModuleConstantMetadataV12 {}
export interface ModuleConstantMetadataLatest extends ModuleConstantMetadataV13 {}
/** @name ModuleConstantMetadataV10 */
export interface ModuleConstantMetadataV10 extends ModuleConstantMetadataV9 {}
@@ -201,6 +230,9 @@ export interface ModuleConstantMetadataV11 extends ModuleConstantMetadataV10 {}
/** @name ModuleConstantMetadataV12 */
export interface ModuleConstantMetadataV12 extends ModuleConstantMetadataV11 {}
/** @name ModuleConstantMetadataV13 */
export interface ModuleConstantMetadataV13 extends ModuleConstantMetadataV12 {}
/** @name ModuleConstantMetadataV9 */
export interface ModuleConstantMetadataV9 extends Struct {
readonly name: Text;
@@ -210,7 +242,7 @@ export interface ModuleConstantMetadataV9 extends Struct {
}
/** @name ModuleMetadataLatest */
export interface ModuleMetadataLatest extends ModuleMetadataV12 {}
export interface ModuleMetadataLatest extends ModuleMetadataV13 {}
/** @name ModuleMetadataV10 */
export interface ModuleMetadataV10 extends Struct {
@@ -243,6 +275,17 @@ export interface ModuleMetadataV12 extends Struct {
readonly index: u8;
}
/** @name ModuleMetadataV13 */
export interface ModuleMetadataV13 extends Struct {
readonly name: Text;
readonly storage: Option<StorageMetadataV13>;
readonly calls: Option<Vec<FunctionMetadataV13>>;
readonly events: Option<Vec<EventMetadataV13>>;
readonly constants: Vec<ModuleConstantMetadataV13>;
readonly errors: Vec<ErrorMetadataV13>;
readonly index: u8;
}
/** @name ModuleMetadataV9 */
export interface ModuleMetadataV9 extends Struct {
readonly name: Text;
@@ -253,8 +296,18 @@ export interface ModuleMetadataV9 extends Struct {
readonly errors: Vec<ErrorMetadataV9>;
}
/** @name NMapTypeLatest */
export interface NMapTypeLatest extends NMapTypeV13 {}
/** @name NMapTypeV13 */
export interface NMapTypeV13 extends Struct {
readonly hashers: Vec<StorageHasherV13>;
readonly keyVec: Vec<Type>;
readonly value: Type;
}
/** @name StorageEntryMetadataLatest */
export interface StorageEntryMetadataLatest extends StorageEntryMetadataV12 {}
export interface StorageEntryMetadataLatest extends StorageEntryMetadataV13 {}
/** @name StorageEntryMetadataV10 */
export interface StorageEntryMetadataV10 extends Struct {
@@ -277,6 +330,15 @@ export interface StorageEntryMetadataV11 extends Struct {
/** @name StorageEntryMetadataV12 */
export interface StorageEntryMetadataV12 extends StorageEntryMetadataV11 {}
/** @name StorageEntryMetadataV13 */
export interface StorageEntryMetadataV13 extends Struct {
readonly name: Text;
readonly modifier: StorageEntryModifierV13;
readonly type: StorageEntryTypeV13;
readonly fallback: Bytes;
readonly documentation: Vec<Text>;
}
/** @name StorageEntryMetadataV9 */
export interface StorageEntryMetadataV9 extends Struct {
readonly name: Text;
@@ -287,7 +349,7 @@ export interface StorageEntryMetadataV9 extends Struct {
}
/** @name StorageEntryModifierLatest */
export interface StorageEntryModifierLatest extends StorageEntryModifierV12 {}
export interface StorageEntryModifierLatest extends StorageEntryModifierV13 {}
/** @name StorageEntryModifierV10 */
export interface StorageEntryModifierV10 extends StorageEntryModifierV9 {}
@@ -298,6 +360,9 @@ export interface StorageEntryModifierV11 extends StorageEntryModifierV10 {}
/** @name StorageEntryModifierV12 */
export interface StorageEntryModifierV12 extends StorageEntryModifierV11 {}
/** @name StorageEntryModifierV13 */
export interface StorageEntryModifierV13 extends StorageEntryModifierV12 {}
/** @name StorageEntryModifierV9 */
export interface StorageEntryModifierV9 extends Enum {
readonly isOptional: boolean;
@@ -306,7 +371,7 @@ export interface StorageEntryModifierV9 extends Enum {
}
/** @name StorageEntryTypeLatest */
export interface StorageEntryTypeLatest extends StorageEntryTypeV12 {}
export interface StorageEntryTypeLatest extends StorageEntryTypeV13 {}
/** @name StorageEntryTypeV10 */
export interface StorageEntryTypeV10 extends Enum {
@@ -331,6 +396,18 @@ export interface StorageEntryTypeV11 extends Enum {
/** @name StorageEntryTypeV12 */
export interface StorageEntryTypeV12 extends StorageEntryTypeV11 {}
/** @name StorageEntryTypeV13 */
export interface StorageEntryTypeV13 extends Enum {
readonly isPlain: boolean;
readonly asPlain: Type;
readonly isMap: boolean;
readonly asMap: MapTypeV13;
readonly isDoubleMap: boolean;
readonly asDoubleMap: DoubleMapTypeV13;
readonly isNMap: boolean;
readonly asNMap: NMapTypeV13;
}
/** @name StorageEntryTypeV9 */
export interface StorageEntryTypeV9 extends Enum {
readonly isPlain: boolean;
@@ -342,7 +419,7 @@ export interface StorageEntryTypeV9 extends Enum {
}
/** @name StorageHasher */
export interface StorageHasher extends StorageHasherV12 {}
export interface StorageHasher extends StorageHasherV13 {}
/** @name StorageHasherV10 */
export interface StorageHasherV10 extends Enum {
@@ -368,6 +445,9 @@ export interface StorageHasherV11 extends Enum {
/** @name StorageHasherV12 */
export interface StorageHasherV12 extends StorageHasherV11 {}
/** @name StorageHasherV13 */
export interface StorageHasherV13 extends StorageHasherV12 {}
/** @name StorageHasherV9 */
export interface StorageHasherV9 extends Enum {
readonly isBlake2128: boolean;
@@ -378,7 +458,7 @@ export interface StorageHasherV9 extends Enum {
}
/** @name StorageMetadataLatest */
export interface StorageMetadataLatest extends StorageMetadataV12 {}
export interface StorageMetadataLatest extends StorageMetadataV13 {}
/** @name StorageMetadataV10 */
export interface StorageMetadataV10 extends Struct {
@@ -395,6 +475,12 @@ export interface StorageMetadataV11 extends Struct {
/** @name StorageMetadataV12 */
export interface StorageMetadataV12 extends StorageMetadataV11 {}
/** @name StorageMetadataV13 */
export interface StorageMetadataV13 extends Struct {
readonly prefix: Text;
readonly items: Vec<StorageEntryMetadataV13>;
}
/** @name StorageMetadataV9 */
export interface StorageMetadataV9 extends Struct {
readonly prefix: Text;
+17 -9
View File
@@ -33,13 +33,15 @@ const HASHER_MAP: Record<keyof typeof AllHashers, [number, boolean]> = {
};
function getStorageType (type: StorageEntryTypeLatest): [boolean, string] {
if (type.isPlain) {
return [false, type.asPlain.toString()];
if (type.isMap) {
return [false, type.asMap.value.toString()];
} else if (type.isDoubleMap) {
return [false, type.asDoubleMap.value.toString()];
} else if (type.isNMap) {
return [false, type.asNMap.value.toString()];
}
return [false, type.asMap.value.toString()];
return [false, type.asPlain.toString()];
}
// we unwrap the type here, turning into an output usable for createType
@@ -105,7 +107,7 @@ function decodeHashers <A extends AnyTuple> (registry: Registry, value: Uint8Arr
/** @internal */
function decodeArgsFromMeta <A extends AnyTuple> (registry: Registry, value: Uint8Array, meta?: StorageEntryMetadataLatest): A {
if (!meta || !(meta.type.isDoubleMap || meta.type.isMap)) {
if (!meta || !(meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap)) {
return [] as unknown as A;
}
@@ -115,14 +117,20 @@ function decodeArgsFromMeta <A extends AnyTuple> (registry: Registry, value: Uin
return decodeHashers(registry, value, [
[mapInfo.hasher, mapInfo.key.toString()]
]);
} else if (meta.type.isDoubleMap) {
const mapInfo = meta.type.asDoubleMap;
return decodeHashers(registry, value, [
[mapInfo.hasher, mapInfo.key1.toString()],
[mapInfo.key2Hasher, mapInfo.key2.toString()]
]);
}
const mapInfo = meta.type.asDoubleMap;
const mapInfo = meta.type.asNMap;
return decodeHashers(registry, value, [
[mapInfo.hasher, mapInfo.key1.toString()],
[mapInfo.key2Hasher, mapInfo.key2.toString()]
]);
return decodeHashers(registry, value, mapInfo.hashers.map((h, i) =>
[h, mapInfo.keyVec[i].toString()]
));
}
/** @internal */
+2 -2
View File
@@ -9,8 +9,8 @@ import { Text } from './Text';
/**
* @name Type
* @description
* This is a extended version of String, specifically to handle types. Here we rely fully
* on what string provides us, however we also adjust the types received from the runtime,
* This is a extended version of Text, specifically to handle types. Here we rely fully
* on what Text provides us, however we also adjust the types received from the runtime,
* i.e. we remove the `T::` prefixes found in some types for consistency across implementation.
*/
export class Type extends Text {