Support Metadata V8 (#1441)
* Support Metadata V8 * Update V7 references, introduce *Latest (as applicable) * Add v8 static metadata * Bump to latest metadata
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { ModuleConstantMetadataV7 } from '@polkadot/types/interfaces';
|
||||
import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface ConstantCodec extends Codec {
|
||||
meta: ModuleConstantMetadataV7;
|
||||
meta: ModuleConstantMetadataLatest;
|
||||
}
|
||||
|
||||
export type ModuleConstants = Record<string, Codec>;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Call, FunctionMetadataV7 } from '@polkadot/types/interfaces';
|
||||
import { Call, FunctionMetadataLatest } from '@polkadot/types/interfaces';
|
||||
import { CallFunction } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types';
|
||||
@@ -21,7 +21,7 @@ export default function createDescriptor (
|
||||
section: string,
|
||||
sectionIndex: number,
|
||||
methodIndex: number,
|
||||
callMetadata: FunctionMetadataV7
|
||||
callMetadata: FunctionMetadataLatest
|
||||
): CallFunction {
|
||||
const callIndex = new Uint8Array([sectionIndex, methodIndex]);
|
||||
const expectedArgs = callMetadata.args;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { createType, Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/v7/static';
|
||||
import json from '@polkadot/types/Metadata/static';
|
||||
|
||||
import fromMetadata from '.';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { Calls, ModulesWithCalls } from '@polkadot/types/types';
|
||||
|
||||
import { ModuleMetadataV7 } from '@polkadot/types/Metadata/v7/Metadata';
|
||||
import { ModuleMetadataV8 } from '@polkadot/types/Metadata/v8/Metadata';
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -19,7 +19,7 @@ import createUnchecked from './createUnchecked';
|
||||
export default function fromMetadata (metadata: Metadata): ModulesWithCalls {
|
||||
return metadata.asLatest.modules
|
||||
.filter(({ calls }): boolean => calls.isSome)
|
||||
.reduce((result, modul: ModuleMetadataV7, sectionIndex): ModulesWithCalls => {
|
||||
.reduce((result, modul: ModuleMetadataV8, sectionIndex): ModulesWithCalls => {
|
||||
const section = stringCamelCase(modul.name.toString());
|
||||
|
||||
result[section] = modul.calls.unwrap().reduce((newModule, callMetadata, methodIndex): Calls => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Codec } from '@polkadot/types/types';
|
||||
import BN from 'bn.js';
|
||||
import { Bytes, Compact, StorageKey, U8a } from '@polkadot/types';
|
||||
import { createType, createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v7/Storage';
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v8/Storage';
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
@@ -121,8 +121,8 @@ function extendLinkedMap ({ meta: { documentation, name, type } }: CreateItemFn,
|
||||
// meta fallback only applies to actual entry values, create one for head
|
||||
headFn.meta = new StorageEntryMetadata({
|
||||
name,
|
||||
modifier: createType('StorageEntryModifierV7', 1), // required
|
||||
type: new StorageEntryType(createType('PlainTypeV7', type.asMap.key), 0),
|
||||
modifier: createType('StorageEntryModifierLatest', 1), // required
|
||||
type: new StorageEntryType(createType('PlainTypeLatest', type.asMap.key), 0),
|
||||
fallback: new Bytes(createTypeUnsafe(type.asMap.key.toString()).toHex()),
|
||||
documentation
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v7/Storage';
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v8/Storage';
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { createType, Text, Vec } from '@polkadot/types';
|
||||
|
||||
@@ -19,7 +19,7 @@ const createRuntimeFunction = (method: string, key: string, { documentation, typ
|
||||
{
|
||||
meta: {
|
||||
documentation: new Vec(Text, [documentation]),
|
||||
modifier: createType('StorageEntryModifierV7', 1), // required
|
||||
modifier: createType('StorageEntryModifierLatest', 1), // required
|
||||
type: new StorageEntryType(type, 0),
|
||||
toJSON: (): any => key
|
||||
} as unknown as StorageEntryMetadata,
|
||||
|
||||
@@ -15,6 +15,7 @@ import rpcMetadataV4 from '@polkadot/types/Metadata/v4/static';
|
||||
import rpcMetadataV5 from '@polkadot/types/Metadata/v5/static';
|
||||
import rpcMetadataV6 from '@polkadot/types/Metadata/v6/static';
|
||||
import rpcMetadataV7 from '@polkadot/types/Metadata/v7/static';
|
||||
import rpcMetadataV8 from '@polkadot/types/Metadata/v8/static';
|
||||
|
||||
import Api from '.';
|
||||
|
||||
@@ -212,3 +213,9 @@ formattingTests('v7', fromMetadata(new Metadata(rpcMetadataV7)), [
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
formattingTests('v8', fromMetadata(new Metadata(rpcMetadataV8)), [
|
||||
'0xec8f96437274a883afcac82d01a9defeb68209cd4f2c084632813692aa5e65ad',
|
||||
'0x1dbb0224910f42a14e7f1406b24c6fe8157296691b02a78756e01946038fffab',
|
||||
'0xc7879f4faa637a90d782070a3cb6be99a9fb0316e19a0454ce93c4f0a34712f1'
|
||||
]);
|
||||
|
||||
@@ -15,6 +15,7 @@ import MetadataV4 from './v4';
|
||||
import MetadataV5 from './v5';
|
||||
import MetadataV6 from './v6';
|
||||
import MetadataV7 from './v7';
|
||||
import MetadataV8 from './v8';
|
||||
import v0ToV1 from './v0/toV1';
|
||||
import v1ToV2 from './v1/toV2';
|
||||
import v2ToV3 from './v2/toV3';
|
||||
@@ -22,11 +23,12 @@ import v3ToV4 from './v3/toV4';
|
||||
import v4ToV5 from './v4/toV5';
|
||||
import v5ToV6 from './v5/toV6';
|
||||
import v6ToV7 from './v6/toV7';
|
||||
import v7ToV8 from './v7/toV8';
|
||||
import { getUniqTypes, toCallsOnly } from './util';
|
||||
|
||||
type MetaMapped = MetadataV0 | MetadataV1 | MetadataV2 | MetadataV3 | MetadataV4 | MetadataV5 | MetadataV6 | MetadataV7;
|
||||
type MetaVersions = 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
||||
type MetaAsX = 'asV0' | 'asV1' | 'asV2' | 'asV3' | 'asV4' | 'asV5' | 'asV6';
|
||||
type MetaVersions = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
||||
type MetaAsX = 'asV0' | 'asV1' | 'asV2' | 'asV3' | 'asV4' | 'asV5' | 'asV6' | 'asV7';
|
||||
|
||||
class MetadataEnum extends Enum {
|
||||
public constructor (value?: any, index?: number) {
|
||||
@@ -38,7 +40,8 @@ class MetadataEnum extends Enum {
|
||||
V4: MetadataV4, // once rolled-out, can replace this with MetadataDeprecated
|
||||
V5: MetadataV5, // once rolled-out, can replace this with MetadataDeprecated
|
||||
V6: MetadataV6, // once rolled-out, can replace this with MetadataDeprecated
|
||||
V7: MetadataV7
|
||||
V7: MetadataV7, // once rolled-out, can replace this with MetadataDeprecated
|
||||
V8: MetadataV8
|
||||
}, value, index);
|
||||
}
|
||||
|
||||
@@ -114,6 +117,15 @@ class MetadataEnum extends Enum {
|
||||
return this.value as MetadataV7;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V8 object
|
||||
*/
|
||||
public get asV8 (): MetadataV8 {
|
||||
assert(this.isV8, `Cannot convert '${this.type}' via asV8`);
|
||||
|
||||
return this.value as MetadataV8;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if Deprecated
|
||||
*/
|
||||
@@ -176,6 +188,13 @@ class MetadataEnum extends Enum {
|
||||
public get isV7 (): boolean {
|
||||
return this.type === 'V7';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if V8
|
||||
*/
|
||||
public get isV8 (): boolean {
|
||||
return this.type === 'V8';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,6 +312,13 @@ export default class MetadataVersioned extends Struct {
|
||||
return this.getVersion(7, v6ToV7);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V8 object
|
||||
*/
|
||||
public get asV8 (): MetadataV8 {
|
||||
return this.getVersion(8, v7ToV8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped metadata as a limited calls-only (latest) version
|
||||
*/
|
||||
@@ -306,8 +332,8 @@ export default class MetadataVersioned extends Struct {
|
||||
/**
|
||||
* @description Returns the wrapped values as a latest version object
|
||||
*/
|
||||
public get asLatest (): MetadataV7 {
|
||||
return this.asV7;
|
||||
public get asLatest (): MetadataV8 {
|
||||
return this.asV8;
|
||||
}
|
||||
|
||||
public getUniqTypes (throwError: boolean): string[] {
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import metadata from './v7/static';
|
||||
import metadata from './v8/static';
|
||||
|
||||
export default metadata;
|
||||
|
||||
@@ -32,7 +32,7 @@ type Item = {
|
||||
type Storage = Option<Vec<Item> | {
|
||||
// v0
|
||||
functions?: Vec<Item>;
|
||||
// V7
|
||||
// V7+
|
||||
items?: Vec<Item>;
|
||||
} & Codec>;
|
||||
|
||||
|
||||
@@ -34,18 +34,18 @@ export function decodeLatestSubstrate<Modules extends Codec> (
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a `version`, MetadataV7 and MetadataV{version} should output the same
|
||||
* Given a `version`, MetadataLatest and MetadataV{version} should output the same
|
||||
* unique types.
|
||||
*/
|
||||
export function toV7<Modules extends Codec> (version: number, rpcData: string): void {
|
||||
it(`converts v${version} to v7`, (): void => {
|
||||
export function toLatest<Modules extends Codec> (version: number, rpcData: string): void {
|
||||
it(`converts v${version} to v8`, (): void => {
|
||||
const metadata = new Metadata(rpcData)[`asV${version}` as keyof Metadata];
|
||||
const metadataV7 = new Metadata(rpcData).asV7;
|
||||
const metadataV8 = new Metadata(rpcData).asLatest;
|
||||
|
||||
expect(
|
||||
getUniqTypes(metadata as unknown as MetadataInterface<Modules>, true)
|
||||
).toEqual(
|
||||
getUniqTypes(metadataV7, true)
|
||||
getUniqTypes(metadataV8, true)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import MetadataV7 from '../v7';
|
||||
import MetadataV8 from '../v8';
|
||||
|
||||
/**
|
||||
* @description Convert from MetadataV7 to a stripped representation of MetadataV7
|
||||
* @description Convert from MetadataV8 to a stripped representation of MetadataV8
|
||||
*/
|
||||
export default function toCallsOnly ({ modules }: MetadataV7): any {
|
||||
return new MetadataV7({
|
||||
export default function toCallsOnly ({ modules }: MetadataV8): any {
|
||||
return new MetadataV8({
|
||||
// FIXME, this needs typing, not any
|
||||
modules: modules.map(({ calls, name }): any => ({
|
||||
name,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { createType } from '../../codec';
|
||||
import Metadata from '../';
|
||||
import latestSubstrateV0 from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { defaultValues, toV7 } from '../util/testUtil';
|
||||
import { defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('Metadata', (): void => {
|
||||
it('works with fallback', (): void => {
|
||||
@@ -27,7 +27,7 @@ describe('Metadata', (): void => {
|
||||
expect(json).toEqual(latestSubstrateV0);
|
||||
});
|
||||
|
||||
toV7(0, rpcData);
|
||||
toLatest(0, rpcData);
|
||||
|
||||
defaultValues(rpcData);
|
||||
});
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV1', (): void => {
|
||||
decodeLatestSubstrate(1, rpcData, staticSubstrate);
|
||||
|
||||
toV7(1, rpcData);
|
||||
toLatest(1, rpcData);
|
||||
|
||||
defaultValues(rpcData);
|
||||
});
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV2', (): void => {
|
||||
decodeLatestSubstrate(2, rpcData, staticSubstrate);
|
||||
|
||||
toV7(2, rpcData);
|
||||
toLatest(2, rpcData);
|
||||
|
||||
defaultValues(rpcData);
|
||||
});
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV3', (): void => {
|
||||
decodeLatestSubstrate(3, rpcData, staticSubstrate);
|
||||
|
||||
toV7(3, rpcData);
|
||||
toLatest(3, rpcData);
|
||||
|
||||
defaultValues(rpcData);
|
||||
});
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import staticSubstrate from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV4', (): void => {
|
||||
decodeLatestSubstrate(4, rpcData, staticSubstrate);
|
||||
|
||||
toV7(4, rpcData);
|
||||
toLatest(4, rpcData);
|
||||
|
||||
defaultValues(rpcData);
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import polkadotJson from './static-polkadot.json';
|
||||
import substrateJson from './static-substrate.json';
|
||||
import polkadotData from './static.polkadot';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV5 (substrate)', (): void => {
|
||||
decodeLatestSubstrate(5, substrateData, substrateJson);
|
||||
|
||||
toV7(5, substrateData);
|
||||
toLatest(5, substrateData);
|
||||
|
||||
defaultValues(substrateData);
|
||||
});
|
||||
@@ -19,7 +19,7 @@ describe('MetadataV5 (substrate)', (): void => {
|
||||
describe('MetadataV5 (polkadot)', (): void => {
|
||||
decodeLatestSubstrate(5, polkadotData, polkadotJson);
|
||||
|
||||
toV7(5, polkadotData);
|
||||
toLatest(5, polkadotData);
|
||||
|
||||
defaultValues(polkadotData);
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import polkadotJson from './static-polkadot.json';
|
||||
import substrateJson from './static-substrate.json';
|
||||
import polkadotData from './static.polkadot';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV6 (substrate)', (): void => {
|
||||
decodeLatestSubstrate(6, substrateData, substrateJson);
|
||||
|
||||
toV7(6, substrateData);
|
||||
toLatest(6, substrateData);
|
||||
|
||||
defaultValues(substrateData);
|
||||
});
|
||||
@@ -19,7 +19,7 @@ describe('MetadataV6 (substrate)', (): void => {
|
||||
describe('MetadataV6 (polkadot)', (): void => {
|
||||
decodeLatestSubstrate(6, polkadotData, polkadotJson);
|
||||
|
||||
toV7(6, polkadotData);
|
||||
toLatest(6, polkadotData);
|
||||
|
||||
defaultValues(polkadotData);
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ import polkadotJson from './static-polkadot.json';
|
||||
import substrateJson from './static-substrate.json';
|
||||
import polkadotData from './static.polkadot';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toV7 } from '../util/testUtil';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV7 (substrate)', (): void => {
|
||||
decodeLatestSubstrate(7, substrateData, substrateJson);
|
||||
|
||||
toV7(7, substrateData);
|
||||
toLatest(7, substrateData);
|
||||
|
||||
defaultValues(substrateData);
|
||||
});
|
||||
@@ -19,7 +19,7 @@ describe('MetadataV7 (substrate)', (): void => {
|
||||
describe('MetadataV7 (polkadot)', (): void => {
|
||||
decodeLatestSubstrate(7, polkadotData, polkadotJson);
|
||||
|
||||
toV7(7, polkadotData);
|
||||
toLatest(7, polkadotData);
|
||||
|
||||
defaultValues(polkadotData);
|
||||
});
|
||||
|
||||
@@ -55,13 +55,6 @@ export class ModuleMetadataV7 extends Struct {
|
||||
return this.get('name') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module prefix
|
||||
*/
|
||||
public get prefix (): Text {
|
||||
return this.get('prefix') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import MetadataV7 from './Metadata';
|
||||
import MetadataV8 from '../v8';
|
||||
import { ModuleMetadataV8 } from '../v8/Metadata';
|
||||
|
||||
/**
|
||||
* Convert from MetadataV7 to MetadataV8
|
||||
*/
|
||||
export default function toV8 ({ modules }: MetadataV7): MetadataV8 {
|
||||
return new MetadataV8({
|
||||
modules: modules.map(({ calls, constants, events, name, storage }): ModuleMetadataV8 =>
|
||||
new ModuleMetadataV8({
|
||||
calls,
|
||||
constants,
|
||||
errors: [],
|
||||
events,
|
||||
name,
|
||||
storage
|
||||
})
|
||||
)
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV8 (substrate)', (): void => {
|
||||
decodeLatestSubstrate(8, substrateData, substrateJson);
|
||||
|
||||
toLatest(8, substrateData);
|
||||
|
||||
defaultValues(substrateData);
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ErrorMetadataV8, EventMetadataV8, FunctionMetadataV8, ModuleConstantMetadataV8 } from '../../interfaces/metadata';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { StorageMetadata } from './Storage';
|
||||
|
||||
// Note the following errors are non-duplicated and fill the first 2 slots for
|
||||
// each of the modules - this means that other errors start at index 2
|
||||
//
|
||||
// {
|
||||
// "name": "Other",
|
||||
// "documentation": [
|
||||
// "Other unspecified error"
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// "name": "CannotLookup",
|
||||
// "documentation": [
|
||||
// "Can not lookup"
|
||||
// ]
|
||||
// }
|
||||
|
||||
/**
|
||||
* @name ModuleMetadataV8
|
||||
* @description
|
||||
* The definition of a module in the system
|
||||
*/
|
||||
export class ModuleMetadataV8 extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: 'Text',
|
||||
storage: Option.with(StorageMetadata),
|
||||
calls: Option.with('Vec<FunctionMetadataV8>'),
|
||||
events: Option.with('Vec<EventMetadataV8>'),
|
||||
constants: 'Vec<ModuleConstantMetadataV8>',
|
||||
errors: 'Vec<ErrorMetadataV8>'
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vec<FunctionMetadataV8>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadataV8>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module constants
|
||||
*/
|
||||
public get constants (): Vec<ModuleConstantMetadataV8> {
|
||||
return this.get('constants') as Vec<ModuleConstantMetadataV8>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module errors
|
||||
*/
|
||||
public get errors (): Vec<ErrorMetadataV8> {
|
||||
return this.get('errors') as Vec<ErrorMetadataV8>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vec<EventMetadataV8>> {
|
||||
return this.get('events') as Option<Vec<EventMetadataV8>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module name
|
||||
*/
|
||||
public get name (): Text {
|
||||
return this.get('name') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<StorageMetadata> {
|
||||
return this.get('storage') as Option<StorageMetadata>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name MetadataV8
|
||||
* @description
|
||||
* The runtime metadata as a decoded structure
|
||||
*/
|
||||
export default class MetadataV8 extends Struct implements MetadataInterface<ModuleMetadataV8> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vec.with(ModuleMetadataV8)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vec<ModuleMetadataV8> {
|
||||
return this.get('modules') as Vec<ModuleMetadataV8>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { StorageEntryMetadata, StorageEntryMetadataValue, StorageEntryType, StorageMetadata } from '../v7/Storage';
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import MetadataV8, { ModuleMetadataV8 } from './Metadata';
|
||||
|
||||
export default MetadataV8;
|
||||
|
||||
export {
|
||||
ModuleMetadataV8
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -47,7 +47,7 @@ export class TypeRegistry {
|
||||
? type
|
||||
: JSON.stringify(type);
|
||||
|
||||
// we alreday have this type, remove the classes registered for it
|
||||
// we already have this type, remove the classes registered for it
|
||||
if (this._classes.has(name)) {
|
||||
this._classes.delete(name);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import { DispatchResult, DispatchResultOf } from '@polkadot/types/interfaces/uti
|
||||
import { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';
|
||||
import { EcdsaSignature, EthereumAddress } from '@polkadot/types/interfaces/claims';
|
||||
import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParachainDispatchOrigin, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { CallMetadataV0, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, EventMetadataV0, EventMetadataV1, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, MapTypeV0, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MetadataV0, MetadataV1, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleMetadataV0, ModuleMetadataV1, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeV0, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, RuntimeModuleMetadataV0, StorageEntryModifierV6, StorageEntryModifierV7, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageMetadataV0 } from '@polkadot/types/interfaces/metadata';
|
||||
import { CallMetadataV0, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, ErrorMetadataV8, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, MapTypeV0, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MetadataV0, MetadataV1, ModuleConstantMetadataLatest, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleMetadataV0, ModuleMetadataV1, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, RuntimeModuleMetadataV0, StorageEntryModifierLatest, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageMetadataV0 } from '@polkadot/types/interfaces/metadata';
|
||||
import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RpcMethods, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/rpc';
|
||||
|
||||
export interface InterfaceRegistry {
|
||||
@@ -942,6 +942,51 @@ export interface InterfaceRegistry {
|
||||
StorageEntryModifierV7: StorageEntryModifierV7;
|
||||
'Option<StorageEntryModifierV7>': Option<StorageEntryModifierV7>;
|
||||
'Vec<StorageEntryModifierV7>': Vec<StorageEntryModifierV7>;
|
||||
DoubleMapTypeV8: DoubleMapTypeV8;
|
||||
'Option<DoubleMapTypeV8>': Option<DoubleMapTypeV8>;
|
||||
'Vec<DoubleMapTypeV8>': Vec<DoubleMapTypeV8>;
|
||||
ErrorMetadataV8: ErrorMetadataV8;
|
||||
'Option<ErrorMetadataV8>': Option<ErrorMetadataV8>;
|
||||
'Vec<ErrorMetadataV8>': Vec<ErrorMetadataV8>;
|
||||
EventMetadataV8: EventMetadataV8;
|
||||
'Option<EventMetadataV8>': Option<EventMetadataV8>;
|
||||
'Vec<EventMetadataV8>': Vec<EventMetadataV8>;
|
||||
FunctionArgumentMetadataV8: FunctionArgumentMetadataV8;
|
||||
'Option<FunctionArgumentMetadataV8>': Option<FunctionArgumentMetadataV8>;
|
||||
'Vec<FunctionArgumentMetadataV8>': Vec<FunctionArgumentMetadataV8>;
|
||||
FunctionMetadataV8: FunctionMetadataV8;
|
||||
'Option<FunctionMetadataV8>': Option<FunctionMetadataV8>;
|
||||
'Vec<FunctionMetadataV8>': Vec<FunctionMetadataV8>;
|
||||
MapTypeV8: MapTypeV8;
|
||||
'Option<MapTypeV8>': Option<MapTypeV8>;
|
||||
'Vec<MapTypeV8>': Vec<MapTypeV8>;
|
||||
ModuleConstantMetadataV8: ModuleConstantMetadataV8;
|
||||
'Option<ModuleConstantMetadataV8>': Option<ModuleConstantMetadataV8>;
|
||||
'Vec<ModuleConstantMetadataV8>': Vec<ModuleConstantMetadataV8>;
|
||||
PlainTypeV8: PlainTypeV8;
|
||||
'Option<PlainTypeV8>': Option<PlainTypeV8>;
|
||||
'Vec<PlainTypeV8>': Vec<PlainTypeV8>;
|
||||
StorageEntryModifierV8: StorageEntryModifierV8;
|
||||
'Option<StorageEntryModifierV8>': Option<StorageEntryModifierV8>;
|
||||
'Vec<StorageEntryModifierV8>': Vec<StorageEntryModifierV8>;
|
||||
EventMetadataLatest: EventMetadataLatest;
|
||||
'Option<EventMetadataLatest>': Option<EventMetadataLatest>;
|
||||
'Vec<EventMetadataLatest>': Vec<EventMetadataLatest>;
|
||||
FunctionArgumentMetadataLatest: FunctionArgumentMetadataLatest;
|
||||
'Option<FunctionArgumentMetadataLatest>': Option<FunctionArgumentMetadataLatest>;
|
||||
'Vec<FunctionArgumentMetadataLatest>': Vec<FunctionArgumentMetadataLatest>;
|
||||
FunctionMetadataLatest: FunctionMetadataLatest;
|
||||
'Option<FunctionMetadataLatest>': Option<FunctionMetadataLatest>;
|
||||
'Vec<FunctionMetadataLatest>': Vec<FunctionMetadataLatest>;
|
||||
ModuleConstantMetadataLatest: ModuleConstantMetadataLatest;
|
||||
'Option<ModuleConstantMetadataLatest>': Option<ModuleConstantMetadataLatest>;
|
||||
'Vec<ModuleConstantMetadataLatest>': Vec<ModuleConstantMetadataLatest>;
|
||||
PlainTypeLatest: PlainTypeLatest;
|
||||
'Option<PlainTypeLatest>': Option<PlainTypeLatest>;
|
||||
'Vec<PlainTypeLatest>': Vec<PlainTypeLatest>;
|
||||
StorageEntryModifierLatest: StorageEntryModifierLatest;
|
||||
'Option<StorageEntryModifierLatest>': Option<StorageEntryModifierLatest>;
|
||||
'Vec<StorageEntryModifierLatest>': Vec<StorageEntryModifierLatest>;
|
||||
ApiId: ApiId;
|
||||
'Option<ApiId>': Option<ApiId>;
|
||||
'Vec<ApiId>': Vec<ApiId>;
|
||||
|
||||
@@ -185,6 +185,28 @@ export default {
|
||||
MapTypeV7: 'MapTypeV6',
|
||||
ModuleConstantMetadataV7: 'ModuleConstantMetadataV6',
|
||||
PlainTypeV7: 'Type',
|
||||
StorageEntryModifierV7: 'StorageEntryModifierV6'
|
||||
StorageEntryModifierV7: 'StorageEntryModifierV6',
|
||||
|
||||
// v8
|
||||
DoubleMapTypeV8: 'DoubleMapTypeV7',
|
||||
ErrorMetadataV8: {
|
||||
name: 'Text',
|
||||
documentation: 'Vec<Text>'
|
||||
},
|
||||
EventMetadataV8: 'EventMetadataV7',
|
||||
FunctionArgumentMetadataV8: 'FunctionArgumentMetadataV7',
|
||||
FunctionMetadataV8: 'FunctionMetadataV7',
|
||||
MapTypeV8: 'MapTypeV7',
|
||||
ModuleConstantMetadataV8: 'ModuleConstantMetadataV7',
|
||||
PlainTypeV8: 'Type',
|
||||
StorageEntryModifierV8: 'StorageEntryModifierV7',
|
||||
|
||||
// This always maps to the latest
|
||||
EventMetadataLatest: 'EventMetadataV8',
|
||||
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV8',
|
||||
FunctionMetadataLatest: 'FunctionMetadataV8',
|
||||
ModuleConstantMetadataLatest: 'ModuleConstantMetadataV8',
|
||||
PlainTypeLatest: 'PlainTypeV8',
|
||||
StorageEntryModifierLatest: 'StorageEntryModifierV8'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,6 +59,20 @@ export interface DoubleMapTypeV6 extends DoubleMapTypeV5 {}
|
||||
/** DoubleMapTypeV6 */
|
||||
export interface DoubleMapTypeV7 extends DoubleMapTypeV6 {}
|
||||
|
||||
/** DoubleMapTypeV7 */
|
||||
export interface DoubleMapTypeV8 extends DoubleMapTypeV7 {}
|
||||
|
||||
/** Struct */
|
||||
export interface ErrorMetadataV8 extends Struct {
|
||||
/** Text */
|
||||
readonly name: Text;
|
||||
/** Vec<Text> */
|
||||
readonly documentation: Vec<Text>;
|
||||
}
|
||||
|
||||
/** EventMetadataV8 */
|
||||
export interface EventMetadataLatest extends EventMetadataV8 {}
|
||||
|
||||
/** Struct */
|
||||
export interface EventMetadataV0 extends Struct {
|
||||
/** Text */
|
||||
@@ -90,6 +104,12 @@ export interface EventMetadataV6 extends EventMetadataV5 {}
|
||||
/** EventMetadataV6 */
|
||||
export interface EventMetadataV7 extends EventMetadataV6 {}
|
||||
|
||||
/** EventMetadataV7 */
|
||||
export interface EventMetadataV8 extends EventMetadataV7 {}
|
||||
|
||||
/** FunctionArgumentMetadataV8 */
|
||||
export interface FunctionArgumentMetadataLatest extends FunctionArgumentMetadataV8 {}
|
||||
|
||||
/** Struct */
|
||||
export interface FunctionArgumentMetadataV0 extends Struct {
|
||||
/** Text */
|
||||
@@ -119,6 +139,12 @@ export interface FunctionArgumentMetadataV6 extends FunctionArgumentMetadataV5 {
|
||||
/** FunctionArgumentMetadataV6 */
|
||||
export interface FunctionArgumentMetadataV7 extends FunctionArgumentMetadataV6 {}
|
||||
|
||||
/** FunctionArgumentMetadataV7 */
|
||||
export interface FunctionArgumentMetadataV8 extends FunctionArgumentMetadataV7 {}
|
||||
|
||||
/** FunctionMetadataV8 */
|
||||
export interface FunctionMetadataLatest extends FunctionMetadataV8 {}
|
||||
|
||||
/** Struct */
|
||||
export interface FunctionMetadataV0 extends Struct {
|
||||
/** u16 */
|
||||
@@ -159,6 +185,9 @@ export interface FunctionMetadataV6 extends FunctionMetadataV5 {}
|
||||
/** FunctionMetadataV6 */
|
||||
export interface FunctionMetadataV7 extends FunctionMetadataV6 {}
|
||||
|
||||
/** FunctionMetadataV7 */
|
||||
export interface FunctionMetadataV8 extends FunctionMetadataV7 {}
|
||||
|
||||
/** Struct */
|
||||
export interface MapTypeV0 extends Struct {
|
||||
/** Type */
|
||||
@@ -201,6 +230,9 @@ export interface MapTypeV6 extends MapTypeV5 {}
|
||||
/** MapTypeV6 */
|
||||
export interface MapTypeV7 extends MapTypeV6 {}
|
||||
|
||||
/** MapTypeV7 */
|
||||
export interface MapTypeV8 extends MapTypeV7 {}
|
||||
|
||||
/** Struct */
|
||||
export interface MetadataV0 extends Struct {
|
||||
/** OuterEventMetadataV0 */
|
||||
@@ -217,6 +249,9 @@ export interface MetadataV1 extends Struct {
|
||||
readonly modules: Vec<ModuleMetadataV1>;
|
||||
}
|
||||
|
||||
/** ModuleConstantMetadataV8 */
|
||||
export interface ModuleConstantMetadataLatest extends ModuleConstantMetadataV8 {}
|
||||
|
||||
/** Struct */
|
||||
export interface ModuleConstantMetadataV6 extends Struct {
|
||||
/** Text */
|
||||
@@ -232,6 +267,9 @@ export interface ModuleConstantMetadataV6 extends Struct {
|
||||
/** ModuleConstantMetadataV6 */
|
||||
export interface ModuleConstantMetadataV7 extends ModuleConstantMetadataV6 {}
|
||||
|
||||
/** ModuleConstantMetadataV7 */
|
||||
export interface ModuleConstantMetadataV8 extends ModuleConstantMetadataV7 {}
|
||||
|
||||
/** Struct */
|
||||
export interface ModuleMetadataV0 extends Struct {
|
||||
/** Text */
|
||||
@@ -286,6 +324,9 @@ export interface OuterEventMetadataV0 extends Struct {
|
||||
readonly events: Vec<OuterEventEventMetadataV0>;
|
||||
}
|
||||
|
||||
/** PlainTypeV8 */
|
||||
export interface PlainTypeLatest extends PlainTypeV8 {}
|
||||
|
||||
/** Type */
|
||||
export interface PlainTypeV0 extends Type {}
|
||||
|
||||
@@ -307,6 +348,9 @@ export interface PlainTypeV6 extends Type {}
|
||||
/** Type */
|
||||
export interface PlainTypeV7 extends Type {}
|
||||
|
||||
/** Type */
|
||||
export interface PlainTypeV8 extends Type {}
|
||||
|
||||
/** Struct */
|
||||
export interface RuntimeModuleMetadataV0 extends Struct {
|
||||
/** Text */
|
||||
@@ -317,12 +361,18 @@ export interface RuntimeModuleMetadataV0 extends Struct {
|
||||
readonly storage: Option<StorageMetadataV0>;
|
||||
}
|
||||
|
||||
/** StorageEntryModifierV8 */
|
||||
export interface StorageEntryModifierLatest extends StorageEntryModifierV8 {}
|
||||
|
||||
/** StorageFunctionModifierV5 */
|
||||
export interface StorageEntryModifierV6 extends StorageFunctionModifierV5 {}
|
||||
|
||||
/** StorageEntryModifierV6 */
|
||||
export interface StorageEntryModifierV7 extends StorageEntryModifierV6 {}
|
||||
|
||||
/** StorageEntryModifierV7 */
|
||||
export interface StorageEntryModifierV8 extends StorageEntryModifierV7 {}
|
||||
|
||||
/** Struct */
|
||||
export interface StorageFunctionMetadataV0 extends Struct {
|
||||
/** Text */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { FunctionMetadataV7 } from '../../interfaces/metadata/types';
|
||||
import { FunctionMetadataLatest } from '../../interfaces/metadata/types';
|
||||
import { Address, Balance, Call, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, Index } from '../../interfaces/runtime';
|
||||
import { AnyU8a, ArgsDef, Codec, ExtrinsicPayloadValue, IExtrinsic, IHash, IKeyringPair, InterfaceTypes, SignatureOptions } from '../../types';
|
||||
|
||||
@@ -174,9 +174,9 @@ export default class Extrinsic extends Base<ExtrinsicVx | ExtrinsicUnknown> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[FunctionMetadataV7]] that describes the extrinsic
|
||||
* @description The [[FunctionMetadataLatest]] that describes the extrinsic
|
||||
*/
|
||||
public get meta (): FunctionMetadataV7 {
|
||||
public get meta (): FunctionMetadataLatest {
|
||||
return this.method.meta;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { FunctionArgumentMetadataV7, FunctionMetadataV7 } from '../../interfaces/metadata';
|
||||
import { FunctionArgumentMetadataLatest, FunctionMetadataLatest } from '../../interfaces/metadata';
|
||||
import { AnyU8a, ArgsDef, CallFunction, Codec, IMethod, ModulesWithCalls } from '../../types';
|
||||
|
||||
import { assert, isHex, isObject, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
@@ -18,7 +18,7 @@ interface DecodeMethodInput {
|
||||
|
||||
interface DecodedMethod extends DecodeMethodInput {
|
||||
argsDef: ArgsDef;
|
||||
meta: FunctionMetadataV7;
|
||||
meta: FunctionMetadataLatest;
|
||||
}
|
||||
|
||||
const FN_UNKNOWN: Partial<CallFunction> = {
|
||||
@@ -46,9 +46,9 @@ export class CallIndex extends U8aFixed {
|
||||
* {@link https://github.com/paritytech/wiki/blob/master/Extrinsic.md#the-extrinsic-format-for-node}.
|
||||
*/
|
||||
export default class Call extends Struct implements IMethod {
|
||||
protected _meta: FunctionMetadataV7;
|
||||
protected _meta: FunctionMetadataLatest;
|
||||
|
||||
public constructor (value: any, meta?: FunctionMetadataV7) {
|
||||
public constructor (value: any, meta?: FunctionMetadataLatest) {
|
||||
const decoded = Call.decodeCall(value, meta);
|
||||
|
||||
super({
|
||||
@@ -69,7 +69,7 @@ export default class Call extends Struct implements IMethod {
|
||||
* @param _meta - Metadata to use, so that `injectMethods` lookup is not
|
||||
* necessary.
|
||||
*/
|
||||
private static decodeCall (value: DecodedMethod | Uint8Array | string = new Uint8Array(), _meta?: FunctionMetadataV7): DecodedMethod {
|
||||
private static decodeCall (value: DecodedMethod | Uint8Array | string = new Uint8Array(), _meta?: FunctionMetadataLatest): DecodedMethod {
|
||||
if (isHex(value) || isU8a(value)) {
|
||||
return Call.decodeCallViaU8a(u8aToU8a(value), _meta);
|
||||
} else if (isObject(value) && value.callIndex && value.args) {
|
||||
@@ -79,7 +79,7 @@ export default class Call extends Struct implements IMethod {
|
||||
throw new Error(`Call: Cannot decode value '${value}' of type ${typeof value}`);
|
||||
}
|
||||
|
||||
private static decodeCallViaObject (value: DecodedMethod, _meta?: FunctionMetadataV7): DecodedMethod {
|
||||
private static decodeCallViaObject (value: DecodedMethod, _meta?: FunctionMetadataLatest): DecodedMethod {
|
||||
// destructure value, we only pass args/methodsIndex out
|
||||
const { args, callIndex } = value;
|
||||
|
||||
@@ -99,7 +99,7 @@ export default class Call extends Struct implements IMethod {
|
||||
};
|
||||
}
|
||||
|
||||
private static decodeCallViaU8a (value: Uint8Array, _meta?: FunctionMetadataV7): DecodedMethod {
|
||||
private static decodeCallViaU8a (value: Uint8Array, _meta?: FunctionMetadataLatest): DecodedMethod {
|
||||
// The first 2 bytes are the callIndex
|
||||
const callIndex = value.subarray(0, 2);
|
||||
|
||||
@@ -115,7 +115,7 @@ export default class Call extends Struct implements IMethod {
|
||||
}
|
||||
|
||||
// If the extrinsic function has an argument of type `Origin`, we ignore it
|
||||
public static filterOrigin (meta?: FunctionMetadataV7): FunctionArgumentMetadataV7[] {
|
||||
public static filterOrigin (meta?: FunctionMetadataLatest): FunctionArgumentMetadataLatest[] {
|
||||
// FIXME should be `arg.type !== Origin`, but doesn't work...
|
||||
return meta
|
||||
? meta.args.filter(({ type }): boolean =>
|
||||
@@ -143,7 +143,7 @@ export default class Call extends Struct implements IMethod {
|
||||
*
|
||||
* @param meta - The function metadata used to get the definition.
|
||||
*/
|
||||
private static getArgsDef (meta: FunctionMetadataV7): ArgsDef {
|
||||
private static getArgsDef (meta: FunctionMetadataLatest): ArgsDef {
|
||||
return Call.filterOrigin(meta).reduce((result, { name, type }): ArgsDef => {
|
||||
const Type = getTypeClass(
|
||||
getTypeDef(type.toString())
|
||||
@@ -205,7 +205,7 @@ export default class Call extends Struct implements IMethod {
|
||||
/**
|
||||
* @description The [[FunctionMetadata]]
|
||||
*/
|
||||
public get meta (): FunctionMetadataV7 {
|
||||
public get meta (): FunctionMetadataLatest {
|
||||
return this._meta;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeDef } from '../../codec/types';
|
||||
import { EventMetadataV7 } from '../../interfaces/metadata';
|
||||
import { EventMetadataLatest } from '../../interfaces/metadata';
|
||||
import { EventId } from '../../interfaces/system';
|
||||
import { Constructor, Codec } from '../../types';
|
||||
|
||||
@@ -23,7 +23,7 @@ const EventTypes: Record<string, Constructor<EventData>> = {};
|
||||
* Wrapper for the actual data that forms part of an [[Event]]
|
||||
*/
|
||||
export class EventData extends Tuple {
|
||||
private _meta: EventMetadataV7;
|
||||
private _meta: EventMetadataLatest;
|
||||
|
||||
private _method: string;
|
||||
|
||||
@@ -31,7 +31,7 @@ export class EventData extends Tuple {
|
||||
|
||||
private _typeDef: TypeDef[];
|
||||
|
||||
public constructor (Types: Constructor[], value: Uint8Array, typeDef: TypeDef[], meta: EventMetadataV7, section: string, method: string) {
|
||||
public constructor (Types: Constructor[], value: Uint8Array, typeDef: TypeDef[], meta: EventMetadataLatest, section: string, method: string) {
|
||||
super(Types, value);
|
||||
|
||||
this._meta = meta;
|
||||
@@ -43,7 +43,7 @@ export class EventData extends Tuple {
|
||||
/**
|
||||
* @description The wrapped [[EventMetadata]]
|
||||
*/
|
||||
public get meta (): EventMetadataV7 {
|
||||
public get meta (): EventMetadataLatest {
|
||||
return this._meta;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ export default class Event extends Struct {
|
||||
/**
|
||||
* @description The [[EventMetadata]] with the documentation
|
||||
*/
|
||||
public get meta (): EventMetadataV7 {
|
||||
public get meta (): EventMetadataLatest {
|
||||
return this.data.meta;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import rpcDataV4 from '@polkadot/types/Metadata/v4/static';
|
||||
import rpcDataV5 from '@polkadot/types/Metadata/v5/static';
|
||||
import rpcDataV6 from '@polkadot/types/Metadata/v6/static';
|
||||
import rpcDataV7 from '@polkadot/types/Metadata/v7/static';
|
||||
import rpcDataV8 from '@polkadot/types/Metadata/v8/static';
|
||||
|
||||
import Metadata from '../Metadata';
|
||||
import StorageKey from './StorageKey';
|
||||
@@ -181,4 +182,32 @@ describe('StorageKey', (): void => {
|
||||
).toEqual(Uint8Array.from([1, 1, 48, 7, 201, 255, 112, 39, 246, 89, 0, 171, 205, 252, 164, 253, 177, 7, 234, 212, 126, 42, 158, 53, 88, 224, 27, 105, 27, 15, 74, 95, 133, 24, 212, 135, 50, 102, 20, 240, 102, 65, 99, 8, 191, 106, 164, 229, 4, 29, 25, 73, 146, 142, 75, 38, 237, 233, 142, 60, 235, 179, 106, 59, 23, 38]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('with MetadataV8', (): void => {
|
||||
const storage = fromMetadata(new Metadata(rpcDataV8));
|
||||
|
||||
it('should correctly get the EventTopics double map storage key (hex)', (): void => {
|
||||
expect(
|
||||
new StorageKey([
|
||||
storage
|
||||
.system
|
||||
.eventTopics,
|
||||
['any', [1, 2, 3]]
|
||||
])
|
||||
.toHex()
|
||||
).toBe('0x3007c9ff7027f65900abcdfca4fdb107ead47e2a9e3558e01b691b0f4a5f8518d487326614f066416308bf6aa4e5041d1949928e4b26ede98e3cebb36a3b1726');
|
||||
});
|
||||
|
||||
it('should correctly get the EventTopics double map storage key (u8a)', (): void => {
|
||||
expect(
|
||||
new StorageKey([
|
||||
storage
|
||||
.system
|
||||
.eventTopics,
|
||||
['any', [1, 2, 3]]
|
||||
])
|
||||
.toU8a()
|
||||
).toEqual(Uint8Array.from([1, 1, 48, 7, 201, 255, 112, 39, 246, 89, 0, 171, 205, 252, 164, 253, 177, 7, 234, 212, 126, 42, 158, 53, 88, 224, 27, 105, 27, 15, 74, 95, 133, 24, 212, 135, 50, 102, 20, 240, 102, 65, 99, 8, 191, 106, 164, 229, 4, 29, 25, 73, 146, 142, 75, 38, 237, 233, 142, 60, 235, 179, 106, 59, 23, 38]));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
import { assert, isFunction, isString, isU8a } from '@polkadot/util';
|
||||
|
||||
import { StorageEntryMetadata as MetaV7 } from '../Metadata/v7/Storage';
|
||||
import { StorageEntryMetadata as MetaV8 } from '../Metadata/v8/Storage';
|
||||
import { AnyU8a } from '../types';
|
||||
import Bytes from './Bytes';
|
||||
|
||||
export interface StorageEntry {
|
||||
(arg?: any): Uint8Array;
|
||||
headKey?: Uint8Array;
|
||||
meta: MetaV7;
|
||||
meta: MetaV8;
|
||||
method: string;
|
||||
prefix: string;
|
||||
section: string;
|
||||
@@ -36,7 +36,7 @@ interface StorageKeyExtra {
|
||||
* constructed by passing in a raw key or a StorageEntry with (optional) arguments.
|
||||
*/
|
||||
export default class StorageKey extends Bytes {
|
||||
private _meta?: MetaV7;
|
||||
private _meta?: MetaV8;
|
||||
|
||||
private _method?: string;
|
||||
|
||||
@@ -86,7 +86,7 @@ export default class StorageKey extends Bytes {
|
||||
throw new Error(`Unable to convert input ${value} to StorageKey`);
|
||||
}
|
||||
|
||||
public static getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): MetaV7 | undefined {
|
||||
public static getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): MetaV8 | undefined {
|
||||
if (value instanceof StorageKey) {
|
||||
return value.meta;
|
||||
} else if (isFunction(value)) {
|
||||
@@ -117,7 +117,7 @@ export default class StorageKey extends Bytes {
|
||||
/**
|
||||
* @description The metadata or `undefined` when not available
|
||||
*/
|
||||
public get meta (): MetaV7 | undefined {
|
||||
public get meta (): MetaV8 | undefined {
|
||||
return this._meta;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import interfaces from '../../../type-jsonrpc/src';
|
||||
import Call from '../primitive/Generic/Call';
|
||||
import Metadata from '../Metadata';
|
||||
import rpcdata from '../Metadata/static';
|
||||
import MetadataV7, { ModuleMetadataV7 } from '../Metadata/v7';
|
||||
import MetadataV8, { ModuleMetadataV8 } from '../Metadata/v8';
|
||||
|
||||
const ANCHOR_TOP = '';
|
||||
const LINK_BACK_TO_TOP = '';
|
||||
@@ -72,7 +72,7 @@ function sortByName<T extends { name: any }> (a: T, b: T): number {
|
||||
return nameA.localeCompare(nameB);
|
||||
}
|
||||
|
||||
function addConstants (metadata: MetadataV7): string {
|
||||
function addConstants (metadata: MetadataV8): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Constants${DESC_CONSTANTS}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
let renderAnchors = '';
|
||||
@@ -103,7 +103,7 @@ function addConstants (metadata: MetadataV7): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
function addEvents (metadata: MetadataV7): string {
|
||||
function addEvents (metadata: MetadataV8): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Events${DESC_EVENTS}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
let renderAnchors = '';
|
||||
@@ -136,9 +136,9 @@ function addEvents (metadata: MetadataV7): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
function addExtrinsics (metadata: MetadataV7): string {
|
||||
function addExtrinsics (metadata: MetadataV8): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Extrinsics${DESC_EXTRINSICS}`;
|
||||
const orderedSections = metadata.modules.map((i): ModuleMetadataV7 => i).sort(sortByName);
|
||||
const orderedSections = metadata.modules.map((i): ModuleMetadataV8 => i).sort(sortByName);
|
||||
let renderAnchors = '';
|
||||
const sections = orderedSections.reduce((md, meta): string => {
|
||||
if (meta.calls.isNone || !meta.calls.unwrap().length) {
|
||||
@@ -168,7 +168,7 @@ function addExtrinsics (metadata: MetadataV7): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
function addStorage (metadata: MetadataV7): string {
|
||||
function addStorage (metadata: MetadataV8): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Storage${DESC_STORAGE}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
let renderAnchors = '';
|
||||
@@ -229,22 +229,22 @@ function writeToRpcMd (): void {
|
||||
writeFile('docs/substrate/rpc.md', addRpc());
|
||||
}
|
||||
|
||||
function writeToConstantsMd (metadata: MetadataV7): void {
|
||||
function writeToConstantsMd (metadata: MetadataV8): void {
|
||||
writeFile('docs/substrate/constants.md', addConstants(metadata));
|
||||
}
|
||||
|
||||
function writeToStorageMd (metadata: MetadataV7): void {
|
||||
function writeToStorageMd (metadata: MetadataV8): void {
|
||||
const options = { flags: 'r', encoding: 'utf8' };
|
||||
const data = fs.readFileSync('docs/substrate/storage-known.md', options);
|
||||
|
||||
writeFile('docs/substrate/storage.md', addStorage(metadata), data);
|
||||
}
|
||||
|
||||
function writeToExtrinsicsMd (metadata: MetadataV7): void {
|
||||
function writeToExtrinsicsMd (metadata: MetadataV8): void {
|
||||
writeFile('docs/substrate/extrinsics.md', addExtrinsics(metadata));
|
||||
}
|
||||
|
||||
function writeToEventsMd (metadata: MetadataV7): void {
|
||||
function writeToEventsMd (metadata: MetadataV8): void {
|
||||
writeFile('docs/substrate/events.md', addEvents(metadata));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import fs from 'fs';
|
||||
import { stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../..';
|
||||
import { ModuleMetadataV7 } from '../../Metadata/v7/Metadata';
|
||||
import { StorageEntryMetadata } from '../../Metadata/v7/Storage';
|
||||
import staticData from '../../Metadata/v7/static';
|
||||
import { ModuleMetadataV8 } from '../../Metadata/v8/Metadata';
|
||||
import { StorageEntryMetadata } from '../../Metadata/v8/Storage';
|
||||
import staticData from '../../Metadata/static';
|
||||
import { createImportCode, createImports, FOOTER, formatType, getSimilarTypes, HEADER, indent, setImports, TypeImports } from '../util';
|
||||
|
||||
// From a storage entry metadata, we return [args, returnType]
|
||||
@@ -64,7 +64,7 @@ function generateEntry (storageEntry: StorageEntryMetadata, imports: TypeImports
|
||||
}
|
||||
|
||||
// Generate types for one module
|
||||
function generateModule (modul: ModuleMetadataV7, imports: TypeImports): string[] {
|
||||
function generateModule (modul: ModuleMetadataV8, imports: TypeImports): string[] {
|
||||
if (modul.storage.isNone) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { FunctionMetadataV7 } from './interfaces/metadata';
|
||||
import { FunctionMetadataLatest } from './interfaces/metadata';
|
||||
import { Balance, Index } from './interfaces/runtime';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@@ -20,7 +20,7 @@ export type InterfaceTypes = keyof InterfaceRegistry;
|
||||
export interface CallFunction {
|
||||
(...args: any[]): Call;
|
||||
callIndex: Uint8Array;
|
||||
meta: FunctionMetadataV7;
|
||||
meta: FunctionMetadataLatest;
|
||||
method: string;
|
||||
section: string;
|
||||
toJSON: () => any;
|
||||
@@ -167,7 +167,7 @@ export interface IMethod extends Codec {
|
||||
readonly data: Uint8Array;
|
||||
readonly hash: IHash;
|
||||
readonly hasOrigin: boolean;
|
||||
readonly meta: FunctionMetadataV7;
|
||||
readonly meta: FunctionMetadataLatest;
|
||||
}
|
||||
|
||||
interface ExtrinsicSignatureBase {
|
||||
|
||||
Reference in New Issue
Block a user