diff --git a/packages/api-metadata/src/consts/types.ts b/packages/api-metadata/src/consts/types.ts index b5ae655a70..0b6337437c 100644 --- a/packages/api-metadata/src/consts/types.ts +++ b/packages/api-metadata/src/consts/types.ts @@ -3,10 +3,10 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { Codec } from '@polkadot/types/types'; -import { ModuleConstantMetadata as MetaV7 } from '@polkadot/types/Metadata/v6/Constants'; +import { ModuleConstantMetadataV7 } from '@polkadot/types/interfaces'; export interface ConstantCodec extends Codec { - meta: MetaV7; + meta: ModuleConstantMetadataV7; } export type ModuleConstants = Record; diff --git a/packages/api-metadata/src/extrinsics/fromMetadata/createUnchecked.ts b/packages/api-metadata/src/extrinsics/fromMetadata/createUnchecked.ts index 071396e9a6..c869c12bf0 100644 --- a/packages/api-metadata/src/extrinsics/fromMetadata/createUnchecked.ts +++ b/packages/api-metadata/src/extrinsics/fromMetadata/createUnchecked.ts @@ -2,10 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { Call } from '@polkadot/types/interfaces'; +import { Call, FunctionMetadataV7 } from '@polkadot/types/interfaces'; import { CallFunction } from '@polkadot/types/types'; -import { FunctionMetadata } from '@polkadot/types/Metadata/v7/Calls'; import { createType } from '@polkadot/types'; import { assert, stringCamelCase } from '@polkadot/util'; @@ -22,7 +21,7 @@ export default function createDescriptor ( section: string, sectionIndex: number, methodIndex: number, - callMetadata: FunctionMetadata + callMetadata: FunctionMetadataV7 ): CallFunction { const callIndex = new Uint8Array([sectionIndex, methodIndex]); const expectedArgs = callMetadata.args; diff --git a/packages/types/src/Metadata/v0/Calls.ts b/packages/types/src/Metadata/v0/Calls.ts deleted file mode 100644 index 0b571a5f9b..0000000000 --- a/packages/types/src/Metadata/v0/Calls.ts +++ /dev/null @@ -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 { - return this.get('calls') as Vec; - } - - /** - * @description The name for the dispatch - */ - public get name (): Text { - return this.get('name') as Text; - } -} diff --git a/packages/types/src/Metadata/v0/Events.ts b/packages/types/src/Metadata/v0/Events.ts index ce910bf45c..6c8db4b03f 100644 --- a/packages/types/src/Metadata/v0/Events.ts +++ b/packages/types/src/Metadata/v0/Events.ts @@ -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 { - return this.get('args') as Vec; - } - - /** - * @description The arguments of [[Type]] - * @deprecated Use `.args` instead - */ - public get arguments (): Vec { - return this.args; - } - - /** - * @description The [[Text]] documentation - */ - public get documentation (): Vec { - return this.get('documentation') as Vec; - } - - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - 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': Vec.with(EventMetadata) - }, value); + super(['Text', 'Vec'], value); } /** * @description The [[EventMetadata]] */ - public get events (): Vec { - return this[1] as Vec; + public get events (): Vec { + return this[1] as Vec; } /** diff --git a/packages/types/src/Metadata/v0/Metadata.ts b/packages/types/src/Metadata/v0/Metadata.ts index 42093f7d8a..18e9ab53be 100644 --- a/packages/types/src/Metadata/v0/Metadata.ts +++ b/packages/types/src/Metadata/v0/Metadata.ts @@ -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 { +export default class MetadataV0 extends Struct implements MetadataInterface { 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 { - return (this.get('outerDispatch') as OuterDispatchMetadata).calls; + public get calls (): Vec { + return (this.get('outerDispatch') as OuterDispatchMetadataV0).calls; } /** @@ -69,14 +69,14 @@ export default class MetadataV0 extends Struct implements MetadataInterface { - return this.get('modules') as Vec; + public get modules (): Vec { + return this.get('modules') as Vec; } 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 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()] ) : [] ); diff --git a/packages/types/src/Metadata/v0/Modules.ts b/packages/types/src/Metadata/v0/Modules.ts index 71e8e9a726..0ef2c819fd 100644 --- a/packages/types/src/Metadata/v0/Modules.ts +++ b/packages/types/src/Metadata/v0/Modules.ts @@ -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 { - return this.get('args') as Vec; - } - - /** - * @description The [[FunctionArgumentMetadata]] for arguments - * @deprecated Use `.args` instead - */ - public get arguments (): Vec { - return this.get('arguments') as Vec; - } - - /** - * @description The [[Text]] documentation - */ - public get documentation (): Vec { - return this.get('documentation') as Vec; - } - - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - 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 { - return this.get('functions') as Vec; - } - - /** - * @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 { - return this.get('storage') as Option; + public get storage (): Option { + return this.get('storage') as Option; } } diff --git a/packages/types/src/Metadata/v0/Storage.ts b/packages/types/src/Metadata/v0/Storage.ts index efa714f05d..4d1a00c68c 100644 --- a/packages/types/src/Metadata/v0/Storage.ts +++ b/packages/types/src/Metadata/v0/Storage.ts @@ -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; } - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - 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, diff --git a/packages/types/src/Metadata/v0/toV1.ts b/packages/types/src/Metadata/v0/toV1.ts index 8f113304f3..65957629ed 100644 --- a/packages/types/src/Metadata/v0/toV1.ts +++ b/packages/types/src/Metadata/v0/toV1.ts @@ -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 { +function toV1Calls (modul: RuntimeModuleMetadataV0): Option { 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 { +function toV1Events (metadataV0: MetadataV0, prefix: Text): Option { 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 { +function toV1Storage (modul: RuntimeModuleMetadataV0): Option { return modul.storage.isNone ? new Option(Vec.with(StorageFunctionMetadata)) : new Option( diff --git a/packages/types/src/Metadata/v1/Calls.ts b/packages/types/src/Metadata/v1/Calls.ts deleted file mode 100644 index 6ccea3a4a1..0000000000 --- a/packages/types/src/Metadata/v1/Calls.ts +++ /dev/null @@ -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 { - return this.get('args') as Vec; - } - - /** - * @description The [[Text]] documentation - */ - public get documentation (): Vec { - return this.get('documentation') as Vec; - } - - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - return this.documentation; - } - - /** - * @description The call name - */ - public get name (): Text { - return this.get('name') as Text; - } -} diff --git a/packages/types/src/Metadata/v1/Events.ts b/packages/types/src/Metadata/v1/Events.ts deleted file mode 100644 index ba9078cdf1..0000000000 --- a/packages/types/src/Metadata/v1/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v1/Metadata.ts b/packages/types/src/Metadata/v1/Metadata.ts index 7aeb6477ad..561b887584 100644 --- a/packages/types/src/Metadata/v1/Metadata.ts +++ b/packages/types/src/Metadata/v1/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v2/Calls.ts b/packages/types/src/Metadata/v2/Calls.ts deleted file mode 100644 index 8e3ef477f3..0000000000 --- a/packages/types/src/Metadata/v2/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v2/Events.ts b/packages/types/src/Metadata/v2/Events.ts deleted file mode 100644 index de53bb4245..0000000000 --- a/packages/types/src/Metadata/v2/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v2/Metadata.ts b/packages/types/src/Metadata/v2/Metadata.ts index 11de70f068..daac92633d 100644 --- a/packages/types/src/Metadata/v2/Metadata.ts +++ b/packages/types/src/Metadata/v2/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v2/Storage.ts b/packages/types/src/Metadata/v2/Storage.ts index 0969282e70..94e8732413 100644 --- a/packages/types/src/Metadata/v2/Storage.ts +++ b/packages/types/src/Metadata/v2/Storage.ts @@ -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; } - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - return this.documentation; - } - /** * @description The [[Bytes]] fallback default */ diff --git a/packages/types/src/Metadata/v3/Calls.ts b/packages/types/src/Metadata/v3/Calls.ts deleted file mode 100644 index 9911bcdbd2..0000000000 --- a/packages/types/src/Metadata/v3/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v3/Events.ts b/packages/types/src/Metadata/v3/Events.ts deleted file mode 100644 index f81e45b6c6..0000000000 --- a/packages/types/src/Metadata/v3/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v3/Metadata.ts b/packages/types/src/Metadata/v3/Metadata.ts index e4b452d7a9..c29407f3de 100644 --- a/packages/types/src/Metadata/v3/Metadata.ts +++ b/packages/types/src/Metadata/v3/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v3/Storage.ts b/packages/types/src/Metadata/v3/Storage.ts index f3cde893ba..0b6b2bac34 100644 --- a/packages/types/src/Metadata/v3/Storage.ts +++ b/packages/types/src/Metadata/v3/Storage.ts @@ -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; } - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - return this.documentation; - } - /** * @description The [[Bytes]] fallback default */ diff --git a/packages/types/src/Metadata/v3/toV4.ts b/packages/types/src/Metadata/v3/toV4.ts index b5e3ef8ee8..45c5c4a1fe 100644 --- a/packages/types/src/Metadata/v3/toV4.ts +++ b/packages/types/src/Metadata/v3/toV4.ts @@ -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, diff --git a/packages/types/src/Metadata/v4/Calls.ts b/packages/types/src/Metadata/v4/Calls.ts deleted file mode 100644 index 24ee13dc04..0000000000 --- a/packages/types/src/Metadata/v4/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v4/Events.ts b/packages/types/src/Metadata/v4/Events.ts deleted file mode 100644 index 689efe418e..0000000000 --- a/packages/types/src/Metadata/v4/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v4/Metadata.ts b/packages/types/src/Metadata/v4/Metadata.ts index e90f149061..c601e993d0 100644 --- a/packages/types/src/Metadata/v4/Metadata.ts +++ b/packages/types/src/Metadata/v4/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v4/Storage.ts b/packages/types/src/Metadata/v4/Storage.ts index cd301a81c0..6d59787ce8 100644 --- a/packages/types/src/Metadata/v4/Storage.ts +++ b/packages/types/src/Metadata/v4/Storage.ts @@ -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; } - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - return this.documentation; - } - /** * @description The key name */ diff --git a/packages/types/src/Metadata/v4/toV5.ts b/packages/types/src/Metadata/v4/toV5.ts index d652b3718d..63117a2469 100644 --- a/packages/types/src/Metadata/v4/toV5.ts +++ b/packages/types/src/Metadata/v4/toV5.ts @@ -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 = 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, diff --git a/packages/types/src/Metadata/v5/Calls.ts b/packages/types/src/Metadata/v5/Calls.ts deleted file mode 100644 index 83a2f37fee..0000000000 --- a/packages/types/src/Metadata/v5/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v5/Events.ts b/packages/types/src/Metadata/v5/Events.ts deleted file mode 100644 index 751e2d5f16..0000000000 --- a/packages/types/src/Metadata/v5/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v5/Metadata.ts b/packages/types/src/Metadata/v5/Metadata.ts index e59f5effe5..6417cd80e1 100644 --- a/packages/types/src/Metadata/v5/Metadata.ts +++ b/packages/types/src/Metadata/v5/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v5/Storage.ts b/packages/types/src/Metadata/v5/Storage.ts index 29c0a056de..d628311742 100644 --- a/packages/types/src/Metadata/v5/Storage.ts +++ b/packages/types/src/Metadata/v5/Storage.ts @@ -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; } - /** - * @description The [[Text]] documentation - * @deprecated Use `.documentation` instead. - */ - public get docs (): Vec { - return this.documentation; - } - /** * @description The key name */ diff --git a/packages/types/src/Metadata/v5/toV6.ts b/packages/types/src/Metadata/v5/toV6.ts index 5c74874600..d9320b69a3 100644 --- a/packages/types/src/Metadata/v5/toV6.ts +++ b/packages/types/src/Metadata/v5/toV6.ts @@ -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: [], diff --git a/packages/types/src/Metadata/v6/Calls.ts b/packages/types/src/Metadata/v6/Calls.ts deleted file mode 100644 index 4bcfba4c5f..0000000000 --- a/packages/types/src/Metadata/v6/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v6/Constants.ts b/packages/types/src/Metadata/v6/Constants.ts deleted file mode 100644 index 2ce2839d03..0000000000 --- a/packages/types/src/Metadata/v6/Constants.ts +++ /dev/null @@ -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 { - return this.get('documentation') as Vec; - } -} diff --git a/packages/types/src/Metadata/v6/Events.ts b/packages/types/src/Metadata/v6/Events.ts deleted file mode 100644 index 6d426706ff..0000000000 --- a/packages/types/src/Metadata/v6/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v6/Metadata.ts b/packages/types/src/Metadata/v6/Metadata.ts index a1b5308191..b277648d45 100644 --- a/packages/types/src/Metadata/v6/Metadata.ts +++ b/packages/types/src/Metadata/v6/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module constants */ - public get constants (): Vec { - return this.get('constants') as Vec; + public get constants (): Vec { + return this.get('constants') as Vec; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v6/Storage.ts b/packages/types/src/Metadata/v6/Storage.ts index 5e6ce35515..322eb553ee 100644 --- a/packages/types/src/Metadata/v6/Storage.ts +++ b/packages/types/src/Metadata/v6/Storage.ts @@ -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, diff --git a/packages/types/src/Metadata/v7/Calls.ts b/packages/types/src/Metadata/v7/Calls.ts deleted file mode 100644 index 78f24dc3ea..0000000000 --- a/packages/types/src/Metadata/v7/Calls.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v7/Constants.ts b/packages/types/src/Metadata/v7/Constants.ts deleted file mode 100644 index d40c72093d..0000000000 --- a/packages/types/src/Metadata/v7/Constants.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v7/Events.ts b/packages/types/src/Metadata/v7/Events.ts deleted file mode 100644 index a968d99a61..0000000000 --- a/packages/types/src/Metadata/v7/Events.ts +++ /dev/null @@ -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'; diff --git a/packages/types/src/Metadata/v7/Metadata.ts b/packages/types/src/Metadata/v7/Metadata.ts index c74af7bb87..ae22e46a7f 100644 --- a/packages/types/src/Metadata/v7/Metadata.ts +++ b/packages/types/src/Metadata/v7/Metadata.ts @@ -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> { - return this.get('calls') as Option>; + public get calls (): Option> { + return this.get('calls') as Option>; } /** * @description the module constants */ - public get constants (): Vec { - return this.get('constants') as Vec; + public get constants (): Vec { + return this.get('constants') as Vec; } /** * @description the module events */ - public get events (): Option> { - return this.get('events') as Option>; + public get events (): Option> { + return this.get('events') as Option>; } /** diff --git a/packages/types/src/Metadata/v7/Storage.ts b/packages/types/src/Metadata/v7/Storage.ts index 1d9d727a8e..458ede2025 100644 --- a/packages/types/src/Metadata/v7/Storage.ts +++ b/packages/types/src/Metadata/v7/Storage.ts @@ -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, diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index 254d6d1bd2..bd70075d06 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -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': Option; 'Vec': Vec; + CallMetadataV0: CallMetadataV0; + 'Option': Option; + 'Vec': Vec; + EventMetadataV0: EventMetadataV0; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV0: FunctionArgumentMetadataV0; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV0: FunctionMetadataV0; + 'Option': Option; + 'Vec': Vec; + ModuleMetadataV0: ModuleMetadataV0; + 'Option': Option; + 'Vec': Vec; + OuterDispatchCallV0: OuterDispatchCallV0; + 'Option': Option; + 'Vec': Vec; + OuterDispatchMetadataV0: OuterDispatchMetadataV0; + 'Option': Option; + 'Vec': Vec; + EventMetadataV1: EventMetadataV1; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV1: FunctionArgumentMetadataV1; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV1: FunctionMetadataV1; + 'Option': Option; + 'Vec': Vec; + EventMetadataV2: EventMetadataV2; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV2: FunctionArgumentMetadataV2; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV2: FunctionMetadataV2; + 'Option': Option; + 'Vec': Vec; + DoubleMapTypeV3: DoubleMapTypeV3; + 'Option': Option; + 'Vec': Vec; + EventMetadataV3: EventMetadataV3; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV3: FunctionArgumentMetadataV3; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV3: FunctionMetadataV3; + 'Option': Option; + 'Vec': Vec; + DoubleMapTypeV4: DoubleMapTypeV4; + 'Option': Option; + 'Vec': Vec; + EventMetadataV4: EventMetadataV4; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV4: FunctionArgumentMetadataV4; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV4: FunctionMetadataV4; + 'Option': Option; + 'Vec': Vec; + DoubleMapTypeV5: DoubleMapTypeV5; + 'Option': Option; + 'Vec': Vec; + EventMetadataV5: EventMetadataV5; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV5: FunctionArgumentMetadataV5; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV5: FunctionMetadataV5; + 'Option': Option; + 'Vec': Vec; + DoubleMapTypeV6: DoubleMapTypeV6; + 'Option': Option; + 'Vec': Vec; + EventMetadataV6: EventMetadataV6; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV6: FunctionArgumentMetadataV6; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV6: FunctionMetadataV6; + 'Option': Option; + 'Vec': Vec; + ModuleConstantMetadataV6: ModuleConstantMetadataV6; + 'Option': Option; + 'Vec': Vec; + DoubleMapTypeV7: DoubleMapTypeV7; + 'Option': Option; + 'Vec': Vec; + EventMetadataV7: EventMetadataV7; + 'Option': Option; + 'Vec': Vec; + FunctionArgumentMetadataV7: FunctionArgumentMetadataV7; + 'Option': Option; + 'Vec': Vec; + FunctionMetadataV7: FunctionMetadataV7; + 'Option': Option; + 'Vec': Vec; + ModuleConstantMetadataV7: ModuleConstantMetadataV7; + 'Option': Option; + 'Vec': Vec; ApiId: ApiId; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index 45460f2bea..6c712b32e4 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -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'; diff --git a/packages/types/src/interfaces/metadata/definitions.ts b/packages/types/src/interfaces/metadata/definitions.ts new file mode 100644 index 0000000000..1b1ed629f4 --- /dev/null +++ b/packages/types/src/interfaces/metadata/definitions.ts @@ -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' + }, + EventMetadataV0: { + name: 'Text', + args: 'Vec', + documentation: 'Vec' + }, + FunctionArgumentMetadataV0: { + name: 'Text', + type: 'Type' + }, + FunctionMetadataV0: { + id: 'u16', + name: 'Text', + args: 'Vec', + documentation: 'Vec' + }, + ModuleMetadataV0: { + name: 'Text', + call: 'CallMetadataV0' + }, + OuterDispatchCallV0: { + name: 'Text', + prefix: 'Text', + index: 'u16' + }, + OuterDispatchMetadataV0: { + name: 'Text', + calls: 'Vec' + }, + + // v1 + EventMetadataV1: 'EventMetadataV0', + FunctionArgumentMetadataV1: 'FunctionArgumentMetadataV0', + FunctionMetadataV1: { + name: 'Text', + args: 'Vec', + documentation: 'Vec' + }, + + // 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' + }, + + // v7 + DoubleMapTypeV7: 'DoubleMapTypeV6', + EventMetadataV7: 'EventMetadataV6', + FunctionArgumentMetadataV7: 'FunctionArgumentMetadataV6', + FunctionMetadataV7: 'FunctionMetadataV6', + ModuleConstantMetadataV7: 'ModuleConstantMetadataV6' + } +}; diff --git a/packages/types/src/interfaces/metadata/index.ts b/packages/types/src/interfaces/metadata/index.ts new file mode 100644 index 0000000000..05fdc138ff --- /dev/null +++ b/packages/types/src/interfaces/metadata/index.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn build:interfaces`, do not edit +/* eslint-disable @typescript-eslint/no-empty-interface */ + +export * from './types'; diff --git a/packages/types/src/interfaces/metadata/types.ts b/packages/types/src/interfaces/metadata/types.ts new file mode 100644 index 0000000000..10a3779503 --- /dev/null +++ b/packages/types/src/interfaces/metadata/types.ts @@ -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 */ + readonly functions: Vec; +} + +/** 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 */ + readonly args: Vec; + /** Vec */ + readonly documentation: Vec; +} + +/** 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 */ + readonly args: Vec; + /** Vec */ + readonly documentation: Vec; +} + +/** Struct */ +export interface FunctionMetadataV1 extends Struct { + /** Text */ + readonly name: Text; + /** Vec */ + readonly args: Vec; + /** Vec */ + readonly documentation: Vec; +} + +/** 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 */ + readonly documentation: Vec; +} + +/** 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 */ + readonly calls: Vec; +} diff --git a/packages/types/src/interfaces/types.ts b/packages/types/src/interfaces/types.ts index addf3f6b4d..0050d4a5b9 100644 --- a/packages/types/src/interfaces/types.ts +++ b/packages/types/src/interfaces/types.ts @@ -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'; diff --git a/packages/types/src/primitive/Extrinsic/Extrinsic.ts b/packages/types/src/primitive/Extrinsic/Extrinsic.ts index 531db2aa57..b7d4601991 100644 --- a/packages/types/src/primitive/Extrinsic/Extrinsic.ts +++ b/packages/types/src/primitive/Extrinsic/Extrinsic.ts @@ -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 diff --git a/packages/types/src/primitive/Generic/Event.ts b/packages/types/src/primitive/Generic/Event.ts index 79fda8fb0c..61995fd733 100644 --- a/packages/types/src/primitive/Generic/Event.ts +++ b/packages/types/src/primitive/Generic/Event.ts @@ -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> = {}; diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index d47e9521f3..5ffcc0aeb0 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -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 {