Remove deprecated Metadata getters (#1315)

* Remove deprecated Metadata getters

* Start metadata with som injected types

* Cleanup V0 somewhat with injected types

* Re-generate interfaces

* Extract some Storage type definitions

* Remove unneeded Calls & Constants files in metadata
This commit is contained in:
Jaco Greeff
2019-08-16 14:51:14 +02:00
committed by GitHub
parent facdd27117
commit f30354ead4
50 changed files with 560 additions and 833 deletions
-62
View File
@@ -1,62 +0,0 @@
// 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 Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import U16 from '../../primitive/U16';
export class OuterDispatchCall extends Struct {
public constructor (value?: any) {
super({
name: Text,
prefix: Text,
index: U16
}, value);
}
/**
* @description The [[U16]] index for the call
*/
public get index (): U16 {
return this.get('index') as U16;
}
/**
* @description The name for the call
*/
public get name (): Text {
return this.get('name') as Text;
}
/**
* @description The call prefix (or section)
*/
public get prefix (): Text {
return this.get('prefix') as Text;
}
}
export class OuterDispatchMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
calls: Vec.with(OuterDispatchCall)
}, value);
}
/**
* @description The [[OuterDispathCall]] wrapped
*/
public get calls (): Vec<OuterDispatchCall> {
return this.get('calls') as Vec<OuterDispatchCall>;
}
/**
* @description The name for the dispatch
*/
public get name (): Text {
return this.get('name') as Text;
}
}
+5 -54
View File
@@ -2,72 +2,23 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventMetadataV0 } from '../../interfaces/metadata/types';
import Struct from '../../codec/Struct';
import Tuple from '../../codec/Tuple';
import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
export class EventMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
args: Vec.with(Type),
documentation: Vec.with(Text)
}, value);
}
/**
* @description The arguments of [[Type]]
*/
public get args (): Vec<Type> {
return this.get('args') as Vec<Type>;
}
/**
* @description The arguments of [[Type]]
* @deprecated Use `.args` instead
*/
public get arguments (): Vec<Type> {
return this.args;
}
/**
* @description The [[Text]] documentation
*/
public get documentation (): Vec<Text> {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The name for the event
*/
public get name (): Text {
return this.get('name') as Text;
}
}
export class OuterEventEventMetadata extends Tuple {
public constructor (value?: any) {
super({
Text,
'Vec<EventMetadata>': Vec.with(EventMetadata)
}, value);
super(['Text', 'Vec<EventMetadataV0>'], value);
}
/**
* @description The [[EventMetadata]]
*/
public get events (): Vec<EventMetadata> {
return this[1] as Vec<EventMetadata>;
public get events (): Vec<EventMetadataV0> {
return this[1] as Vec<EventMetadataV0>;
}
/**
+16 -16
View File
@@ -2,6 +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 { OuterDispatchMetadataV0, OuterDispatchCallV0 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import { hexToU8a, isHex, isU8a } from '@polkadot/util';
@@ -10,9 +11,8 @@ import Compact from '../../codec/Compact';
import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import { flattenUniq, validateTypes } from '../util';
import { OuterDispatchMetadata, OuterDispatchCall } from './Calls';
import { OuterEventMetadata, OuterEventEventMetadata } from './Events';
import { RuntimeModuleMetadata } from './Modules';
import { RuntimeModuleMetadataV0 } from './Modules';
// Decodes the runtime metadata as passed through from the `state_getMetadata` call.
@@ -21,12 +21,12 @@ import { RuntimeModuleMetadata } from './Modules';
* @description
* The runtime metadata as a decoded structure
*/
export default class MetadataV0 extends Struct implements MetadataInterface<RuntimeModuleMetadata> {
export default class MetadataV0 extends Struct implements MetadataInterface<RuntimeModuleMetadataV0> {
public constructor (value?: any) {
super({
outerEvent: OuterEventMetadata,
modules: Vec.with(RuntimeModuleMetadata),
outerDispatch: OuterDispatchMetadata
modules: Vec.with(RuntimeModuleMetadataV0),
outerDispatch: 'OuterDispatchMetadataV0'
}, MetadataV0.decodeMetadata(value));
}
@@ -55,8 +55,8 @@ export default class MetadataV0 extends Struct implements MetadataInterface<Runt
/**
* @description Wrapped [[OuterDispatchCall]]
*/
public get calls (): Vec<OuterDispatchCall> {
return (this.get('outerDispatch') as OuterDispatchMetadata).calls;
public get calls (): Vec<OuterDispatchCallV0> {
return (this.get('outerDispatch') as OuterDispatchMetadataV0).calls;
}
/**
@@ -69,14 +69,14 @@ export default class MetadataV0 extends Struct implements MetadataInterface<Runt
/**
* @description Wrapped [[RuntimeModuleMetadata]]
*/
public get modules (): Vec<RuntimeModuleMetadata> {
return this.get('modules') as Vec<RuntimeModuleMetadata>;
public get modules (): Vec<RuntimeModuleMetadataV0> {
return this.get('modules') as Vec<RuntimeModuleMetadataV0>;
}
private get argNames (): string[][][] {
return this.modules.map((modul): string[][] =>
modul.module.call.functions.map((fn): string[] =>
fn.args.map((argument): string => argument.type.toString())
return this.modules.map(({ module: { call: { functions } } }): string[][] =>
functions.map(({ args }): string[] =>
args.map((arg): string => arg.type.toString())
)
);
}
@@ -92,10 +92,10 @@ export default class MetadataV0 extends Struct implements MetadataInterface<Runt
private get storageNames (): string[][][] {
return this.modules.map((modul): string[][] =>
modul.storage.isSome
? modul.storage.unwrap().functions.map((fn): string[] =>
fn.type.isMap
? [fn.type.asMap.key.toString(), fn.type.asMap.value.toString()]
: [fn.type.asType.toString()]
? modul.storage.unwrap().functions.map(({ type }): string[] =>
type.isMap
? [type.asMap.key.toString(), type.asMap.value.toString()]
: [type.asType.toString()]
)
: []
);
+12 -136
View File
@@ -2,152 +2,28 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ModuleMetadataV0 } from '../../interfaces/types';
import Option from '../../codec/Option';
import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
import U16 from '../../primitive/U16';
import { StorageMetadata } from './Storage';
import { StorageMetadataV0 } from './Storage';
export class FunctionArgumentMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
type: Type
}, value);
}
/**
* @description The argument name
*/
public get name (): Text {
return this.get('name') as Text;
}
/**
* @description The [[Type]]
*/
public get type (): Type {
return this.get('type') as Type;
}
}
export class FunctionMetadata extends Struct {
public constructor (value?: any) {
super({
id: U16,
name: Text,
args: Vec.with(FunctionArgumentMetadata),
documentation: Vec.with(Text)
}, value);
}
/**
* @description The arguments of [[Type]]
*/
public get args (): Vec<FunctionArgumentMetadata> {
return this.get('args') as Vec<FunctionArgumentMetadata>;
}
/**
* @description The [[FunctionArgumentMetadata]] for arguments
* @deprecated Use `.args` instead
*/
public get arguments (): Vec<FunctionArgumentMetadata> {
return this.get('arguments') as Vec<FunctionArgumentMetadata>;
}
/**
* @description The [[Text]] documentation
*/
public get documentation (): Vec<Text> {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The `[sectionIndex, methodIndex]` call id
*/
public get id (): U16 {
return this.get('id') as U16;
}
/**
* @description The call name
*/
public get name (): Text {
return this.get('name') as Text;
}
}
export class CallMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
functions: Vec.with(FunctionMetadata)
}, value);
}
/**
* @description The functions available as [[FunctionMetadata]]
*/
public get functions (): Vec<FunctionMetadata> {
return this.get('functions') as Vec<FunctionMetadata>;
}
/**
* @description The section name
*/
public get name (): Text {
return this.get('name') as Text;
}
}
export class ModuleMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
call: CallMetadata
}, value);
}
/**
* @description The calls as [[FunctionMetadata]]
*/
public get call (): CallMetadata {
return this.get('call') as CallMetadata;
}
/**
* @description The name
*/
public get name (): Text {
return this.get('name') as Text;
}
}
export class RuntimeModuleMetadata extends Struct {
export class RuntimeModuleMetadataV0 extends Struct {
public constructor (value?: any) {
super({
prefix: Text,
module: ModuleMetadata,
storage: Option.with(StorageMetadata)
module: 'ModuleMetadataV0',
storage: Option.with(StorageMetadataV0)
}, value);
}
/**
* @description The [[ModuleMetadata]]
* @description The [[ModuleMetadataV0]]
*/
public get module (): ModuleMetadata {
return this.get('module') as ModuleMetadata;
public get module (): ModuleMetadataV0 {
return this.get('module') as ModuleMetadataV0;
}
/**
@@ -158,9 +34,9 @@ export class RuntimeModuleMetadata extends Struct {
}
/**
* @description The optional [[StorageMetadata]]
* @description The optional [[StorageMetadataV0]]
*/
public get storage (): Option<StorageMetadata> {
return this.get('storage') as Option<StorageMetadata>;
public get storage (): Option<StorageMetadataV0> {
return this.get('storage') as Option<StorageMetadataV0>;
}
}
+1 -17
View File
@@ -145,14 +145,6 @@ export class StorageFunctionMetadata extends Struct {
}, value);
}
/**
* @description The default value of the storage function
* @deprecated Use `.fallback` instead.
*/
public get default (): Bytes {
return this.fallback;
}
/**
* @description The default value of the storage function
*/
@@ -167,14 +159,6 @@ export class StorageFunctionMetadata extends Struct {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The key name
*/
@@ -197,7 +181,7 @@ export class StorageFunctionMetadata extends Struct {
}
}
export class StorageMetadata extends Struct {
export class StorageMetadataV0 extends Struct {
public constructor (value?: any) {
super({
prefix: Text,
+9 -10
View File
@@ -3,32 +3,31 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EventMetadataV1, FunctionMetadataV1 } from '../../interfaces/metadata/types';
import { stringUpperFirst } from '@polkadot/util';
import { Option, Vec } from '../../codec';
import MetadataV0 from './Metadata';
import { RuntimeModuleMetadata } from './Modules';
import { RuntimeModuleMetadataV0 } from './Modules';
import { Text } from '../../primitive';
import { FunctionMetadata } from '../v1/Calls';
import { EventMetadata } from '../v1/Events';
import MetadataV1, { ModuleMetadata as ModuleMetadataV1 } from '../v1/Metadata';
import { StorageFunctionMetadata } from '../v1/Storage';
function toV1Calls (modul: RuntimeModuleMetadata): Option<FunctionMetadata> {
function toV1Calls (modul: RuntimeModuleMetadataV0): Option<FunctionMetadataV1> {
return modul.module.call.functions.length === 0
? new Option(Vec.with(FunctionMetadata))
: new Option(Vec.with(FunctionMetadata), modul.module.call.functions);
? new Option(Vec.with('FunctionMetadataV1'))
: new Option(Vec.with('FunctionMetadataV1'), modul.module.call.functions);
}
function toV1Events (metadataV0: MetadataV0, prefix: Text): Option<EventMetadata> {
function toV1Events (metadataV0: MetadataV0, prefix: Text): Option<EventMetadataV1> {
const events = metadataV0.events.find((event): boolean => event.name.eq(prefix));
return events
? new Option(Vec.with(EventMetadata), events.events)
: new Option(Vec.with(EventMetadata));
? new Option(Vec.with('EventMetadataV1'), events.events)
: new Option(Vec.with('EventMetadataV1'));
}
function toV1Storage (modul: RuntimeModuleMetadata): Option<StorageFunctionMetadata> {
function toV1Storage (modul: RuntimeModuleMetadataV0): Option<StorageFunctionMetadata> {
return modul.storage.isNone
? new Option(Vec.with(StorageFunctionMetadata))
: new Option(
-75
View File
@@ -1,75 +0,0 @@
// 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 Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
export class FunctionArgumentMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
type: Type
}, value);
}
/**
* @description The argument name
*/
public get name (): Text {
return this.get('name') as Text;
}
/**
* @description The [[Type]]
*/
public get type (): Type {
return this.get('type') as Type;
}
}
/**
* @name FunctionMetadata
* @description
* The definition of a call
*/
export class FunctionMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
args: Vec.with(FunctionArgumentMetadata),
documentation: Vec.with(Text)
}, value);
}
/**
* @description The [[FunctionArgumentMetadata]] for arguments
*/
public get args (): Vec<FunctionArgumentMetadata> {
return this.get('args') as Vec<FunctionArgumentMetadata>;
}
/**
* @description The [[Text]] documentation
*/
public get documentation (): Vec<Text> {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The call name
*/
public get name (): Text {
return this.get('name') as Text;
}
}
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V0 and V1
export { EventMetadata } from '../v0/Events';
+7 -8
View File
@@ -2,6 +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 { EventMetadataV1, FunctionMetadataV1 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,8 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { EventMetadata } from './Events';
import { StorageFunctionMetadata } from './Storage';
/**
@@ -25,23 +24,23 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata))
calls: Option.with(Vec.with('FunctionMetadataV1')),
events: Option.with(Vec.with('EventMetadataV1'))
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV1>> {
return this.get('calls') as Option<Vec<FunctionMetadataV1>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV1>> {
return this.get('events') as Option<Vec<EventMetadataV1>>;
}
/**
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V1 and V2
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v1/Calls';
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V1 and V2
export { EventMetadata } from '../v1/Events';
+7 -8
View File
@@ -2,6 +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 { EventMetadataV2, FunctionMetadataV2 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,8 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { EventMetadata } from './Events';
import { StorageFunctionMetadata } from './Storage';
/**
@@ -25,23 +24,23 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata))
calls: Option.with(Vec.with('FunctionMetadataV2')),
events: Option.with(Vec.with('EventMetadataV2'))
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV2>> {
return this.get('calls') as Option<Vec<FunctionMetadataV2>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV2>> {
return this.get('events') as Option<Vec<EventMetadataV2>>;
}
/**
-16
View File
@@ -132,14 +132,6 @@ export class StorageFunctionMetadata extends Struct {
}, value);
}
/**
* @description The default value of the storage function
* @deprecated Use `.fallback` instead.
*/
public get default (): Bytes {
return this.fallback;
}
/**
* @description The [[Text]] documentation
*/
@@ -147,14 +139,6 @@ export class StorageFunctionMetadata extends Struct {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The [[Bytes]] fallback default
*/
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V2 and V3
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v2/Calls';
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V2 and V3
export { EventMetadata } from '../v2/Events';
+7 -8
View File
@@ -2,6 +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 { EventMetadataV3, FunctionMetadataV3 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,8 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { EventMetadata } from './Events';
import { StorageFunctionMetadata } from './Storage';
/**
@@ -25,23 +24,23 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata))
calls: Option.with(Vec.with('FunctionMetadataV3')),
events: Option.with(Vec.with('EventMetadataV3'))
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV3>> {
return this.get('calls') as Option<Vec<FunctionMetadataV3>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV3>> {
return this.get('events') as Option<Vec<EventMetadataV3>>;
}
/**
+5 -64
View File
@@ -2,6 +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 { DoubleMapTypeV3 } from '../../interfaces/metadata/types';
import { AnyNumber } from '../../types';
import { assert } from '@polkadot/util';
@@ -11,12 +12,7 @@ import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Bytes from '../../primitive/Bytes';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
import {
MapType,
PlainType,
StorageFunctionModifier
} from '../v2/Storage';
import { MapType, PlainType, StorageFunctionModifier } from '../v2/Storage';
// Re-export classes that haven't changed between V2 and V3
export {
@@ -25,61 +21,22 @@ export {
StorageFunctionModifier
};
export class DoubleMapType extends Struct {
public constructor (value?: any) {
super({
key1: Type,
key2: Type,
value: Type,
key2Hasher: Text
}, value);
}
/**
* @description The mapped key as [[Type]]
*/
public get key1 (): Type {
return this.get('key1') as Type;
}
/**
* @description The mapped key as [[Type]]
*/
public get key2 (): Type {
return this.get('key2') as Type;
}
/**
* @description The hashing algorithm used to hash key2, as [[Text]]
*/
public get key2Hasher (): Text {
return this.get('key2Hasher') as Text;
}
/**
* @description The mapped key as [[Type]]
*/
public get value (): Type {
return this.get('value') as Type;
}
}
export class StorageFunctionType extends Enum {
public constructor (value?: any, index?: number) {
super({
PlainType,
MapType,
DoubleMapType
DoubleMapType: 'DoubleMapTypeV3'
}, value, index);
}
/**
* @description The value as a mapped value
*/
public get asDoubleMap (): DoubleMapType {
public get asDoubleMap (): DoubleMapTypeV3 {
assert(this.isDoubleMap, `Cannot convert '${this.type}' via asDoubleMap`);
return this.value as DoubleMapType;
return this.value as DoubleMapTypeV3;
}
/**
@@ -165,14 +122,6 @@ export class StorageFunctionMetadata extends Struct {
}, value);
}
/**
* @description The default value of the storage function
* @deprecated Use `.fallback` instead.
*/
public get default (): Bytes {
return this.fallback;
}
/**
* @description The [[Text]] documentation
*/
@@ -180,14 +129,6 @@ export class StorageFunctionMetadata extends Struct {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The [[Bytes]] fallback default
*/
+5 -5
View File
@@ -2,12 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Option, Vec } from '../../codec';
import { createType, Option, Vec } from '../../codec';
import MetadataV3 from './Metadata';
import StorageHasher from '../../primitive/StorageHasher';
import MetadataV4 from '../v4';
import { ModuleMetadata as ModuleMetadataV4 } from '../v4/Metadata';
import { DoubleMapType, MapType, StorageFunctionMetadata, StorageFunctionType } from '../v4/Storage';
import { MapType, StorageFunctionMetadata, StorageFunctionType } from '../v4/Storage';
import { StorageFunctionMetadata as StorageFunctionMetadataV3 } from './Storage';
/**
@@ -28,7 +28,7 @@ function toV4StorageFunction (storageFn: StorageFunctionMetadataV3): StorageFunc
value: type.asMap.value,
isLinked: type.asMap.isLinked
}), 1]
: [new DoubleMapType({
: [createType('DoubleMapTypeV4', {
hasher: new StorageHasher('Twox128'),
key1: type.asDoubleMap.key1,
key2: type.asDoubleMap.key2,
@@ -49,9 +49,9 @@ function toV4StorageFunction (storageFn: StorageFunctionMetadataV3): StorageFunc
* Convert from MetadataV3 to MetadataV4
* See https://github.com/paritytech/substrate/pull/2268 for details
*/
export default function toV4 (metadataV3: MetadataV3): MetadataV4 {
export default function toV4 ({ modules }: MetadataV3): MetadataV4 {
return new MetadataV4({
modules: metadataV3.modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV4 =>
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV4 =>
new ModuleMetadataV4({
calls,
events,
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V3 and V4
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v3/Calls';
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V3 and V4
export { EventMetadata } from '../v3/Events';
+7 -8
View File
@@ -2,6 +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 { EventMetadataV4, FunctionMetadataV4 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,8 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { EventMetadata } from './Events';
import { StorageFunctionMetadata } from './Storage';
/**
@@ -25,23 +24,23 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata))
calls: Option.with(Vec.with('FunctionMetadataV4')),
events: Option.with(Vec.with('EventMetadataV4'))
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV4>> {
return this.get('calls') as Option<Vec<FunctionMetadataV4>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV4>> {
return this.get('events') as Option<Vec<EventMetadataV4>>;
}
/**
+4 -66
View File
@@ -2,6 +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 { DoubleMapTypeV4 } from '../../interfaces/metadata/types';
import { AnyNumber } from '../../types';
import { assert } from '@polkadot/util';
@@ -61,69 +62,22 @@ export class MapType extends Struct {
}
}
export class DoubleMapType extends Struct {
public constructor (value?: any) {
super({
hasher: StorageHasher,
key1: Type,
key2: Type,
value: Type,
key2Hasher: Text
}, value);
}
/**
* @description The hashing algorithm used to hash keys, as [[StorageHasher]]
*/
public get hasher (): StorageHasher {
return this.get('hasher') as StorageHasher;
}
/**
* @description The mapped key as [[Type]]
*/
public get key1 (): Type {
return this.get('key1') as Type;
}
/**
* @description The mapped key as [[Type]]
*/
public get key2 (): Type {
return this.get('key2') as Type;
}
/**
* @description The hashing algorithm used to hash key2, as [[Text]]
*/
public get key2Hasher (): Text {
return this.get('key2Hasher') as Text;
}
/**
* @description The mapped key as [[Type]]
*/
public get value (): Type {
return this.get('value') as Type;
}
}
export class StorageFunctionType extends Enum {
public constructor (value?: any, index?: number) {
super({
PlainType,
MapType,
DoubleMapType
DoubleMapType: 'DoubleMapTypeV4'
}, value, index);
}
/**
* @description The value as a mapped value
*/
public get asDoubleMap (): DoubleMapType {
public get asDoubleMap (): DoubleMapTypeV4 {
assert(this.isDoubleMap, `Cannot convert '${this.type}' via asDoubleMap`);
return this.value as DoubleMapType;
return this.value as DoubleMapTypeV4;
}
/**
@@ -209,14 +163,6 @@ export class StorageFunctionMetadata extends Struct {
}, value);
}
/**
* @description The default value of the storage function
* @deprecated Use `.fallback` instead.
*/
public get default (): Bytes {
return this.fallback;
}
/**
* @description The default value of the storage function
*/
@@ -231,14 +177,6 @@ export class StorageFunctionMetadata extends Struct {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The key name
*/
+5 -5
View File
@@ -4,13 +4,13 @@
import { assert } from '@polkadot/util';
import { Option, Vec } from '../../codec';
import { createType, Option, Vec } from '../../codec';
import Text from '../../primitive/Text';
import MetadataV4 from './Metadata';
import StorageHasher from '../../primitive/StorageHasher';
import MetadataV5 from '../v5';
import { ModuleMetadata as ModuleMetadataV5 } from '../v5/Metadata';
import { DoubleMapType, StorageFunctionMetadata, StorageFunctionType } from '../v5/Storage';
import { StorageFunctionMetadata, StorageFunctionType } from '../v5/Storage';
import { StorageFunctionMetadata as StorageFunctionMetadataV4 } from './Storage';
const hasherMap: Map<string, string> = new Map([
@@ -38,7 +38,7 @@ function toV5StorageFunction (storageFn: StorageFunctionMetadataV4): StorageFunc
? [type, 0]
: type.isMap
? [type.asMap, 1]
: [new DoubleMapType({
: [createType('DoubleMapTypeV5', {
hasher: type.asDoubleMap.hasher,
key1: type.asDoubleMap.key1,
key2: type.asDoubleMap.key2,
@@ -59,9 +59,9 @@ function toV5StorageFunction (storageFn: StorageFunctionMetadataV4): StorageFunc
* Convert from MetadataV4 to MetadataV5
* See https://github.com/paritytech/substrate/pull/2836/files for details
*/
export default function toV5 (metadataV4: MetadataV4): MetadataV5 {
export default function toV5 ({ modules }: MetadataV4): MetadataV5 {
return new MetadataV5({
modules: metadataV4.modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV5 =>
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV5 =>
new ModuleMetadataV5({
name,
prefix,
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V4 and V5
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v4/Calls';
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V4 and V5
export { EventMetadata } from '../v4/Events';
+7 -8
View File
@@ -2,6 +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 { EventMetadataV5, FunctionMetadataV5 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,8 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { EventMetadata } from './Events';
import { StorageFunctionMetadata } from './Storage';
/**
@@ -25,23 +24,23 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata))
calls: Option.with(Vec.with('FunctionMetadataV5')),
events: Option.with(Vec.with('EventMetadataV5'))
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV5>> {
return this.get('calls') as Option<Vec<FunctionMetadataV5>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV5>> {
return this.get('events') as Option<Vec<EventMetadataV5>>;
}
/**
+4 -68
View File
@@ -2,6 +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 { DoubleMapTypeV5 } from '../../interfaces/metadata/types';
import { AnyNumber } from '../../types';
import { assert } from '@polkadot/util';
@@ -10,9 +11,7 @@ import Enum from '../../codec/Enum';
import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Bytes from '../../primitive/Bytes';
import StorageHasher from '../../primitive/StorageHasher';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
import { MapType, PlainType, StorageFunctionModifier } from '../v4/Storage';
// Re-export classes that haven't changed between V4 and V5
@@ -22,69 +21,22 @@ export {
StorageFunctionModifier
};
export class DoubleMapType extends Struct {
public constructor (value?: any) {
super({
hasher: StorageHasher,
key1: Type,
key2: Type,
value: Type,
key2Hasher: StorageHasher
}, value);
}
/**
* @description The hashing algorithm used to hash keys, as [[StorageHasher]]
*/
public get hasher (): StorageHasher {
return this.get('hasher') as StorageHasher;
}
/**
* @description The mapped key as [[Type]]
*/
public get key1 (): Type {
return this.get('key1') as Type;
}
/**
* @description The mapped key as [[Type]]
*/
public get key2 (): Type {
return this.get('key2') as Type;
}
/**
* @description The hashing algorithm used to hash key2, as [[StorageHasher]]
*/
public get key2Hasher (): StorageHasher {
return this.get('key2Hasher') as StorageHasher;
}
/**
* @description The mapped key as [[Type]]
*/
public get value (): Type {
return this.get('value') as Type;
}
}
export class StorageFunctionType extends Enum {
public constructor (value?: any, index?: number) {
super({
PlainType,
MapType,
DoubleMapType
DoubleMapType: 'DoubleMapTypeV5'
}, value, index);
}
/**
* @description The value as a mapped value
*/
public get asDoubleMap (): DoubleMapType {
public get asDoubleMap (): DoubleMapTypeV5 {
assert(this.isDoubleMap, `Cannot convert '${this.type}' via asDoubleMap`);
return this.value as DoubleMapType;
return this.value as DoubleMapTypeV5;
}
/**
@@ -170,14 +122,6 @@ export class StorageFunctionMetadata extends Struct {
}, value);
}
/**
* @description The default value of the storage function
* @deprecated Use `.fallback` instead.
*/
public get default (): Bytes {
return this.fallback;
}
/**
* @description The default value of the storage function
*/
@@ -192,14 +136,6 @@ export class StorageFunctionMetadata extends Struct {
return this.get('documentation') as Vec<Text>;
}
/**
* @description The [[Text]] documentation
* @deprecated Use `.documentation` instead.
*/
public get docs (): Vec<Text> {
return this.documentation;
}
/**
* @description The key name
*/
+2 -2
View File
@@ -10,9 +10,9 @@ import { ModuleMetadata as ModuleMetadataV6 } from '../v6/Metadata';
* Convert from MetadataV5 to MetadataV6
* See https://github.com/polkadot-js/api/issues/1043 for details
*/
export default function toV6 (metadataV5: MetadataV5): MetadataV6 {
export default function toV6 ({ modules }: MetadataV5): MetadataV6 {
return new MetadataV6({
modules: metadataV5.modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV6 =>
modules: modules.map(({ calls, events, name, prefix, storage }): ModuleMetadataV6 =>
new ModuleMetadataV6({
calls,
constants: [],
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V5 and V6
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v5/Calls';
@@ -1,48 +0,0 @@
// 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 Bytes from '../../primitive/Bytes';
import Text from '../../primitive/Text';
import Type from '../../primitive/Type';
import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
export class ModuleConstantMetadata extends Struct {
public constructor (value?: any) {
super({
name: Text,
type: Type,
value: Bytes,
documentation: Vec.with(Text)
}, value);
}
/**
* @description The argument name
*/
public get name (): Text {
return this.get('name') as Text;
}
/**
* @description The [[Type]]
*/
public get type (): Type {
return this.get('type') as Type;
}
/**
* @description The value as [[Bytes]]
*/
public get value (): Bytes {
return this.get('value') as Bytes;
}
/**
* @description The documentation
*/
public get documentation (): Vec<Text> {
return this.get('documentation') as Vec<Text>;
}
}
-6
View File
@@ -1,6 +0,0 @@
// 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.
// Re-export classes that haven't changed between V5 and V6
export { EventMetadata } from '../v5/Events';
+10 -12
View File
@@ -2,6 +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 { EventMetadataV6, FunctionMetadataV6, ModuleConstantMetadataV6 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,9 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { ModuleConstantMetadata } from './Constants';
import { EventMetadata } from './Events';
import { StorageEntryMetadata } from './Storage';
/**
@@ -26,31 +24,31 @@ export class ModuleMetadata extends Struct {
name: Text,
prefix: Text,
storage: Option.with(Vec.with(StorageEntryMetadata)),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata)),
constants: Vec.with(ModuleConstantMetadata)
calls: Option.with(Vec.with('FunctionMetadataV6')),
events: Option.with(Vec.with('EventMetadataV6')),
constants: Vec.with('ModuleConstantMetadataV6')
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV6>> {
return this.get('calls') as Option<Vec<FunctionMetadataV6>>;
}
/**
* @description the module constants
*/
public get constants (): Vec<ModuleConstantMetadata> {
return this.get('constants') as Vec<ModuleConstantMetadata>;
public get constants (): Vec<ModuleConstantMetadataV6> {
return this.get('constants') as Vec<ModuleConstantMetadataV6>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV6>> {
return this.get('events') as Option<Vec<EventMetadataV6>>;
}
/**
+1 -2
View File
@@ -2,13 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { DoubleMapType, MapType, PlainType, StorageFunctionMetadata, StorageFunctionMetadataValue, StorageFunctionModifier, StorageFunctionType } from '../v5/Storage';
import { MapType, PlainType, StorageFunctionMetadata, StorageFunctionMetadataValue, StorageFunctionModifier, StorageFunctionType } from '../v5/Storage';
// Re-export classes that haven't changed between V5 and V6
export {
MapType,
PlainType,
DoubleMapType,
StorageFunctionMetadata as StorageEntryMetadata,
StorageFunctionMetadataValue as StorageEntryMetadataValue,
StorageFunctionModifier as StorageEntryModifier,
-9
View File
@@ -1,9 +0,0 @@
// 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.
// Re-export classes that haven't changed between V6 & V7
export {
FunctionArgumentMetadata,
FunctionMetadata
} from '../v6/Calls';
@@ -1,8 +0,0 @@
// 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.
// Re-export classes that haven't changed between V6 & V7
export {
ModuleConstantMetadata
} from '../v6/Constants';
-8
View File
@@ -1,8 +0,0 @@
// 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.
// Re-export classes that haven't changed between V6 & V7
export {
EventMetadata
} from '../v6/Events';
+10 -12
View File
@@ -2,6 +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 { EventMetadataV7, FunctionMetadataV7, ModuleConstantMetadataV7 } from '../../interfaces/metadata/types';
import { MetadataInterface } from '../types';
import Option from '../../codec/Option';
@@ -10,9 +11,6 @@ import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { flattenUniq, validateTypes } from '../util';
import { FunctionMetadata } from './Calls';
import { ModuleConstantMetadata } from './Constants';
import { EventMetadata } from './Events';
import { StorageMetadata } from './Storage';
/**
@@ -25,31 +23,31 @@ export class ModuleMetadata extends Struct {
super({
name: Text,
storage: Option.with(StorageMetadata),
calls: Option.with(Vec.with(FunctionMetadata)),
events: Option.with(Vec.with(EventMetadata)),
constants: Vec.with(ModuleConstantMetadata)
calls: Option.with(Vec.with('FunctionMetadataV7')),
events: Option.with(Vec.with('EventMetadataV7')),
constants: Vec.with('ModuleConstantMetadataV7')
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadata>> {
return this.get('calls') as Option<Vec<FunctionMetadata>>;
public get calls (): Option<Vec<FunctionMetadataV7>> {
return this.get('calls') as Option<Vec<FunctionMetadataV7>>;
}
/**
* @description the module constants
*/
public get constants (): Vec<ModuleConstantMetadata> {
return this.get('constants') as Vec<ModuleConstantMetadata>;
public get constants (): Vec<ModuleConstantMetadataV7> {
return this.get('constants') as Vec<ModuleConstantMetadataV7>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadata>> {
return this.get('events') as Option<Vec<EventMetadata>>;
public get events (): Option<Vec<EventMetadataV7>> {
return this.get('events') as Option<Vec<EventMetadataV7>>;
}
/**
+1 -2
View File
@@ -5,13 +5,12 @@
import Struct from '../../codec/Struct';
import Vec from '../../codec/Vec';
import Text from '../../primitive/Text';
import { DoubleMapType, MapType, PlainType, StorageEntryMetadata, StorageEntryMetadataValue, StorageEntryModifier, StorageEntryType } from '../v6/Storage';
import { MapType, PlainType, StorageEntryMetadata, StorageEntryMetadataValue, StorageEntryModifier, StorageEntryType } from '../v6/Storage';
// Re-export classes that haven't changed between V6 and V7
export {
MapType,
PlainType,
DoubleMapType,
StorageEntryMetadata,
StorageEntryMetadataValue,
StorageEntryModifier,
+106
View File
@@ -24,6 +24,7 @@ import { TreasuryProposal } from './interfaces/treasury';
import { BlockAttestations, IncludedBlocks, MoreAttestations } from './interfaces/attestations';
import { EcdsaSignature, EthereumAddress } from './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 './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, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleMetadataV0, OuterDispatchCallV0, OuterDispatchMetadataV0 } from './interfaces/metadata';
import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc';
export interface InterfaceRegistry {
@@ -625,6 +626,111 @@ export interface InterfaceRegistry {
WinningData: WinningData;
'Option<WinningData>': Option<WinningData>;
'Vec<WinningData>': Vec<WinningData>;
CallMetadataV0: CallMetadataV0;
'Option<CallMetadataV0>': Option<CallMetadataV0>;
'Vec<CallMetadataV0>': Vec<CallMetadataV0>;
EventMetadataV0: EventMetadataV0;
'Option<EventMetadataV0>': Option<EventMetadataV0>;
'Vec<EventMetadataV0>': Vec<EventMetadataV0>;
FunctionArgumentMetadataV0: FunctionArgumentMetadataV0;
'Option<FunctionArgumentMetadataV0>': Option<FunctionArgumentMetadataV0>;
'Vec<FunctionArgumentMetadataV0>': Vec<FunctionArgumentMetadataV0>;
FunctionMetadataV0: FunctionMetadataV0;
'Option<FunctionMetadataV0>': Option<FunctionMetadataV0>;
'Vec<FunctionMetadataV0>': Vec<FunctionMetadataV0>;
ModuleMetadataV0: ModuleMetadataV0;
'Option<ModuleMetadataV0>': Option<ModuleMetadataV0>;
'Vec<ModuleMetadataV0>': Vec<ModuleMetadataV0>;
OuterDispatchCallV0: OuterDispatchCallV0;
'Option<OuterDispatchCallV0>': Option<OuterDispatchCallV0>;
'Vec<OuterDispatchCallV0>': Vec<OuterDispatchCallV0>;
OuterDispatchMetadataV0: OuterDispatchMetadataV0;
'Option<OuterDispatchMetadataV0>': Option<OuterDispatchMetadataV0>;
'Vec<OuterDispatchMetadataV0>': Vec<OuterDispatchMetadataV0>;
EventMetadataV1: EventMetadataV1;
'Option<EventMetadataV1>': Option<EventMetadataV1>;
'Vec<EventMetadataV1>': Vec<EventMetadataV1>;
FunctionArgumentMetadataV1: FunctionArgumentMetadataV1;
'Option<FunctionArgumentMetadataV1>': Option<FunctionArgumentMetadataV1>;
'Vec<FunctionArgumentMetadataV1>': Vec<FunctionArgumentMetadataV1>;
FunctionMetadataV1: FunctionMetadataV1;
'Option<FunctionMetadataV1>': Option<FunctionMetadataV1>;
'Vec<FunctionMetadataV1>': Vec<FunctionMetadataV1>;
EventMetadataV2: EventMetadataV2;
'Option<EventMetadataV2>': Option<EventMetadataV2>;
'Vec<EventMetadataV2>': Vec<EventMetadataV2>;
FunctionArgumentMetadataV2: FunctionArgumentMetadataV2;
'Option<FunctionArgumentMetadataV2>': Option<FunctionArgumentMetadataV2>;
'Vec<FunctionArgumentMetadataV2>': Vec<FunctionArgumentMetadataV2>;
FunctionMetadataV2: FunctionMetadataV2;
'Option<FunctionMetadataV2>': Option<FunctionMetadataV2>;
'Vec<FunctionMetadataV2>': Vec<FunctionMetadataV2>;
DoubleMapTypeV3: DoubleMapTypeV3;
'Option<DoubleMapTypeV3>': Option<DoubleMapTypeV3>;
'Vec<DoubleMapTypeV3>': Vec<DoubleMapTypeV3>;
EventMetadataV3: EventMetadataV3;
'Option<EventMetadataV3>': Option<EventMetadataV3>;
'Vec<EventMetadataV3>': Vec<EventMetadataV3>;
FunctionArgumentMetadataV3: FunctionArgumentMetadataV3;
'Option<FunctionArgumentMetadataV3>': Option<FunctionArgumentMetadataV3>;
'Vec<FunctionArgumentMetadataV3>': Vec<FunctionArgumentMetadataV3>;
FunctionMetadataV3: FunctionMetadataV3;
'Option<FunctionMetadataV3>': Option<FunctionMetadataV3>;
'Vec<FunctionMetadataV3>': Vec<FunctionMetadataV3>;
DoubleMapTypeV4: DoubleMapTypeV4;
'Option<DoubleMapTypeV4>': Option<DoubleMapTypeV4>;
'Vec<DoubleMapTypeV4>': Vec<DoubleMapTypeV4>;
EventMetadataV4: EventMetadataV4;
'Option<EventMetadataV4>': Option<EventMetadataV4>;
'Vec<EventMetadataV4>': Vec<EventMetadataV4>;
FunctionArgumentMetadataV4: FunctionArgumentMetadataV4;
'Option<FunctionArgumentMetadataV4>': Option<FunctionArgumentMetadataV4>;
'Vec<FunctionArgumentMetadataV4>': Vec<FunctionArgumentMetadataV4>;
FunctionMetadataV4: FunctionMetadataV4;
'Option<FunctionMetadataV4>': Option<FunctionMetadataV4>;
'Vec<FunctionMetadataV4>': Vec<FunctionMetadataV4>;
DoubleMapTypeV5: DoubleMapTypeV5;
'Option<DoubleMapTypeV5>': Option<DoubleMapTypeV5>;
'Vec<DoubleMapTypeV5>': Vec<DoubleMapTypeV5>;
EventMetadataV5: EventMetadataV5;
'Option<EventMetadataV5>': Option<EventMetadataV5>;
'Vec<EventMetadataV5>': Vec<EventMetadataV5>;
FunctionArgumentMetadataV5: FunctionArgumentMetadataV5;
'Option<FunctionArgumentMetadataV5>': Option<FunctionArgumentMetadataV5>;
'Vec<FunctionArgumentMetadataV5>': Vec<FunctionArgumentMetadataV5>;
FunctionMetadataV5: FunctionMetadataV5;
'Option<FunctionMetadataV5>': Option<FunctionMetadataV5>;
'Vec<FunctionMetadataV5>': Vec<FunctionMetadataV5>;
DoubleMapTypeV6: DoubleMapTypeV6;
'Option<DoubleMapTypeV6>': Option<DoubleMapTypeV6>;
'Vec<DoubleMapTypeV6>': Vec<DoubleMapTypeV6>;
EventMetadataV6: EventMetadataV6;
'Option<EventMetadataV6>': Option<EventMetadataV6>;
'Vec<EventMetadataV6>': Vec<EventMetadataV6>;
FunctionArgumentMetadataV6: FunctionArgumentMetadataV6;
'Option<FunctionArgumentMetadataV6>': Option<FunctionArgumentMetadataV6>;
'Vec<FunctionArgumentMetadataV6>': Vec<FunctionArgumentMetadataV6>;
FunctionMetadataV6: FunctionMetadataV6;
'Option<FunctionMetadataV6>': Option<FunctionMetadataV6>;
'Vec<FunctionMetadataV6>': Vec<FunctionMetadataV6>;
ModuleConstantMetadataV6: ModuleConstantMetadataV6;
'Option<ModuleConstantMetadataV6>': Option<ModuleConstantMetadataV6>;
'Vec<ModuleConstantMetadataV6>': Vec<ModuleConstantMetadataV6>;
DoubleMapTypeV7: DoubleMapTypeV7;
'Option<DoubleMapTypeV7>': Option<DoubleMapTypeV7>;
'Vec<DoubleMapTypeV7>': Vec<DoubleMapTypeV7>;
EventMetadataV7: EventMetadataV7;
'Option<EventMetadataV7>': Option<EventMetadataV7>;
'Vec<EventMetadataV7>': Vec<EventMetadataV7>;
FunctionArgumentMetadataV7: FunctionArgumentMetadataV7;
'Option<FunctionArgumentMetadataV7>': Option<FunctionArgumentMetadataV7>;
'Vec<FunctionArgumentMetadataV7>': Vec<FunctionArgumentMetadataV7>;
FunctionMetadataV7: FunctionMetadataV7;
'Option<FunctionMetadataV7>': Option<FunctionMetadataV7>;
'Vec<FunctionMetadataV7>': Vec<FunctionMetadataV7>;
ModuleConstantMetadataV7: ModuleConstantMetadataV7;
'Option<ModuleConstantMetadataV7>': Option<ModuleConstantMetadataV7>;
'Vec<ModuleConstantMetadataV7>': Vec<ModuleConstantMetadataV7>;
ApiId: ApiId;
'Option<ApiId>': Option<ApiId>;
'Vec<ApiId>': Vec<ApiId>;
+2 -1
View File
@@ -29,5 +29,6 @@ export { default as attestations } from './attestations/definitions';
export { default as claims } from './claims/definitions';
export { default as parachains } from './parachains/definitions';
// pull in rpc last, assuming that is uses info from above
// pull in metadata & rpc last, assuming that is uses info from above
export { default as metadata } from './metadata/definitions';
export { default as rpc } from './rpc/definitions';
@@ -0,0 +1,109 @@
// 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 default {
types: {
// v0
CallMetadataV0: {
name: 'Text',
functions: 'Vec<FunctionMetadataV0>'
},
EventMetadataV0: {
name: 'Text',
args: 'Vec<Type>',
documentation: 'Vec<Text>'
},
FunctionArgumentMetadataV0: {
name: 'Text',
type: 'Type'
},
FunctionMetadataV0: {
id: 'u16',
name: 'Text',
args: 'Vec<FunctionArgumentMetadataV0>',
documentation: 'Vec<Text>'
},
ModuleMetadataV0: {
name: 'Text',
call: 'CallMetadataV0'
},
OuterDispatchCallV0: {
name: 'Text',
prefix: 'Text',
index: 'u16'
},
OuterDispatchMetadataV0: {
name: 'Text',
calls: 'Vec<OuterDispatchCallV0>'
},
// v1
EventMetadataV1: 'EventMetadataV0',
FunctionArgumentMetadataV1: 'FunctionArgumentMetadataV0',
FunctionMetadataV1: {
name: 'Text',
args: 'Vec<FunctionArgumentMetadataV1>',
documentation: 'Vec<Text>'
},
// v2
EventMetadataV2: 'EventMetadataV1',
FunctionArgumentMetadataV2: 'FunctionArgumentMetadataV1',
FunctionMetadataV2: 'FunctionMetadataV1',
// v3
DoubleMapTypeV3: {
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'Text'
},
EventMetadataV3: 'EventMetadataV2',
FunctionArgumentMetadataV3: 'FunctionArgumentMetadataV2',
FunctionMetadataV3: 'FunctionMetadataV2',
// v4
DoubleMapTypeV4: {
hasher: 'StorageHasher',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'Text'
},
EventMetadataV4: 'EventMetadataV3',
FunctionArgumentMetadataV4: 'FunctionArgumentMetadataV3',
FunctionMetadataV4: 'FunctionMetadataV3',
// v5
DoubleMapTypeV5: {
hasher: 'StorageHasher',
key1: 'Type',
key2: 'Type',
value: 'Type',
key2Hasher: 'StorageHasher'
},
EventMetadataV5: 'EventMetadataV4',
FunctionArgumentMetadataV5: 'FunctionArgumentMetadataV4',
FunctionMetadataV5: 'FunctionMetadataV4',
// v6
DoubleMapTypeV6: 'DoubleMapTypeV5',
EventMetadataV6: 'EventMetadataV5',
FunctionArgumentMetadataV6: 'FunctionArgumentMetadataV5',
FunctionMetadataV6: 'FunctionMetadataV5',
ModuleConstantMetadataV6: {
name: 'Text',
type: 'Type',
value: 'Bytes',
documentation: 'Vec<Text>'
},
// v7
DoubleMapTypeV7: 'DoubleMapTypeV6',
EventMetadataV7: 'EventMetadataV6',
FunctionArgumentMetadataV7: 'FunctionArgumentMetadataV6',
FunctionMetadataV7: 'FunctionMetadataV6',
ModuleConstantMetadataV7: 'ModuleConstantMetadataV6'
}
};
@@ -0,0 +1,4 @@
// Auto-generated via `yarn build:interfaces`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,200 @@
// Auto-generated via `yarn build:interfaces`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { Struct, Vec } from '../../codec';
import { Bytes, StorageHasher, Text, Type, u16 } from '../../primitive';
/** Struct */
export interface CallMetadataV0 extends Struct {
/** Text */
readonly name: Text;
/** Vec<FunctionMetadataV0> */
readonly functions: Vec<FunctionMetadataV0>;
}
/** Struct */
export interface DoubleMapTypeV3 extends Struct {
/** Type */
readonly key1: Type;
/** Type */
readonly key2: Type;
/** Type */
readonly value: Type;
/** Text */
readonly key2Hasher: Text;
}
/** Struct */
export interface DoubleMapTypeV4 extends Struct {
/** StorageHasher */
readonly hasher: StorageHasher;
/** Type */
readonly key1: Type;
/** Type */
readonly key2: Type;
/** Type */
readonly value: Type;
/** Text */
readonly key2Hasher: Text;
}
/** Struct */
export interface DoubleMapTypeV5 extends Struct {
/** StorageHasher */
readonly hasher: StorageHasher;
/** Type */
readonly key1: Type;
/** Type */
readonly key2: Type;
/** Type */
readonly value: Type;
/** StorageHasher */
readonly key2Hasher: StorageHasher;
}
/** DoubleMapTypeV5 */
export type DoubleMapTypeV6 = DoubleMapTypeV5;
/** DoubleMapTypeV6 */
export type DoubleMapTypeV7 = DoubleMapTypeV6;
/** Struct */
export interface EventMetadataV0 extends Struct {
/** Text */
readonly name: Text;
/** Vec<Type> */
readonly args: Vec<Type>;
/** Vec<Text> */
readonly documentation: Vec<Text>;
}
/** EventMetadataV0 */
export type EventMetadataV1 = EventMetadataV0;
/** EventMetadataV1 */
export type EventMetadataV2 = EventMetadataV1;
/** EventMetadataV2 */
export type EventMetadataV3 = EventMetadataV2;
/** EventMetadataV3 */
export type EventMetadataV4 = EventMetadataV3;
/** EventMetadataV4 */
export type EventMetadataV5 = EventMetadataV4;
/** EventMetadataV5 */
export type EventMetadataV6 = EventMetadataV5;
/** EventMetadataV6 */
export type EventMetadataV7 = EventMetadataV6;
/** Struct */
export interface FunctionArgumentMetadataV0 extends Struct {
/** Text */
readonly name: Text;
/** Type */
readonly type: Type;
}
/** FunctionArgumentMetadataV0 */
export type FunctionArgumentMetadataV1 = FunctionArgumentMetadataV0;
/** FunctionArgumentMetadataV1 */
export type FunctionArgumentMetadataV2 = FunctionArgumentMetadataV1;
/** FunctionArgumentMetadataV2 */
export type FunctionArgumentMetadataV3 = FunctionArgumentMetadataV2;
/** FunctionArgumentMetadataV3 */
export type FunctionArgumentMetadataV4 = FunctionArgumentMetadataV3;
/** FunctionArgumentMetadataV4 */
export type FunctionArgumentMetadataV5 = FunctionArgumentMetadataV4;
/** FunctionArgumentMetadataV5 */
export type FunctionArgumentMetadataV6 = FunctionArgumentMetadataV5;
/** FunctionArgumentMetadataV6 */
export type FunctionArgumentMetadataV7 = FunctionArgumentMetadataV6;
/** Struct */
export interface FunctionMetadataV0 extends Struct {
/** u16 */
readonly id: u16;
/** Text */
readonly name: Text;
/** Vec<FunctionArgumentMetadataV0> */
readonly args: Vec<FunctionArgumentMetadataV0>;
/** Vec<Text> */
readonly documentation: Vec<Text>;
}
/** Struct */
export interface FunctionMetadataV1 extends Struct {
/** Text */
readonly name: Text;
/** Vec<FunctionArgumentMetadataV1> */
readonly args: Vec<FunctionArgumentMetadataV1>;
/** Vec<Text> */
readonly documentation: Vec<Text>;
}
/** FunctionMetadataV1 */
export type FunctionMetadataV2 = FunctionMetadataV1;
/** FunctionMetadataV2 */
export type FunctionMetadataV3 = FunctionMetadataV2;
/** FunctionMetadataV3 */
export type FunctionMetadataV4 = FunctionMetadataV3;
/** FunctionMetadataV4 */
export type FunctionMetadataV5 = FunctionMetadataV4;
/** FunctionMetadataV5 */
export type FunctionMetadataV6 = FunctionMetadataV5;
/** FunctionMetadataV6 */
export type FunctionMetadataV7 = FunctionMetadataV6;
/** Struct */
export interface ModuleConstantMetadataV6 extends Struct {
/** Text */
readonly name: Text;
/** Type */
readonly type: Type;
/** Bytes */
readonly value: Bytes;
/** Vec<Text> */
readonly documentation: Vec<Text>;
}
/** ModuleConstantMetadataV6 */
export type ModuleConstantMetadataV7 = ModuleConstantMetadataV6;
/** Struct */
export interface ModuleMetadataV0 extends Struct {
/** Text */
readonly name: Text;
/** CallMetadataV0 */
readonly call: CallMetadataV0;
}
/** Struct */
export interface OuterDispatchCallV0 extends Struct {
/** Text */
readonly name: Text;
/** Text */
readonly prefix: Text;
/** u16 */
readonly index: u16;
}
/** Struct */
export interface OuterDispatchMetadataV0 extends Struct {
/** Text */
readonly name: Text;
/** Vec<OuterDispatchCallV0> */
readonly calls: Vec<OuterDispatchCallV0>;
}
+1
View File
@@ -22,4 +22,5 @@ export * from './treasury/types';
export * from './attestations/types';
export * from './claims/types';
export * from './parachains/types';
export * from './metadata/types';
export * from './rpc/types';
@@ -2,6 +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 { Balance, Index } from '../../interfaces/runtime';
import { AnyU8a, ArgsDef, Codec, ExtrinsicPayloadValue, IExtrinsic, IHash, IKeyringPair, SignatureOptions } from '../../types';
@@ -9,7 +10,6 @@ import { assert, isHex, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/u
import Base from '../../codec/Base';
import Compact from '../../codec/Compact';
import { FunctionMetadata } from '../../Metadata/v7/Calls';
import Address from '../Generic/Address';
import Call from '../Generic/Call';
import ExtrinsicV1, { ExtrinsicValueV1 } from './v1/Extrinsic';
@@ -160,9 +160,9 @@ export default class Extrinsic extends Base<ExtrinsicV1 | ExtrinsicV2 | Extrinsi
}
/**
* @description The [[FunctionMetadata]] that describes the extrinsic
* @description The [[FunctionMetadataV7]] that describes the extrinsic
*/
public get meta (): FunctionMetadata {
public get meta (): FunctionMetadataV7 {
return this.method.meta;
}
+2 -2
View File
@@ -2,6 +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 { AnyU8a, ArgsDef, CallFunction, Codec, IMethod, ModulesWithCalls } from '../../types';
import { assert, isHex, isObject, isU8a, u8aToU8a } from '@polkadot/util';
@@ -9,7 +10,6 @@ import { assert, isHex, isObject, isU8a, u8aToU8a } from '@polkadot/util';
import { getTypeDef, getTypeClass } from '../../codec/create';
import Struct from '../../codec/Struct';
import U8aFixed from '../../codec/U8aFixed';
import { FunctionMetadata as FunctionMetadataV7, FunctionArgumentMetadata } from '../../Metadata/v7/Calls';
interface DecodeMethodInput {
args: any;
@@ -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): FunctionArgumentMetadata[] {
public static filterOrigin (meta?: FunctionMetadataV7): FunctionArgumentMetadataV7[] {
// FIXME should be `arg.type !== Origin`, but doesn't work...
return meta
? meta.args.filter(({ type }): boolean =>
@@ -3,6 +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 { EventId } from '../../interfaces/system';
import { Constructor, Codec } from '../../types';
@@ -12,7 +13,6 @@ import { getTypeClass, getTypeDef } from '../../codec/create';
import Struct from '../../codec/Struct';
import Tuple from '../../codec/Tuple';
import Metadata from '../../Metadata';
import { EventMetadata as EventMetadataV7 } from '../../Metadata/v7/Events';
import Null from '../Null';
const EventTypes: Record<string, Constructor<EventData>> = {};
+3 -3
View File
@@ -2,6 +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 { Balance, Index } from './interfaces/runtime';
import BN from 'bn.js';
@@ -9,7 +10,6 @@ import BN from 'bn.js';
import Compact from './codec/Compact';
import U8a from './codec/U8a';
import { InterfaceRegistry } from './interfaceRegistry';
import { FunctionMetadata } from './Metadata/v7/Calls';
import Call from './primitive/Generic/Call';
import Address from './primitive/Generic/Address';
@@ -20,7 +20,7 @@ export type InterfaceTypes = keyof InterfaceRegistry;
export interface CallFunction {
(...args: any[]): Call;
callIndex: Uint8Array;
meta: FunctionMetadata;
meta: FunctionMetadataV7;
method: string;
section: string;
toJSON: () => any;
@@ -162,7 +162,7 @@ export interface IMethod extends Codec {
readonly data: Uint8Array;
readonly hash: IHash;
readonly hasOrigin: boolean;
readonly meta: FunctionMetadata;
readonly meta: FunctionMetadataV7;
}
interface ExtrinsicSignatureBase {