Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/api-metadata/src/consts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Codec>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand Down
62 changes: 0 additions & 62 deletions packages/types/src/Metadata/v0/Calls.ts

This file was deleted.

59 changes: 5 additions & 54 deletions packages/types/src/Metadata/v0/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}

/**
Expand Down
32 changes: 16 additions & 16 deletions packages/types/src/Metadata/v0/Metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.

Expand All @@ -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));
}

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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())
)
);
}
Expand All @@ -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()]
)
: []
);
Expand Down
Loading