Convert RPC classes to primitive classes or /srml types (#1192)
* Convert RPC classes to primitive classes or /srml types * Lint passes... lokking at tests next. * Tests pass. * Types with basic docs (lots of work here) * Update StorageKey.spec.ts * Add injector to metadata doc generation * Fix import
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Vector } from '../codec';
|
||||
import { Vec } from '../codec';
|
||||
import { Codec } from '../types';
|
||||
|
||||
export interface MetadataInterface<Modules extends Codec> extends Codec {
|
||||
modules: Vector<Modules>;
|
||||
modules: Vec<Modules>;
|
||||
getUniqTypes (throwError: boolean): string[];
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ export default function validateTypes (types: string[], throwError: boolean): vo
|
||||
|
||||
case TypeDefInfo.Compact:
|
||||
case TypeDefInfo.Option:
|
||||
case TypeDefInfo.Vector:
|
||||
case TypeDefInfo.Vec:
|
||||
return extractTypes([(decoded.sub as TypeDef).type]);
|
||||
|
||||
case TypeDefInfo.VectorFixed:
|
||||
case TypeDefInfo.VecFixed:
|
||||
return extractTypes([(decoded.ext as TypeDefExtVecFixed).type]);
|
||||
|
||||
case TypeDefInfo.Tuple:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import U16 from '../../primitive/U16';
|
||||
|
||||
@@ -42,15 +42,15 @@ export class OuterDispatchMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: Text,
|
||||
calls: Vector.with(OuterDispatchCall)
|
||||
calls: Vec.with(OuterDispatchCall)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[OuterDispathCall]] wrapped
|
||||
*/
|
||||
public get calls (): Vector<OuterDispatchCall> {
|
||||
return this.get('calls') as Vector<OuterDispatchCall>;
|
||||
public get calls (): Vec<OuterDispatchCall> {
|
||||
return this.get('calls') as Vec<OuterDispatchCall>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
import Tuple from '../../codec/Tuple';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
|
||||
@@ -12,38 +12,38 @@ export class EventMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: Text,
|
||||
args: Vector.with(Type),
|
||||
documentation: Vector.with(Text)
|
||||
args: Vec.with(Type),
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The arguments of [[Type]]
|
||||
*/
|
||||
public get args (): Vector<Type> {
|
||||
return this.get('args') as Vector<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 (): Vector<Type> {
|
||||
public get arguments (): Vec<Type> {
|
||||
return this.args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
@@ -59,15 +59,15 @@ export class OuterEventEventMetadata extends Tuple {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
Text,
|
||||
'Vec<EventMetadata>': Vector.with(EventMetadata)
|
||||
'Vec<EventMetadata>': Vec.with(EventMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[EventMetadata]]
|
||||
*/
|
||||
public get events (): Vector<EventMetadata> {
|
||||
return this[1] as Vector<EventMetadata>;
|
||||
public get events (): Vec<EventMetadata> {
|
||||
return this[1] as Vec<EventMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,15 +82,15 @@ export class OuterEventMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: Text,
|
||||
events: Vector.with(OuterEventEventMetadata)
|
||||
events: Vec.with(OuterEventEventMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[OuterEventEventMetadata]]
|
||||
*/
|
||||
public get events (): Vector<OuterEventEventMetadata> {
|
||||
return this.get('events') as Vector<OuterEventEventMetadata>;
|
||||
public get events (): Vec<OuterEventEventMetadata> {
|
||||
return this.get('events') as Vec<OuterEventEventMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ import { hexToU8a, isHex, isU8a } from '@polkadot/util';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
import { OuterDispatchMetadata, OuterDispatchCall } from './Calls';
|
||||
import { OuterEventMetadata, OuterEventEventMetadata } from './Events';
|
||||
@@ -25,7 +25,7 @@ export default class MetadataV0 extends Struct implements MetadataInterface<Runt
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
outerEvent: OuterEventMetadata,
|
||||
modules: Vector.with(RuntimeModuleMetadata),
|
||||
modules: Vec.with(RuntimeModuleMetadata),
|
||||
outerDispatch: OuterDispatchMetadata
|
||||
}, MetadataV0.decodeMetadata(value));
|
||||
}
|
||||
@@ -55,22 +55,22 @@ export default class MetadataV0 extends Struct implements MetadataInterface<Runt
|
||||
/**
|
||||
* @description Wrapped [[OuterDispatchCall]]
|
||||
*/
|
||||
public get calls (): Vector<OuterDispatchCall> {
|
||||
public get calls (): Vec<OuterDispatchCall> {
|
||||
return (this.get('outerDispatch') as OuterDispatchMetadata).calls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Wrapped [[OuterEventEventMetadata]]
|
||||
*/
|
||||
public get events (): Vector<OuterEventEventMetadata> {
|
||||
public get events (): Vec<OuterEventEventMetadata> {
|
||||
return (this.get('outerEvent') as OuterEventMetadata).events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Wrapped [[RuntimeModuleMetadata]]
|
||||
*/
|
||||
public get modules (): Vector<RuntimeModuleMetadata> {
|
||||
return this.get('modules') as Vector<RuntimeModuleMetadata>;
|
||||
public get modules (): Vec<RuntimeModuleMetadata> {
|
||||
return this.get('modules') as Vec<RuntimeModuleMetadata>;
|
||||
}
|
||||
|
||||
private get argNames (): string[][][] {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
import U16 from '../../primitive/U16';
|
||||
@@ -39,38 +39,38 @@ export class FunctionMetadata extends Struct {
|
||||
super({
|
||||
id: U16,
|
||||
name: Text,
|
||||
args: Vector.with(FunctionArgumentMetadata),
|
||||
documentation: Vector.with(Text)
|
||||
args: Vec.with(FunctionArgumentMetadata),
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The arguments of [[Type]]
|
||||
*/
|
||||
public get args (): Vector<FunctionArgumentMetadata> {
|
||||
return this.get('args') as Vector<FunctionArgumentMetadata>;
|
||||
public get args (): Vec<FunctionArgumentMetadata> {
|
||||
return this.get('args') as Vec<FunctionArgumentMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[FunctionArgumentMetadata]] for arguments
|
||||
* @deprecated Use `.args` instead
|
||||
*/
|
||||
public get arguments (): Vector<FunctionArgumentMetadata> {
|
||||
return this.get('arguments') as Vector<FunctionArgumentMetadata>;
|
||||
public get arguments (): Vec<FunctionArgumentMetadata> {
|
||||
return this.get('arguments') as Vec<FunctionArgumentMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
@@ -93,15 +93,15 @@ export class CallMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: Text,
|
||||
functions: Vector.with(FunctionMetadata)
|
||||
functions: Vec.with(FunctionMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The functions available as [[FunctionMetadata]]
|
||||
*/
|
||||
public get functions (): Vector<FunctionMetadata> {
|
||||
return this.get('functions') as Vector<FunctionMetadata>;
|
||||
public get functions (): Vec<FunctionMetadata> {
|
||||
return this.get('functions') as Vec<FunctionMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
@@ -131,7 +131,7 @@ export interface StorageFunctionMetadataValue {
|
||||
modifier: StorageFunctionModifier | AnyNumber;
|
||||
type: StorageFunctionType;
|
||||
fallback: Bytes;
|
||||
documentation: Vector<Text> | string[];
|
||||
documentation: Vec<Text> | string[];
|
||||
}
|
||||
|
||||
export class StorageFunctionMetadata extends Struct {
|
||||
@@ -141,7 +141,7 @@ export class StorageFunctionMetadata extends Struct {
|
||||
modifier: StorageFunctionModifier,
|
||||
type: StorageFunctionType,
|
||||
fallback: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -163,15 +163,15 @@ export class StorageFunctionMetadata extends Struct {
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
@@ -201,15 +201,15 @@ export class StorageMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
prefix: Text,
|
||||
functions: Vector.with(StorageFunctionMetadata)
|
||||
functions: Vec.with(StorageFunctionMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[StorageFunctionMetadata]] for the section
|
||||
*/
|
||||
public get functions (): Vector<StorageFunctionMetadata> {
|
||||
return this.get('functions') as Vector<StorageFunctionMetadata>;
|
||||
public get functions (): Vec<StorageFunctionMetadata> {
|
||||
return this.get('functions') as Vec<StorageFunctionMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { Option, Vector } from '../../codec';
|
||||
import { Option, Vec } from '../../codec';
|
||||
import MetadataV0 from './Metadata';
|
||||
import { RuntimeModuleMetadata } from './Modules';
|
||||
import { Text } from '../../primitive';
|
||||
@@ -16,23 +16,23 @@ import { StorageFunctionMetadata } from '../v1/Storage';
|
||||
|
||||
function toV1Calls (modul: RuntimeModuleMetadata): Option<FunctionMetadata> {
|
||||
return modul.module.call.functions.length === 0
|
||||
? new Option(Vector.with(FunctionMetadata))
|
||||
: new Option(Vector.with(FunctionMetadata), modul.module.call.functions);
|
||||
? new Option(Vec.with(FunctionMetadata))
|
||||
: new Option(Vec.with(FunctionMetadata), modul.module.call.functions);
|
||||
}
|
||||
|
||||
function toV1Events (metadataV0: MetadataV0, prefix: Text): Option<EventMetadata> {
|
||||
const events = metadataV0.events.find((event): boolean => event.name.eq(prefix));
|
||||
|
||||
return events
|
||||
? new Option(Vector.with(EventMetadata), events.events)
|
||||
: new Option(Vector.with(EventMetadata));
|
||||
? new Option(Vec.with(EventMetadata), events.events)
|
||||
: new Option(Vec.with(EventMetadata));
|
||||
}
|
||||
|
||||
function toV1Storage (modul: RuntimeModuleMetadata): Option<StorageFunctionMetadata> {
|
||||
return modul.storage.isNone
|
||||
? new Option(Vector.with(StorageFunctionMetadata))
|
||||
? new Option(Vec.with(StorageFunctionMetadata))
|
||||
: new Option(
|
||||
Vector.with(StorageFunctionMetadata),
|
||||
Vec.with(StorageFunctionMetadata),
|
||||
modul.storage.unwrap().functions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
|
||||
@@ -39,30 +39,30 @@ export class FunctionMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
name: Text,
|
||||
args: Vector.with(FunctionArgumentMetadata),
|
||||
documentation: Vector.with(Text)
|
||||
args: Vec.with(FunctionArgumentMetadata),
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[FunctionArgumentMetadata]] for arguments
|
||||
*/
|
||||
public get args (): Vector<FunctionArgumentMetadata> {
|
||||
return this.get('args') as Vector<FunctionArgumentMetadata>;
|
||||
public get args (): Vec<FunctionArgumentMetadata> {
|
||||
return this.get('args') as Vec<FunctionArgumentMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -24,24 +24,24 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata))
|
||||
storage: Option.with(Vec.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata))
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageFunctionMetadata>>;
|
||||
public get storage (): Option<Vec<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV1 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -24,24 +24,24 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata))
|
||||
storage: Option.with(Vec.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata))
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageFunctionMetadata>>;
|
||||
public get storage (): Option<Vec<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV2 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bool from '../../primitive/Bool';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
@@ -113,7 +113,7 @@ export interface StorageFunctionMetadataValue {
|
||||
modifier: StorageFunctionModifier | AnyNumber;
|
||||
type: StorageFunctionType;
|
||||
fallback: Bytes;
|
||||
documentation: Vector<Text> | string[];
|
||||
documentation: Vec<Text> | string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ export class StorageFunctionMetadata extends Struct {
|
||||
modifier: StorageFunctionModifier,
|
||||
type: StorageFunctionType,
|
||||
fallback: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -143,15 +143,15 @@ export class StorageFunctionMetadata extends Struct {
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -24,24 +24,24 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata))
|
||||
storage: Option.with(Vec.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata))
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageFunctionMetadata>>;
|
||||
public get storage (): Option<Vec<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV3 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
@@ -146,7 +146,7 @@ export interface StorageFunctionMetadataValue {
|
||||
modifier: StorageFunctionModifier | AnyNumber;
|
||||
type: StorageFunctionType;
|
||||
fallback: Bytes;
|
||||
documentation: Vector<Text> | string[];
|
||||
documentation: Vec<Text> | string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ export class StorageFunctionMetadata extends Struct {
|
||||
modifier: StorageFunctionModifier,
|
||||
type: StorageFunctionType,
|
||||
fallback: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -176,15 +176,15 @@ export class StorageFunctionMetadata extends Struct {
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Option, Vector } from '../../codec';
|
||||
import { Option, Vec } from '../../codec';
|
||||
import MetadataV3 from './Metadata';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
import MetadataV4 from '../v4';
|
||||
@@ -57,7 +57,7 @@ export default function toV4 (metadataV3: MetadataV3): MetadataV4 {
|
||||
prefix: modul.prefix,
|
||||
storage: modul.storage.isSome
|
||||
? new Option(
|
||||
Vector.with(StorageFunctionMetadata),
|
||||
Vec.with(StorageFunctionMetadata),
|
||||
modul.storage.unwrap().map(toV4StorageFunction)
|
||||
)
|
||||
: undefined,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -24,24 +24,24 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata))
|
||||
storage: Option.with(Vec.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata))
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageFunctionMetadata>>;
|
||||
public get storage (): Option<Vec<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV4 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bool from '../../primitive/Bool';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
@@ -190,7 +190,7 @@ export interface StorageFunctionMetadataValue {
|
||||
modifier: StorageFunctionModifier | AnyNumber;
|
||||
type: StorageFunctionType;
|
||||
fallback: Bytes;
|
||||
documentation: Vector<Text> | string[];
|
||||
documentation: Vec<Text> | string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ export class StorageFunctionMetadata extends Struct {
|
||||
modifier: StorageFunctionModifier,
|
||||
type: StorageFunctionType,
|
||||
fallback: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -227,15 +227,15 @@ export class StorageFunctionMetadata extends Struct {
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Option, Vector } from '../../codec';
|
||||
import { Option, Vec } from '../../codec';
|
||||
import Text from '../../primitive/Text';
|
||||
import MetadataV4 from './Metadata';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
@@ -67,7 +67,7 @@ export default function toV5 (metadataV4: MetadataV4): MetadataV5 {
|
||||
prefix: modul.prefix,
|
||||
storage: modul.storage.isSome
|
||||
? new Option(
|
||||
Vector.with(StorageFunctionMetadata),
|
||||
Vec.with(StorageFunctionMetadata),
|
||||
modul.storage.unwrap().map(toV5StorageFunction)
|
||||
)
|
||||
: undefined,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -24,24 +24,24 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata))
|
||||
storage: Option.with(Vec.with(StorageFunctionMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata))
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +61,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageFunctionMetadata>>;
|
||||
public get storage (): Option<Vec<StorageFunctionMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV5 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
import Text from '../../primitive/Text';
|
||||
@@ -151,7 +151,7 @@ export interface StorageFunctionMetadataValue {
|
||||
modifier: StorageFunctionModifier | AnyNumber;
|
||||
type: StorageFunctionType;
|
||||
fallback: Bytes;
|
||||
documentation: Vector<Text> | string[];
|
||||
documentation: Vec<Text> | string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ export class StorageFunctionMetadata extends Struct {
|
||||
modifier: StorageFunctionModifier,
|
||||
type: StorageFunctionType,
|
||||
fallback: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -188,15 +188,15 @@ export class StorageFunctionMetadata extends Struct {
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Text]] documentation
|
||||
* @deprecated Use `.documentation` instead.
|
||||
*/
|
||||
public get docs (): Vector<Text> {
|
||||
public get docs (): Vec<Text> {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
|
||||
export class ModuleConstantMetadata extends Struct {
|
||||
public constructor (value?: any) {
|
||||
@@ -14,7 +14,7 @@ export class ModuleConstantMetadata extends Struct {
|
||||
name: Text,
|
||||
type: Type,
|
||||
value: Bytes,
|
||||
documentation: Vector.with(Text)
|
||||
documentation: Vec.with(Text)
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ModuleConstantMetadata extends Struct {
|
||||
/**
|
||||
* @description The documentation
|
||||
*/
|
||||
public get documentation (): Vector<Text> {
|
||||
return this.get('documentation') as Vector<Text>;
|
||||
public get documentation (): Vec<Text> {
|
||||
return this.get('documentation') as Vec<Text>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -25,32 +25,32 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
prefix: Text,
|
||||
storage: Option.with(Vector.with(StorageEntryMetadata)),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata)),
|
||||
constants: Vector.with(ModuleConstantMetadata)
|
||||
storage: Option.with(Vec.with(StorageEntryMetadata)),
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata)),
|
||||
constants: Vec.with(ModuleConstantMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module constants
|
||||
*/
|
||||
public get constants (): Vector<ModuleConstantMetadata> {
|
||||
return this.get('constants') as Vector<ModuleConstantMetadata>;
|
||||
public get constants (): Vec<ModuleConstantMetadata> {
|
||||
return this.get('constants') as Vec<ModuleConstantMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,8 +70,8 @@ export class ModuleMetadata extends Struct {
|
||||
/**
|
||||
* @description the associated module storage
|
||||
*/
|
||||
public get storage (): Option<Vector<StorageEntryMetadata>> {
|
||||
return this.get('storage') as Option<Vector<StorageEntryMetadata>>;
|
||||
public get storage (): Option<Vec<StorageEntryMetadata>> {
|
||||
return this.get('storage') as Option<Vec<StorageEntryMetadata>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,15 +83,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV6 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { flattenUniq, validateTypes } from '../util';
|
||||
|
||||
@@ -25,31 +25,31 @@ export class ModuleMetadata extends Struct {
|
||||
super({
|
||||
name: Text,
|
||||
storage: Option.with(StorageMetadata),
|
||||
calls: Option.with(Vector.with(FunctionMetadata)),
|
||||
events: Option.with(Vector.with(EventMetadata)),
|
||||
constants: Vector.with(ModuleConstantMetadata)
|
||||
calls: Option.with(Vec.with(FunctionMetadata)),
|
||||
events: Option.with(Vec.with(EventMetadata)),
|
||||
constants: Vec.with(ModuleConstantMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module calls
|
||||
*/
|
||||
public get calls (): Option<Vector<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vector<FunctionMetadata>>;
|
||||
public get calls (): Option<Vec<FunctionMetadata>> {
|
||||
return this.get('calls') as Option<Vec<FunctionMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module constants
|
||||
*/
|
||||
public get constants (): Vector<ModuleConstantMetadata> {
|
||||
return this.get('constants') as Vector<ModuleConstantMetadata>;
|
||||
public get constants (): Vec<ModuleConstantMetadata> {
|
||||
return this.get('constants') as Vec<ModuleConstantMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the module events
|
||||
*/
|
||||
public get events (): Option<Vector<EventMetadata>> {
|
||||
return this.get('events') as Option<Vector<EventMetadata>>;
|
||||
public get events (): Option<Vec<EventMetadata>> {
|
||||
return this.get('events') as Option<Vec<EventMetadata>>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,15 +82,15 @@ export class ModuleMetadata extends Struct {
|
||||
export default class MetadataV7 extends Struct implements MetadataInterface<ModuleMetadata> {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
modules: Vector.with(ModuleMetadata)
|
||||
modules: Vec.with(ModuleMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The associated modules for this structure
|
||||
*/
|
||||
public get modules (): Vector<ModuleMetadata> {
|
||||
return this.get('modules') as Vector<ModuleMetadata>;
|
||||
public get modules (): Vec<ModuleMetadata> {
|
||||
return this.get('modules') as Vec<ModuleMetadata>;
|
||||
}
|
||||
|
||||
private get callNames (): string[][][] {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vector from '../../codec/Vector';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
|
||||
import { DoubleMapType, MapType, PlainType, StorageEntryMetadata, StorageEntryMetadataValue, StorageEntryModifier, StorageEntryType } from '../v6/Storage';
|
||||
@@ -24,15 +24,15 @@ export class StorageMetadata extends Struct {
|
||||
super({
|
||||
prefix: Text,
|
||||
// NOTE renamed to items from entries (since Struct already has entries from Map)
|
||||
items: Vector.with(StorageEntryMetadata)
|
||||
items: Vec.with(StorageEntryMetadata)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the storage entries
|
||||
*/
|
||||
public get items (): Vector<StorageEntryMetadata> {
|
||||
return this.get('items') as Vector<StorageEntryMetadata>;
|
||||
public get items (): Vec<StorageEntryMetadata> {
|
||||
return this.get('items') as Vec<StorageEntryMetadata>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,7 @@ export default abstract class AbstractArray<T extends Codec> extends Array<T> im
|
||||
);
|
||||
}
|
||||
|
||||
// Below are methods that we override. When we do a `new Vector(...).map()`,
|
||||
// Below are methods that we override. When we do a `new Vec(...).map()`,
|
||||
// we want it to return an Array. We only override the methods that return a
|
||||
// new instance.
|
||||
|
||||
|
||||
@@ -2,18 +2,20 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber, Constructor } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { bnToBn, compactAddLength, compactFromU8a, compactStripLength, compactToU8a, hexToBn, isBn, isHex, isNumber, isString } from '@polkadot/util';
|
||||
import { DEFAULT_BITLENGTH } from '@polkadot/util/compact/defaults';
|
||||
|
||||
import Moment from '../primitive/Moment';
|
||||
import { AnyNumber, Constructor } from '../types';
|
||||
import AbstractInt, { UIntBitLength } from './AbstractInt';
|
||||
import { UIntBitLength } from './AbstractInt';
|
||||
import UInt from './UInt';
|
||||
import Base from './Base';
|
||||
|
||||
// List of codec types that are compact-encodable
|
||||
export const COMPACT_ENCODABLE = [AbstractInt, Moment];
|
||||
export type CompactEncodable = AbstractInt | Moment; // FIXME is there a way to do it not-manually from the array?
|
||||
export const COMPACT_ENCODABLE = [UInt, Moment];
|
||||
export type CompactEncodable = UInt | Moment; // FIXME is there a way to do it not-manually from the array?
|
||||
|
||||
/**
|
||||
* @name Compact
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Struct, Option, Tuple, Vector } from '.';
|
||||
import { Struct, Option, Tuple, Vec } from '.';
|
||||
import { Constructor, Codec } from '../types';
|
||||
|
||||
type TypeWithValues = [Constructor, any[]];
|
||||
@@ -35,8 +35,8 @@ export default class Linkage<T extends Codec> extends Struct {
|
||||
export class LinkageResult extends Tuple {
|
||||
public constructor ([TypeKey, keys]: TypeWithValues, [TypeValue, values]: TypeWithValues) {
|
||||
super({
|
||||
Keys: Vector.with(TypeKey),
|
||||
Values: Vector.with(TypeValue)
|
||||
Keys: Vec.with(TypeKey),
|
||||
Values: Vec.with(TypeValue)
|
||||
}, [keys, values]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 { injectDefinitions } from '../srml';
|
||||
import Option from './Option';
|
||||
import Bytes from '../primitive/Bytes';
|
||||
import U32 from '../primitive/U32';
|
||||
@@ -23,6 +24,10 @@ const testEncode = (to: string, expected: any): void =>
|
||||
});
|
||||
|
||||
describe('Option', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
it('converts undefined/null to empty', (): void => {
|
||||
expect(new Option(Text, undefined).isNone).toBe(true);
|
||||
expect(new Option(Text, null).isNone).toBe(true);
|
||||
|
||||
@@ -9,7 +9,7 @@ import U32 from '../primitive/U32';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import { CodecTo } from '../types';
|
||||
import Struct from './Struct';
|
||||
import Vector from './Vector';
|
||||
import Vec from './Vec';
|
||||
|
||||
describe('Struct', (): void => {
|
||||
beforeEach((): void => {
|
||||
@@ -66,7 +66,7 @@ describe('Struct', (): void => {
|
||||
|
||||
it('decodes a more complicated type', (): void => {
|
||||
const s = new Struct({
|
||||
foo: Vector.with(Struct.with({
|
||||
foo: Vec.with(Struct.with({
|
||||
bar: Text
|
||||
}))
|
||||
}, { foo: [{ bar: 1 }, { bar: 2 }] });
|
||||
@@ -198,7 +198,7 @@ describe('Struct', (): void => {
|
||||
compactNumber: ClassOf('Compact<BlockNumber>'),
|
||||
optionNumber: ClassOf('Option<BlockNumber>'),
|
||||
counter: U32,
|
||||
vector: Vector.with(AccountId)
|
||||
vector: Vec.with(AccountId)
|
||||
}).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
|
||||
@@ -11,14 +11,14 @@ import AccountId from '../primitive/AccountId';
|
||||
import Method from '../primitive/Method';
|
||||
import Text from '../primitive/Text';
|
||||
import createType from './createType';
|
||||
import Vector from './Vector';
|
||||
import Vec from './Vec';
|
||||
import Tuple from './Tuple';
|
||||
|
||||
describe('Vector', (): void => {
|
||||
let vector: Vector<Codec>;
|
||||
describe('Vec', (): void => {
|
||||
let vector: Vec<Codec>;
|
||||
|
||||
beforeEach((): void => {
|
||||
vector = new Vector(Text, ['1', '23', '345', '4567', new Text('56789')]);
|
||||
vector = new Vec(Text, ['1', '23', '345', '4567', new Text('56789')]);
|
||||
|
||||
Method.injectMethods(extrinsics);
|
||||
});
|
||||
@@ -44,7 +44,7 @@ describe('Vector', (): void => {
|
||||
|
||||
it('allows contruction via JSON', (): void => {
|
||||
expect(
|
||||
new Vector(Text, ['6', '7']).toJSON()
|
||||
new Vec(Text, ['6', '7']).toJSON()
|
||||
).toEqual(['6', '7']);
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('Vector', (): void => {
|
||||
const test = createType('Vec<(PropIndex, Proposal, AccountId)>', new Uint8Array([
|
||||
4, 10, 0, 0, 0, 0, 3, 80, 123, 10, 9, 34, 48, 120, 52, 50, 34, 58, 32, 34, 48, 120, 52, 51, 34, 10, 125, 10, 209, 114, 167, 76, 218, 76, 134, 89, 18, 195, 43, 160, 168, 10, 87, 174, 105, 171, 174, 65, 14, 92, 203, 89, 222, 232, 78, 47, 68, 50, 219, 79
|
||||
]));
|
||||
const first = (test as Vector<Codec>)[0] as Tuple;
|
||||
const first = (test as Vec<Codec>)[0] as Tuple;
|
||||
|
||||
expect((first[0] as PropIndex).toNumber()).toEqual(10);
|
||||
expect((first[1] as Proposal).callIndex).toEqual(new Uint8Array([0, 3]));
|
||||
@@ -118,7 +118,7 @@ describe('Vector', (): void => {
|
||||
});
|
||||
|
||||
describe('utils', (): void => {
|
||||
const vec = new Vector(Text, ['123', '456']);
|
||||
const vec = new Vec(Text, ['123', '456']);
|
||||
|
||||
it('compares against codec types', (): void => {
|
||||
expect(vec.eq([new Text('123'), new Text('456')])).toBe(true);
|
||||
@@ -130,7 +130,7 @@ describe('Vector', (): void => {
|
||||
|
||||
it('finds the index of an value', (): void => {
|
||||
const myId = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const vec = new Vector(AccountId, [
|
||||
const vec = new Vec(AccountId, [
|
||||
'5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw', '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
|
||||
]);
|
||||
|
||||
@@ -12,24 +12,24 @@ import AbstractArray from './AbstractArray';
|
||||
const MAX_LENGTH = 32768;
|
||||
|
||||
/**
|
||||
* @name Vector
|
||||
* @name Vec
|
||||
* @description
|
||||
* This manages codec arrays. Internally it keeps track of the length (as decoded) and allows
|
||||
* construction with the passed `Type` in the constructor. It is an extension to Array, providing
|
||||
* specific encoding/decoding on top of the base type.
|
||||
*/
|
||||
export default class Vector<T extends Codec> extends AbstractArray<T> {
|
||||
export default class Vec<T extends Codec> extends AbstractArray<T> {
|
||||
private _Type: Constructor<T>;
|
||||
|
||||
public constructor (Type: Constructor<T>, value: Vector<any> | Uint8Array | string | any[] = [] as any[]) {
|
||||
public constructor (Type: Constructor<T>, value: Vec<any> | Uint8Array | string | any[] = [] as any[]) {
|
||||
super(
|
||||
...Vector.decodeVector(Type, value)
|
||||
...Vec.decodeVec(Type, value)
|
||||
);
|
||||
|
||||
this._Type = Type;
|
||||
}
|
||||
|
||||
public static decodeVector<T extends Codec> (Type: Constructor<T>, value: Vector<any> | Uint8Array | string | any[]): T[] {
|
||||
public static decodeVec<T extends Codec> (Type: Constructor<T>, value: Vec<any> | Uint8Array | string | any[]): T[] {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((entry, index): T => {
|
||||
try {
|
||||
@@ -37,7 +37,7 @@ export default class Vector<T extends Codec> extends AbstractArray<T> {
|
||||
? entry
|
||||
: new Type(entry);
|
||||
} catch (error) {
|
||||
console.error(`Unable to decode Vector on index ${index}`, error.message);
|
||||
console.error(`Unable to decode Vec on index ${index}`, error.message);
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -47,19 +47,19 @@ export default class Vector<T extends Codec> extends AbstractArray<T> {
|
||||
const u8a = u8aToU8a(value);
|
||||
const [offset, length] = Compact.decodeU8a(u8a);
|
||||
|
||||
assert(length.lten(MAX_LENGTH), `Vector length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
assert(length.lten(MAX_LENGTH), `Vec length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
|
||||
return decodeU8a(u8a.subarray(offset), new Array(length.toNumber()).fill(Type)) as T[];
|
||||
}
|
||||
|
||||
public static with<O extends Codec> (Type: Constructor<O>): Constructor<Vector<O>> {
|
||||
return class extends Vector<O> {
|
||||
public static with<O extends Codec> (Type: Constructor<O>): Constructor<Vec<O>> {
|
||||
return class extends Vec<O> {
|
||||
public constructor (value?: any[]) {
|
||||
super(Type, value);
|
||||
}
|
||||
|
||||
public static Fallback = Type.Fallback
|
||||
? Vector.with(Type.Fallback)
|
||||
? Vec.with(Type.Fallback)
|
||||
: undefined;
|
||||
};
|
||||
}
|
||||
@@ -6,13 +6,13 @@ import { Codec } from '../types';
|
||||
import AbstractArray from './AbstractArray';
|
||||
|
||||
/**
|
||||
* @name VectorAny
|
||||
* @name VecAny
|
||||
* @description
|
||||
* This manages codec arrays, assuming that the inputs are already of type Codec. Unlike
|
||||
* a vector, this can be used to manage array-like structures with variable arguments of
|
||||
* any types
|
||||
*/
|
||||
export default class VectorAny<T extends Codec> extends AbstractArray<T> {
|
||||
export default class VecAny<T extends Codec> extends AbstractArray<T> {
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
@@ -7,26 +7,26 @@ import { Codec, Constructor } from '../types';
|
||||
import { assert, isU8a, u8aConcat, compactToU8a } from '@polkadot/util';
|
||||
|
||||
import AbstractArray from './AbstractArray';
|
||||
import Vector from './Vector';
|
||||
import Vec from './Vec';
|
||||
|
||||
/**
|
||||
* @name VectorFixed
|
||||
* @name VecFixed
|
||||
* @description
|
||||
* This manages codec arrays of a fixed length
|
||||
*/
|
||||
export default class VectorFixed<T extends Codec> extends AbstractArray<T> {
|
||||
export default class VecFixed<T extends Codec> extends AbstractArray<T> {
|
||||
private _Type: Constructor<T>;
|
||||
|
||||
public constructor (Type: Constructor<T>, length: number, value: VectorFixed<any> | Uint8Array | string | any[] = [] as any[]) {
|
||||
public constructor (Type: Constructor<T>, length: number, value: VecFixed<any> | Uint8Array | string | any[] = [] as any[]) {
|
||||
super(
|
||||
...VectorFixed.decodeVectorFixed(Type, length, value)
|
||||
...VecFixed.decodeVecFixed(Type, length, value)
|
||||
);
|
||||
|
||||
this._Type = Type;
|
||||
}
|
||||
|
||||
public static decodeVectorFixed<T extends Codec> (Type: Constructor<T>, allocLength: number, value: VectorFixed<any> | Uint8Array | string | any[]): T[] {
|
||||
const values = Vector.decodeVector(
|
||||
public static decodeVecFixed<T extends Codec> (Type: Constructor<T>, allocLength: number, value: VecFixed<any> | Uint8Array | string | any[]): T[] {
|
||||
const values = Vec.decodeVec(
|
||||
Type,
|
||||
isU8a(value)
|
||||
? u8aConcat(compactToU8a(allocLength), value)
|
||||
@@ -42,14 +42,14 @@ export default class VectorFixed<T extends Codec> extends AbstractArray<T> {
|
||||
return values;
|
||||
}
|
||||
|
||||
public static with<O extends Codec> (Type: Constructor<O>, length: number): Constructor<VectorFixed<O>> {
|
||||
return class extends VectorFixed<O> {
|
||||
public static with<O extends Codec> (Type: Constructor<O>, length: number): Constructor<VecFixed<O>> {
|
||||
return class extends VecFixed<O> {
|
||||
public constructor (value?: any[]) {
|
||||
super(Type, length, value);
|
||||
}
|
||||
|
||||
public static Fallback = Type.Fallback
|
||||
? VectorFixed.with(Type.Fallback, length)
|
||||
? VecFixed.with(Type.Fallback, length)
|
||||
: undefined;
|
||||
};
|
||||
}
|
||||
@@ -86,7 +86,7 @@ describe('getTypeValue', (): void => {
|
||||
}
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Vector,
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<u64>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -118,7 +118,7 @@ describe('getTypeValue', (): void => {
|
||||
type: 'Text'
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Vector,
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<(Bool, u128)>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
@@ -145,7 +145,7 @@ describe('getTypeValue', (): void => {
|
||||
expect(
|
||||
getTypeDef('Vec<(PropIndex, Proposal, AccountId)>')
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Vector,
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<(PropIndex, Proposal, AccountId)>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
|
||||
@@ -8,7 +8,6 @@ import { assert } from '@polkadot/util';
|
||||
import { InterfaceRegistry } from '../interfaceRegistry';
|
||||
import { Codec, Constructor } from '../types';
|
||||
import Null from '../primitive/Null';
|
||||
import StorageData from '../primitive/StorageData';
|
||||
import Text from '../primitive/Text';
|
||||
import Compact from './Compact';
|
||||
import Enum from './Enum';
|
||||
@@ -19,8 +18,8 @@ import Struct from './Struct';
|
||||
import Tuple from './Tuple';
|
||||
import U8aFixed, { BitLength as U8aFixedBitLength } from './U8aFixed';
|
||||
import UInt from './UInt';
|
||||
import Vector from './Vector';
|
||||
import VectorFixed from './VectorFixed';
|
||||
import Vec from './Vec';
|
||||
import VecFixed from './VecFixed';
|
||||
import getRegistry from './typeRegistry';
|
||||
|
||||
export enum TypeDefInfo {
|
||||
@@ -33,8 +32,8 @@ export enum TypeDefInfo {
|
||||
Set,
|
||||
Struct,
|
||||
Tuple,
|
||||
Vector,
|
||||
VectorFixed,
|
||||
Vec,
|
||||
VecFixed,
|
||||
// anything not full supported (keep this as the last entry)
|
||||
Null
|
||||
}
|
||||
@@ -114,11 +113,10 @@ function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>
|
||||
name,
|
||||
type: 'Null'
|
||||
}))
|
||||
: Object.entries(details).map(([name, type]): TypeDef => ({
|
||||
info: TypeDefInfo.Plain,
|
||||
name,
|
||||
type: type || 'Null'
|
||||
}));
|
||||
: Object.entries(details).map(([name, type]): TypeDef =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
getTypeDef(type || 'Null', name)
|
||||
);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -169,7 +167,7 @@ export function getTypeDef (_type: Text | string, name?: string): TypeDef {
|
||||
// as a first round, only u8 via u8aFixed, we can add more support
|
||||
assert(vecLen <= 256, `${type}: Only support for [Type; <length>], where length <= 256`);
|
||||
|
||||
value.info = TypeDefInfo.VectorFixed;
|
||||
value.info = TypeDefInfo.VecFixed;
|
||||
value.ext = { length: vecLen, type: vecType } as unknown as TypeDefExtVecFixed;
|
||||
} else if (startingWith(type, '{', '}')) {
|
||||
const parsed = JSON.parse(type);
|
||||
@@ -190,7 +188,7 @@ export function getTypeDef (_type: Text | string, name?: string): TypeDef {
|
||||
value.info = TypeDefInfo.Option;
|
||||
value.sub = getTypeDef(subType);
|
||||
} else if (startingWith(type, 'Vec<', '>')) {
|
||||
value.info = TypeDefInfo.Vector;
|
||||
value.info = TypeDefInfo.Vec;
|
||||
value.sub = getTypeDef(subType);
|
||||
} else if (startingWith(type, 'Linkage<', '>')) {
|
||||
value.info = TypeDefInfo.Linkage;
|
||||
@@ -284,13 +282,13 @@ export function getTypeClass<T extends Codec = Codec> (value: TypeDef, Fallback?
|
||||
(value.sub as TypeDef[]).map((Type): Constructor<Codec> => getTypeClass(Type))
|
||||
) as unknown as Constructor<T>;
|
||||
|
||||
case TypeDefInfo.Vector:
|
||||
assert(value.sub && !Array.isArray(value.sub), 'Expected subtype for Vector');
|
||||
return Vector.with(
|
||||
case TypeDefInfo.Vec:
|
||||
assert(value.sub && !Array.isArray(value.sub), 'Expected subtype for Vec');
|
||||
return Vec.with(
|
||||
getTypeClass<Codec>(value.sub as TypeDef)
|
||||
) as unknown as Constructor<T>;
|
||||
|
||||
case TypeDefInfo.VectorFixed:
|
||||
case TypeDefInfo.VecFixed:
|
||||
assert(value.ext, 'Expected length & type information for fixed vector');
|
||||
|
||||
const ext = value.ext as TypeDefExtVecFixed;
|
||||
@@ -298,7 +296,7 @@ export function getTypeClass<T extends Codec = Codec> (value: TypeDef, Fallback?
|
||||
return (
|
||||
ext.type === 'u8'
|
||||
? U8aFixed.with((ext.length * 8) as U8aFixedBitLength)
|
||||
: VectorFixed.with(createClass<Codec>(ext.type), ext.length)
|
||||
: VecFixed.with(createClass<Codec>(ext.type), ext.length)
|
||||
) as unknown as Constructor<T>;
|
||||
|
||||
case TypeDefInfo.Linkage:
|
||||
@@ -340,7 +338,7 @@ function initType<T extends Codec = Codec, K extends Text | string = Text | stri
|
||||
assert(
|
||||
inHex === crHex || // check that the hex matches, if matching, all-ok
|
||||
(
|
||||
(value instanceof StorageData) && // input is from storage
|
||||
(value instanceof ClassOf('StorageData')) && // input is from storage
|
||||
(created instanceof Uint8Array) && // we are a variable-lneght structure
|
||||
(value.toU8a(true).toString() === created.toU8a().toString()) // strip the input length
|
||||
),
|
||||
|
||||
@@ -16,8 +16,7 @@ export { default as Set } from './Set';
|
||||
export { default as Struct } from './Struct';
|
||||
export { default as StructAny } from './StructAny';
|
||||
export { default as Tuple } from './Tuple';
|
||||
export { default as Vector } from './Vector';
|
||||
export { default as VectorAny } from './VectorAny';
|
||||
export { default as Vec, default as Vector } from './Vec';
|
||||
|
||||
// Convenience base classes, used as "anything of this type" bases
|
||||
export { default as U8a } from './U8a';
|
||||
|
||||
@@ -10,4 +10,3 @@
|
||||
*/
|
||||
export { default as Metadata } from './Metadata';
|
||||
export * from './primitive';
|
||||
export * from './rpc';
|
||||
|
||||
@@ -1,215 +1,190 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Option, Vector } from './codec';
|
||||
import { AccountId, AccountIndex, Address, Bool, Bytes, Data, Event, EventIndex, EventRecord, EventRecord0to76, Extrinsic, ExtrinsicEra, Fixed64, H160, H256, H512, I128, I16, I256, I32, I64, I8, ImmortalEra, KeyValue, Method, Moment, MomentOf, MortalEra, Null, Origin, Phantom, SignaturePayload, StorageData, StorageHasher, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, USize, Vote, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive';
|
||||
import { Compact, Option, Vec } from './codec';
|
||||
import { AccountId, AccountIndex, Address, Block, Bool, Bytes, ConsensusEngineId, Data, Digest, DigestItem, Event, Extrinsic, ExtrinsicEra, Fixed64, H160, H256, H512, Header, I128, I16, I256, I32, I64, I8, ImmortalEra, Method, Moment, MortalEra, Null, Origin, SignaturePayload, StorageHasher, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, Vote, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive';
|
||||
|
||||
export interface InterfaceRegistry {
|
||||
AccountId: AccountId;
|
||||
'Option<AccountId>': Option<AccountId>;
|
||||
'Vec<AccountId>': Vector<AccountId>;
|
||||
'Vec<AccountId>': Vec<AccountId>;
|
||||
AccountIndex: AccountIndex;
|
||||
'Compact<AccountIndex>': Compact<AccountIndex>;
|
||||
'Option<AccountIndex>': Option<AccountIndex>;
|
||||
'Vec<AccountIndex>': Vector<AccountIndex>;
|
||||
'Vec<AccountIndex>': Vec<AccountIndex>;
|
||||
Address: Address;
|
||||
'Option<Address>': Option<Address>;
|
||||
'Vec<Address>': Vector<Address>;
|
||||
'Vec<Address>': Vec<Address>;
|
||||
Event: Event;
|
||||
'Option<Event>': Option<Event>;
|
||||
'Vec<Event>': Vector<Event>;
|
||||
EventIndex: EventIndex;
|
||||
'Compact<EventIndex>': Compact<EventIndex>;
|
||||
'Option<EventIndex>': Option<EventIndex>;
|
||||
'Vec<EventIndex>': Vector<EventIndex>;
|
||||
EventRecord: EventRecord;
|
||||
'Option<EventRecord>': Option<EventRecord>;
|
||||
'Vec<EventRecord>': Vector<EventRecord>;
|
||||
EventRecord0to76: EventRecord0to76;
|
||||
'Option<EventRecord0to76>': Option<EventRecord0to76>;
|
||||
'Vec<EventRecord0to76>': Vector<EventRecord0to76>;
|
||||
'Vec<Event>': Vec<Event>;
|
||||
Block: Block;
|
||||
'Option<Block>': Option<Block>;
|
||||
'Vec<Block>': Vec<Block>;
|
||||
Bool: Bool;
|
||||
'Option<Bool>': Option<Bool>;
|
||||
'Vec<Bool>': Vector<Bool>;
|
||||
'Vec<Bool>': Vec<Bool>;
|
||||
bool: bool;
|
||||
'Option<bool>': Option<bool>;
|
||||
'Vec<bool>': Vector<bool>;
|
||||
'Vec<bool>': Vec<bool>;
|
||||
Bytes: Bytes;
|
||||
'Option<Bytes>': Option<Bytes>;
|
||||
'Vec<Bytes>': Vector<Bytes>;
|
||||
'Vec<Bytes>': Vec<Bytes>;
|
||||
ConsensusEngineId: ConsensusEngineId;
|
||||
'Compact<ConsensusEngineId>': Compact<ConsensusEngineId>;
|
||||
'Option<ConsensusEngineId>': Option<ConsensusEngineId>;
|
||||
'Vec<ConsensusEngineId>': Vec<ConsensusEngineId>;
|
||||
Data: Data;
|
||||
'Option<Data>': Option<Data>;
|
||||
'Vec<Data>': Vector<Data>;
|
||||
'Vec<Data>': Vec<Data>;
|
||||
Digest: Digest;
|
||||
'Option<Digest>': Option<Digest>;
|
||||
'Vec<Digest>': Vec<Digest>;
|
||||
DigestItem: DigestItem;
|
||||
'Option<DigestItem>': Option<DigestItem>;
|
||||
'Vec<DigestItem>': Vec<DigestItem>;
|
||||
H160: H160;
|
||||
'Option<H160>': Option<H160>;
|
||||
'Vec<H160>': Vector<H160>;
|
||||
'Vec<H160>': Vec<H160>;
|
||||
H256: H256;
|
||||
'Option<H256>': Option<H256>;
|
||||
'Vec<H256>': Vector<H256>;
|
||||
'Vec<H256>': Vec<H256>;
|
||||
H512: H512;
|
||||
'Option<H512>': Option<H512>;
|
||||
'Vec<H512>': Vector<H512>;
|
||||
I8: I8;
|
||||
'Compact<I8>': Compact<I8>;
|
||||
'Option<I8>': Option<I8>;
|
||||
'Vec<I8>': Vector<I8>;
|
||||
'Vec<H512>': Vec<H512>;
|
||||
Header: Header;
|
||||
'Option<Header>': Option<Header>;
|
||||
'Vec<Header>': Vec<Header>;
|
||||
i8: i8;
|
||||
'Compact<i8>': Compact<i8>;
|
||||
'Option<i8>': Option<i8>;
|
||||
'Vec<i8>': Vector<i8>;
|
||||
I16: I16;
|
||||
'Compact<I16>': Compact<I16>;
|
||||
'Option<I16>': Option<I16>;
|
||||
'Vec<I16>': Vector<I16>;
|
||||
'Vec<i8>': Vec<i8>;
|
||||
I8: I8;
|
||||
'Option<I8>': Option<I8>;
|
||||
'Vec<I8>': Vec<I8>;
|
||||
i16: i16;
|
||||
'Compact<i16>': Compact<i16>;
|
||||
'Option<i16>': Option<i16>;
|
||||
'Vec<i16>': Vector<i16>;
|
||||
I32: I32;
|
||||
'Compact<I32>': Compact<I32>;
|
||||
'Option<I32>': Option<I32>;
|
||||
'Vec<I32>': Vector<I32>;
|
||||
'Vec<i16>': Vec<i16>;
|
||||
I16: I16;
|
||||
'Option<I16>': Option<I16>;
|
||||
'Vec<I16>': Vec<I16>;
|
||||
i32: i32;
|
||||
'Compact<i32>': Compact<i32>;
|
||||
'Option<i32>': Option<i32>;
|
||||
'Vec<i32>': Vector<i32>;
|
||||
I64: I64;
|
||||
'Compact<I64>': Compact<I64>;
|
||||
'Option<I64>': Option<I64>;
|
||||
'Vec<I64>': Vector<I64>;
|
||||
'Vec<i32>': Vec<i32>;
|
||||
I32: I32;
|
||||
'Option<I32>': Option<I32>;
|
||||
'Vec<I32>': Vec<I32>;
|
||||
i64: i64;
|
||||
'Compact<i64>': Compact<i64>;
|
||||
'Option<i64>': Option<i64>;
|
||||
'Vec<i64>': Vector<i64>;
|
||||
'Vec<i64>': Vec<i64>;
|
||||
I64: I64;
|
||||
'Option<I64>': Option<I64>;
|
||||
'Vec<I64>': Vec<I64>;
|
||||
Fixed64: Fixed64;
|
||||
'Compact<Fixed64>': Compact<Fixed64>;
|
||||
'Option<Fixed64>': Option<Fixed64>;
|
||||
'Vec<Fixed64>': Vector<Fixed64>;
|
||||
I128: I128;
|
||||
'Compact<I128>': Compact<I128>;
|
||||
'Option<I128>': Option<I128>;
|
||||
'Vec<I128>': Vector<I128>;
|
||||
'Vec<Fixed64>': Vec<Fixed64>;
|
||||
i128: i128;
|
||||
'Compact<i128>': Compact<i128>;
|
||||
'Option<i128>': Option<i128>;
|
||||
'Vec<i128>': Vector<i128>;
|
||||
I256: I256;
|
||||
'Compact<I256>': Compact<I256>;
|
||||
'Option<I256>': Option<I256>;
|
||||
'Vec<I256>': Vector<I256>;
|
||||
'Vec<i128>': Vec<i128>;
|
||||
I128: I128;
|
||||
'Option<I128>': Option<I128>;
|
||||
'Vec<I128>': Vec<I128>;
|
||||
i256: i256;
|
||||
'Compact<i256>': Compact<i256>;
|
||||
'Option<i256>': Option<i256>;
|
||||
'Vec<i256>': Vector<i256>;
|
||||
KeyValue: KeyValue;
|
||||
'Option<KeyValue>': Option<KeyValue>;
|
||||
'Vec<KeyValue>': Vector<KeyValue>;
|
||||
'Vec<i256>': Vec<i256>;
|
||||
I256: I256;
|
||||
'Option<I256>': Option<I256>;
|
||||
'Vec<I256>': Vec<I256>;
|
||||
Method: Method;
|
||||
'Option<Method>': Option<Method>;
|
||||
'Vec<Method>': Vector<Method>;
|
||||
'Vec<Method>': Vec<Method>;
|
||||
Moment: Moment;
|
||||
'Option<Moment>': Option<Moment>;
|
||||
'Vec<Moment>': Vector<Moment>;
|
||||
MomentOf: MomentOf;
|
||||
'Compact<MomentOf>': Compact<MomentOf>;
|
||||
'Option<MomentOf>': Option<MomentOf>;
|
||||
'Vec<MomentOf>': Vector<MomentOf>;
|
||||
'Vec<Moment>': Vec<Moment>;
|
||||
Null: Null;
|
||||
'Option<Null>': Option<Null>;
|
||||
'Vec<Null>': Vector<Null>;
|
||||
Phantom: Phantom;
|
||||
'Option<Phantom>': Option<Phantom>;
|
||||
'Vec<Phantom>': Vector<Phantom>;
|
||||
'Vec<Null>': Vec<Null>;
|
||||
Origin: Origin;
|
||||
'Option<Origin>': Option<Origin>;
|
||||
'Vec<Origin>': Vector<Origin>;
|
||||
StorageData: StorageData;
|
||||
'Option<StorageData>': Option<StorageData>;
|
||||
'Vec<StorageData>': Vector<StorageData>;
|
||||
'Vec<Origin>': Vec<Origin>;
|
||||
StorageHasher: StorageHasher;
|
||||
'Option<StorageHasher>': Option<StorageHasher>;
|
||||
'Vec<StorageHasher>': Vector<StorageHasher>;
|
||||
'Vec<StorageHasher>': Vec<StorageHasher>;
|
||||
StorageKey: StorageKey;
|
||||
'Option<StorageKey>': Option<StorageKey>;
|
||||
'Vec<StorageKey>': Vector<StorageKey>;
|
||||
'Vec<StorageKey>': Vec<StorageKey>;
|
||||
Text: Text;
|
||||
'Option<Text>': Option<Text>;
|
||||
'Vec<Text>': Vector<Text>;
|
||||
'Vec<Text>': Vec<Text>;
|
||||
Type: Type;
|
||||
'Option<Type>': Option<Type>;
|
||||
'Vec<Type>': Vector<Type>;
|
||||
U8: U8;
|
||||
'Compact<U8>': Compact<U8>;
|
||||
'Option<U8>': Option<U8>;
|
||||
'Vec<U8>': Vector<U8>;
|
||||
'Vec<Type>': Vec<Type>;
|
||||
u8: u8;
|
||||
'Compact<u8>': Compact<u8>;
|
||||
'Option<u8>': Option<u8>;
|
||||
'Vec<u8>': Vector<u8>;
|
||||
U16: U16;
|
||||
'Compact<U16>': Compact<U16>;
|
||||
'Option<U16>': Option<U16>;
|
||||
'Vec<U16>': Vector<U16>;
|
||||
'Vec<u8>': Vec<u8>;
|
||||
U8: U8;
|
||||
'Compact<U8>': Compact<U8>;
|
||||
'Option<U8>': Option<U8>;
|
||||
'Vec<U8>': Vec<U8>;
|
||||
u16: u16;
|
||||
'Compact<u16>': Compact<u16>;
|
||||
'Option<u16>': Option<u16>;
|
||||
'Vec<u16>': Vector<u16>;
|
||||
U32: U32;
|
||||
'Compact<U32>': Compact<U32>;
|
||||
'Option<U32>': Option<U32>;
|
||||
'Vec<U32>': Vector<U32>;
|
||||
'Vec<u16>': Vec<u16>;
|
||||
U16: U16;
|
||||
'Compact<U16>': Compact<U16>;
|
||||
'Option<U16>': Option<U16>;
|
||||
'Vec<U16>': Vec<U16>;
|
||||
u32: u32;
|
||||
'Compact<u32>': Compact<u32>;
|
||||
'Option<u32>': Option<u32>;
|
||||
'Vec<u32>': Vector<u32>;
|
||||
U64: U64;
|
||||
'Compact<U64>': Compact<U64>;
|
||||
'Option<U64>': Option<U64>;
|
||||
'Vec<U64>': Vector<U64>;
|
||||
'Vec<u32>': Vec<u32>;
|
||||
U32: U32;
|
||||
'Compact<U32>': Compact<U32>;
|
||||
'Option<U32>': Option<U32>;
|
||||
'Vec<U32>': Vec<U32>;
|
||||
u64: u64;
|
||||
'Compact<u64>': Compact<u64>;
|
||||
'Option<u64>': Option<u64>;
|
||||
'Vec<u64>': Vector<u64>;
|
||||
U128: U128;
|
||||
'Compact<U128>': Compact<U128>;
|
||||
'Option<U128>': Option<U128>;
|
||||
'Vec<U128>': Vector<U128>;
|
||||
'Vec<u64>': Vec<u64>;
|
||||
U64: U64;
|
||||
'Compact<U64>': Compact<U64>;
|
||||
'Option<U64>': Option<U64>;
|
||||
'Vec<U64>': Vec<U64>;
|
||||
u128: u128;
|
||||
'Compact<u128>': Compact<u128>;
|
||||
'Option<u128>': Option<u128>;
|
||||
'Vec<u128>': Vector<u128>;
|
||||
U256: U256;
|
||||
'Compact<U256>': Compact<U256>;
|
||||
'Option<U256>': Option<U256>;
|
||||
'Vec<U256>': Vector<U256>;
|
||||
'Vec<u128>': Vec<u128>;
|
||||
U128: U128;
|
||||
'Compact<U128>': Compact<U128>;
|
||||
'Option<U128>': Option<U128>;
|
||||
'Vec<U128>': Vec<U128>;
|
||||
u256: u256;
|
||||
'Compact<u256>': Compact<u256>;
|
||||
'Option<u256>': Option<u256>;
|
||||
'Vec<u256>': Vector<u256>;
|
||||
USize: USize;
|
||||
'Compact<USize>': Compact<USize>;
|
||||
'Option<USize>': Option<USize>;
|
||||
'Vec<USize>': Vector<USize>;
|
||||
'Vec<u256>': Vec<u256>;
|
||||
U256: U256;
|
||||
'Compact<U256>': Compact<U256>;
|
||||
'Option<U256>': Option<U256>;
|
||||
'Vec<U256>': Vec<U256>;
|
||||
usize: usize;
|
||||
'Compact<usize>': Compact<usize>;
|
||||
'Option<usize>': Option<usize>;
|
||||
'Vec<usize>': Vector<usize>;
|
||||
'Vec<usize>': Vec<usize>;
|
||||
Vote: Vote;
|
||||
'Option<Vote>': Option<Vote>;
|
||||
'Vec<Vote>': Vector<Vote>;
|
||||
'Vec<Vote>': Vec<Vote>;
|
||||
Extrinsic: Extrinsic;
|
||||
'Option<Extrinsic>': Option<Extrinsic>;
|
||||
'Vec<Extrinsic>': Vector<Extrinsic>;
|
||||
'Vec<Extrinsic>': Vec<Extrinsic>;
|
||||
ExtrinsicEra: ExtrinsicEra;
|
||||
'Option<ExtrinsicEra>': Option<ExtrinsicEra>;
|
||||
'Vec<ExtrinsicEra>': Vector<ExtrinsicEra>;
|
||||
'Vec<ExtrinsicEra>': Vec<ExtrinsicEra>;
|
||||
MortalEra: MortalEra;
|
||||
'Option<MortalEra>': Option<MortalEra>;
|
||||
'Vec<MortalEra>': Vector<MortalEra>;
|
||||
'Vec<MortalEra>': Vec<MortalEra>;
|
||||
ImmortalEra: ImmortalEra;
|
||||
'Option<ImmortalEra>': Option<ImmortalEra>;
|
||||
'Vec<ImmortalEra>': Vector<ImmortalEra>;
|
||||
'Vec<ImmortalEra>': Vec<ImmortalEra>;
|
||||
SignaturePayload: SignaturePayload;
|
||||
'Option<SignaturePayload>': Option<SignaturePayload>;
|
||||
'Vec<SignaturePayload>': Vector<SignaturePayload>;
|
||||
'Vec<SignaturePayload>': Vec<SignaturePayload>;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,18 @@
|
||||
|
||||
import { setAddressPrefix } from '@polkadot/util-crypto';
|
||||
|
||||
import createType from '../codec/createType';
|
||||
import U8a from '../codec/U8a';
|
||||
import Vector from '../codec/Vector';
|
||||
import Vec from '../codec/Vec';
|
||||
import jsonVec from '../json/AccountIdVec.001.json';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import AccountId from './AccountId';
|
||||
import StorageData from './StorageData';
|
||||
|
||||
describe('AccountId', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
describe('defaults', (): void => {
|
||||
const id = new AccountId();
|
||||
|
||||
@@ -85,8 +90,8 @@ describe('AccountId', (): void => {
|
||||
it('has the correct entries', (): void => {
|
||||
setAddressPrefix(68);
|
||||
|
||||
const data = new StorageData(jsonVec.params.result.changes[0][1]);
|
||||
const list = new Vector(AccountId, data).map((accountId): string => accountId.toString());
|
||||
const data = createType('StorageData', jsonVec.params.result.changes[0][1]);
|
||||
const list = new Vec(AccountId, data).map((accountId): string => accountId.toString());
|
||||
|
||||
expect(list).toEqual([
|
||||
'7qVJujLF3EDbZt5WfQXWvueFedMS4Vfk2Hb4GyR8jwksTLup',
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
|
||||
import block00300 from '../json/SignedBlock.003.00.json';
|
||||
import Method from '../primitive/Method';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import Method from './Method';
|
||||
import Block from './Block';
|
||||
|
||||
describe('Block', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
Method.injectMethods(extrinsics);
|
||||
});
|
||||
|
||||
@@ -8,9 +8,9 @@ import { AnyU8a } from '../types';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import createType, { ClassOf } from '../codec/createType';
|
||||
import Extrinsic from '../primitive/Extrinsic/Extrinsic';
|
||||
import Extrinsic from './Extrinsic/Extrinsic';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import Vec from '../codec/Vec';
|
||||
import Header, { HeaderValue } from './Header';
|
||||
|
||||
export interface BlockValue {
|
||||
@@ -27,7 +27,7 @@ export default class Block extends Struct {
|
||||
public constructor (value?: BlockValue | Uint8Array) {
|
||||
super({
|
||||
header: Header,
|
||||
extrinsics: ClassOf<Vector<Extrinsic>>('Vec<Extrinsic>')
|
||||
extrinsics: ClassOf('Vec<Extrinsic>')
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ export default class Block extends Struct {
|
||||
/**
|
||||
* @description The [[Extrinsic]] contained in the block
|
||||
*/
|
||||
public get extrinsics (): Vector<Extrinsic> {
|
||||
return this.get('extrinsics') as Vector<Extrinsic>;
|
||||
public get extrinsics (): Vec<Extrinsic> {
|
||||
return this.get('extrinsics') as Vec<Extrinsic>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2,10 +2,15 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import createType from '../codec/createType';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import Bytes from './Bytes';
|
||||
import StorageData from './StorageData';
|
||||
|
||||
describe('Bytes', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
const CODE = new Uint8Array([0x14, 0x3a, 0x63, 0x6f, 0x64, 0x65]);
|
||||
|
||||
describe('construction', (): void => {
|
||||
@@ -30,7 +35,7 @@ describe('Bytes', (): void => {
|
||||
it('creates via storagedata (no prefix)', (): void => {
|
||||
expect(
|
||||
new Bytes(
|
||||
new StorageData('0x3a636f6465')
|
||||
createType('StorageData', '0x3a636f6465')
|
||||
).toU8a()
|
||||
).toEqual(CODE);
|
||||
});
|
||||
@@ -38,7 +43,7 @@ describe('Bytes', (): void => {
|
||||
it('creates via storagedata (with length prefix)', (): void => {
|
||||
expect(
|
||||
new Bytes(
|
||||
new StorageData('0x143a636f6465')
|
||||
createType('StorageData', '0x143a636f6465')
|
||||
).toU8a()
|
||||
).toEqual(CODE);
|
||||
});
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyU8a } from '../types';
|
||||
|
||||
import { assert, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AnyU8a } from '../types';
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Compact from '../codec/Compact';
|
||||
import U8a from '../codec/U8a';
|
||||
|
||||
@@ -13,7 +15,7 @@ import U8a from '../codec/U8a';
|
||||
* @description
|
||||
* A Bytes wrapper for Vec<u8>. The significant difference between this and a normal Uint8Array
|
||||
* is that this version allows for length-encoding. (i.e. it is a variable-item codec, the same
|
||||
* as what is found in [[Text]] and [[Vector]])
|
||||
* as what is found in [[Text]] and [[Vec]])
|
||||
*/
|
||||
export default class Bytes extends U8a {
|
||||
public constructor (value?: AnyU8a) {
|
||||
@@ -21,18 +23,13 @@ export default class Bytes extends U8a {
|
||||
}
|
||||
|
||||
private static decodeBytes (value?: AnyU8a): Uint8Array | undefined {
|
||||
// FIXME Cyclic dependency, however needed for the StoreageData check below. In a perfect
|
||||
// world, we should probably be checking Bytes - however as a first step, check against
|
||||
// StorageData to cater for the _specific_ problematic case
|
||||
const StorageData = require('./StorageData').default;
|
||||
|
||||
if (Array.isArray(value) || isString(value)) {
|
||||
const u8a = u8aToU8a(value);
|
||||
|
||||
return Bytes.decodeBytes(
|
||||
Compact.addLengthPrefix(u8a)
|
||||
);
|
||||
} else if (value instanceof StorageData) {
|
||||
} else if (value instanceof ClassOf('StorageData')) {
|
||||
// Here we cater for the actual StorageData that _could_ have a length prefix. In the
|
||||
// case of `:code` it is not added, for others it is
|
||||
const u8a = value as Uint8Array;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// 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 BN from 'bn.js';
|
||||
import { assert, bnToBn } from '@polkadot/util';
|
||||
|
||||
import Bytes from './Bytes';
|
||||
import U32 from './U32';
|
||||
import U64 from './U64';
|
||||
|
||||
const CID_AURA = 0x61727561; // 'aura'
|
||||
const CID_BABE = 0x65626162; // 'babe'
|
||||
const CID_GRPA = 0x4b4e5246; // 'FRNK' (don't ask, used to be afg1)
|
||||
|
||||
export { CID_AURA, CID_BABE, CID_GRPA };
|
||||
|
||||
/**
|
||||
* @name ConsensusEngineId
|
||||
* @description
|
||||
* A 4-byte identifier (actually a [u8; 4]) identifying the engine, e.g. for Aura it would be [b'a', b'u', b'r', b'a']
|
||||
*/
|
||||
export default class ConsensusEngineId extends U32 {
|
||||
public static idToString (input: number | BN): string {
|
||||
return bnToBn(input)
|
||||
.toArray('le')
|
||||
.map((code): string => String.fromCharCode(code))
|
||||
.join('');
|
||||
}
|
||||
|
||||
public static stringToId (input: string): number {
|
||||
return input
|
||||
.split('')
|
||||
.reverse()
|
||||
.reduce((result, char): number => (result * 256) + char.charCodeAt(0), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if the engine matches aura
|
||||
*/
|
||||
public get isAura (): boolean {
|
||||
return this.eq(CID_AURA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` is the engine matches babe
|
||||
*/
|
||||
public get isBabe (): boolean {
|
||||
return this.eq(CID_BABE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` is the engine matches grandpa
|
||||
*/
|
||||
public get isGrandpa (): boolean {
|
||||
return this.eq(CID_GRPA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description From the input bytes, decode into an aura-tuple
|
||||
*/
|
||||
public extractSlot (bytes: Bytes): U64 {
|
||||
assert(this.isAura, 'Invalid engine for asAura conversion');
|
||||
|
||||
return new U64(
|
||||
// no compact prefix, only use the correct number of supplied bytes
|
||||
bytes.toU8a(true).subarray(0, 8)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Override the default toString to return a 4-byte string
|
||||
*/
|
||||
public toString (): string {
|
||||
return ConsensusEngineId.idToString(this as BN);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
import { injectDefinitions } from '../srml';
|
||||
import json3 from '../json/Header.003.json';
|
||||
import block1 from '../json/SignedBlock.003.00.json';
|
||||
import Digest, { ConsensusEngineId, CID_AURA, CID_BABE, CID_GRPA } from './Digest';
|
||||
import ConsensusEngineId, { CID_AURA, CID_BABE, CID_GRPA } from './ConsensusEngineId';
|
||||
import Digest from './Digest';
|
||||
|
||||
describe('Digest', (): void => {
|
||||
beforeEach((): void => {
|
||||
@@ -0,0 +1,194 @@
|
||||
// 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 { AuthorityId } from '../srml/consensus/types';
|
||||
import { Hash } from '../srml/runtime/types';
|
||||
import { Consensus, PreRuntime, Seal, SealV0 } from '../srml/rpc/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Enum from '../codec/Enum';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vec from '../codec/Vec';
|
||||
import Bytes from './Bytes';
|
||||
|
||||
/**
|
||||
* @name DigestItem
|
||||
* @description
|
||||
* A [[Enum]] the specifies the specific item in the logs of a [[Digest]]
|
||||
*/
|
||||
export class DigestItem extends Enum {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
Other: ClassOf('Bytes'), // 0
|
||||
AuthoritiesChange: ClassOf('Vec<AuthorityId>'), // 1
|
||||
ChangesTrieRoot: ClassOf('Hash'), // 2
|
||||
SealV0: ClassOf('SealV0'), // 3
|
||||
Consensus: ClassOf('Consensus'), // 4
|
||||
Seal: ClassOf('Seal'), // 5
|
||||
PreRuntime: ClassOf('PreRuntime') // 6
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Vec<AuthorityId>]]
|
||||
*/
|
||||
public get asAuthoritiesChange (): Vec<AuthorityId> {
|
||||
assert(this.isAuthoritiesChange, `Cannot convert '${this.type}' via asAuthoritiesChange`);
|
||||
|
||||
return this.value as Vec<AuthorityId>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[ChangesTrieRoot]]
|
||||
*/
|
||||
public get asChangesTrieRoot (): Hash {
|
||||
assert(this.isChangesTrieRoot, `Cannot convert '${this.type}' via asChangesTrieRoot`);
|
||||
|
||||
return this.value as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desciption Retuns the item as a [[Consensus]]
|
||||
*/
|
||||
public get asConsensus (): Consensus {
|
||||
assert(this.isConsensus, `Cannot convert '${this.type}' via asConsensus`);
|
||||
|
||||
return this.value as Consensus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Bytes]]
|
||||
*/
|
||||
public get asOther (): Bytes {
|
||||
assert(this.isOther, `Cannot convert '${this.type}' via asOther`);
|
||||
|
||||
return this.value as Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[PreRuntime]]
|
||||
*/
|
||||
public get asPreRuntime (): PreRuntime {
|
||||
assert(this.isPreRuntime, `Cannot convert '${this.type}' via asPreRuntime`);
|
||||
|
||||
return this.value as PreRuntime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Seal]]
|
||||
*/
|
||||
public get asSeal (): Seal {
|
||||
assert(this.isSeal, `Cannot convert '${this.type}' via asSeal`);
|
||||
|
||||
return this.value as Seal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[SealV0]]
|
||||
*/
|
||||
public get asSealV0 (): SealV0 {
|
||||
assert(this.isSealV0, `Cannot convert '${this.type}' via asSealV0`);
|
||||
|
||||
return this.value as SealV0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[AuthoritiesChange]]
|
||||
*/
|
||||
public get isAuthoritiesChange (): boolean {
|
||||
return this.type === 'AuthoritiesChange';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[ChangesTrieRoot]]
|
||||
*/
|
||||
public get isChangesTrieRoot (): boolean {
|
||||
return this.type === 'ChangesTrieRoot';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Consensus]]
|
||||
*/
|
||||
public get isConsensus (): boolean {
|
||||
return this.type === 'Consensus';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Other]]
|
||||
*/
|
||||
public get isOther (): boolean {
|
||||
return this.type === 'Other';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[PreRuntime]]
|
||||
*/
|
||||
public get isPreRuntime (): boolean {
|
||||
return this.type === 'PreRuntime';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Seal]]
|
||||
*/
|
||||
public get isSeal (): boolean {
|
||||
return this.type === 'Seal';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[SealV0]]
|
||||
*/
|
||||
public get isSealV0 (): boolean {
|
||||
return this.type === 'SealV0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers. For logs, we overrides to produce the hex version (sligning with substrate gives in actual JSON responses)
|
||||
*/
|
||||
public toJSON (): string {
|
||||
return this.toHex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the type of engine
|
||||
*/
|
||||
public get type (): string {
|
||||
return super.type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Digest
|
||||
* @description
|
||||
* A [[Header]] Digest
|
||||
*/
|
||||
export default class Digest extends Struct {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
logs: Vec.with(DigestItem)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs
|
||||
*/
|
||||
public get logs (): Vec<DigestItem> {
|
||||
return this.get('logs') as Vec<DigestItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs, filtered, filter items included. This is useful for derive functionality where only a certain type of log is to be returned.
|
||||
*/
|
||||
public logsWith (...include: string[]): Vec<DigestItem> {
|
||||
return this.logs.filter(({ type }): boolean => include.includes(type)) as Vec<DigestItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs, filtered, filter items exluded. This is useful for stripping headers for eg. WASM runtime execution.
|
||||
*/
|
||||
public logsWithout (...exclude: string[]): Vec<DigestItem> {
|
||||
return this.logs.filter(({ type }): boolean => !exclude.includes(type)) as Vec<DigestItem>;
|
||||
}
|
||||
}
|
||||
@@ -2,30 +2,21 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventId } from '../srml/system/types';
|
||||
import { Constructor, Codec } from '../types';
|
||||
|
||||
import { assert, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { ClassOf, TypeDef, getTypeClass, getTypeDef } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Tuple from '../codec/Tuple';
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
import { TypeDef, getTypeClass, getTypeDef } from '../codec/createType';
|
||||
import Metadata from '../Metadata';
|
||||
import { EventMetadata as EventMetadataV7 } from '../Metadata/v7/Events';
|
||||
import Null from './Null';
|
||||
import U32 from './U32';
|
||||
import Unconstructable from './Unconstructable';
|
||||
|
||||
const EventTypes: Record<string, Constructor<EventData>> = {};
|
||||
|
||||
/**
|
||||
* @name EventIndex
|
||||
* @description
|
||||
* The Substrate EventIndex representation as a [[U32]].
|
||||
*/
|
||||
export class EventIndex extends U32 {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EventData
|
||||
* @description
|
||||
@@ -78,18 +69,6 @@ export class EventData extends Tuple {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EventId
|
||||
* @description
|
||||
* This follows the same approach as in [[Method]], we have the `[sectionIndex, methodIndex]` pairing
|
||||
* that indicates the actual event fired
|
||||
*/
|
||||
export class EventId extends U8aFixed {
|
||||
public constructor (value?: any) {
|
||||
super(value, 16);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Event
|
||||
* @description
|
||||
@@ -103,7 +82,7 @@ export default class Event extends Struct {
|
||||
const { DataType, value } = Event.decodeEvent(_value);
|
||||
|
||||
super({
|
||||
index: EventId,
|
||||
index: ClassOf('EventId'),
|
||||
data: DataType
|
||||
}, value);
|
||||
}
|
||||
|
||||
@@ -3,114 +3,12 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Hash } from '../srml/runtime/types';
|
||||
import { Phase } from '../srml/system/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import createType, { ClassOf } from '../codec/createType';
|
||||
import Enum from '../codec/Enum';
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import Vec from '../codec/Vec';
|
||||
import Event from './Event';
|
||||
import Null from './Null';
|
||||
import U32 from './U32';
|
||||
|
||||
/**
|
||||
* @name ApplyExtrinsic
|
||||
* @description
|
||||
* The [[Phase]] where the extrinsic is applied
|
||||
*/
|
||||
export class ApplyExtrinsic extends U32 {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Finalization
|
||||
* @description
|
||||
* The [[Phase]] where the extrinsic is being Finalized
|
||||
*/
|
||||
export class Finalization extends Null {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Phase
|
||||
* @description
|
||||
* An [[Enum]] that indicates the specific phase where the [[EventRecord]] was generated
|
||||
*/
|
||||
export class Phase extends Enum {
|
||||
public constructor (value: any, index?: number) {
|
||||
super({
|
||||
ApplyExtrinsic,
|
||||
Finalization
|
||||
}, value, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[ApplyExtrinsic]]
|
||||
*/
|
||||
public get asApplyExtrinsic (): ApplyExtrinsic {
|
||||
assert(this.isApplyExtrinsic, `Cannot convert '${this.type}' via asApplyExtrinsic`);
|
||||
|
||||
return this.value as ApplyExtrinsic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Finalization]]
|
||||
*/
|
||||
public get asFinalization (): Finalization {
|
||||
assert(this.isFinalization, `Cannot convert '${this.type}' via asFinalization`);
|
||||
|
||||
return this.value as Finalization;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a ApplyExtrinsic
|
||||
*/
|
||||
public get isApplyExtrinsic (): boolean {
|
||||
return this.type === 'ApplyExtrinsic';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true when this is a ApplyExtrinsic
|
||||
*/
|
||||
public get isFinalization (): boolean {
|
||||
return this.type === 'Finalization';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EventRecord_0_76
|
||||
* @description
|
||||
* A record for an [[Event]] (as specified by [[Metadata]]) with the specific [[Phase]] of
|
||||
* application.
|
||||
*/
|
||||
export class EventRecord0to76 extends Struct {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
phase: Phase,
|
||||
event: Event
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Event]] this record refers to
|
||||
*/
|
||||
public get event (): Event {
|
||||
return this.get('event') as Event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Phase]] where the event was generated
|
||||
*/
|
||||
public get phase (): Phase {
|
||||
return this.get('phase') as Phase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Hash]] topics for this event (empty, compat)
|
||||
*/
|
||||
public get topics (): Vector<Hash> {
|
||||
return createType('Vec<Hash>', []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EventRecord
|
||||
@@ -121,13 +19,14 @@ export class EventRecord0to76 extends Struct {
|
||||
export default class EventRecord extends Struct {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
phase: Phase,
|
||||
phase: ClassOf('Phase'),
|
||||
event: Event,
|
||||
topics: ClassOf('Vec<Hash>')
|
||||
}, value);
|
||||
}
|
||||
|
||||
public static Fallback = EventRecord0to76;
|
||||
// TODO We want these injected by createType
|
||||
public static Fallback = ClassOf('EventRecord0to76');
|
||||
|
||||
/**
|
||||
* @description The [[Event]] this record refers to
|
||||
@@ -146,7 +45,7 @@ export default class EventRecord extends Struct {
|
||||
/**
|
||||
* @description The [[Hash]] topics for this event
|
||||
*/
|
||||
public get topics (): Vector<Hash> {
|
||||
return this.get('topics') as Vector<Hash>;
|
||||
public get topics (): Vec<Hash> {
|
||||
return this.get('topics') as Vec<Hash>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class Header extends Struct {
|
||||
number: ClassOf('Compact<BlockNumber>'),
|
||||
stateRoot: ClassOf('Hash'),
|
||||
extrinsicsRoot: ClassOf('Hash'),
|
||||
digest: Digest
|
||||
digest: ClassOf('Digest')
|
||||
}, value || {});
|
||||
}
|
||||
|
||||
@@ -1,51 +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 KeyValue, { KeyValueOption } from './KeyValue';
|
||||
|
||||
describe('KeyValue', (): void => {
|
||||
it('decodes KeyValue from u8a', (): void => {
|
||||
expect(
|
||||
new KeyValue(
|
||||
Uint8Array.from([
|
||||
4 << 2,
|
||||
0x11, 0x22, 0x33, 0x44,
|
||||
9 << 2,
|
||||
0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
|
||||
])
|
||||
).toJSON()
|
||||
).toEqual(['0x11223344', '0x998877665544332211']);
|
||||
});
|
||||
|
||||
it('encodes KeyValue from JSON', (): void => {
|
||||
expect(
|
||||
new KeyValue(['0x11223344', '0x998877665544332211']).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
4 << 2,
|
||||
0x11, 0x22, 0x33, 0x44,
|
||||
9 << 2,
|
||||
0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('exposes the properties for key/value', (): void => {
|
||||
const kv = new KeyValue(['0x11223344', '0x998877665544332211']);
|
||||
|
||||
expect(kv.key.toHex()).toEqual('0x11223344');
|
||||
expect(kv.value.toHex()).toEqual('0x998877665544332211');
|
||||
});
|
||||
});
|
||||
|
||||
describe('KeyValueOption', (): void => {
|
||||
it('exposes the properties for key/value', (): void => {
|
||||
const kv = new KeyValueOption([
|
||||
'0x11223344'
|
||||
]);
|
||||
|
||||
expect(kv.key.toHex()).toEqual('0x11223344');
|
||||
expect(kv.value.isNone).toEqual(true);
|
||||
});
|
||||
});
|
||||
@@ -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 { AnyU8a } from '../types';
|
||||
|
||||
import Option from '../codec/Option';
|
||||
import Tuple from '../codec/Tuple';
|
||||
import StorageData from './StorageData';
|
||||
import StorageKey from './StorageKey';
|
||||
|
||||
type KeyValueValue = [AnyU8a, AnyU8a];
|
||||
|
||||
/**
|
||||
* @name KeyValue
|
||||
* @description
|
||||
* KeyValue structure. Since most of the keys and resultant values in Subtrate are
|
||||
* hashed and/or encoded, this does not wrap [[Text]], but rather a [[Bytes]]
|
||||
* for the keys and values. (Not to be confused with the KeyValue in [[Metadata]], that
|
||||
* is actually for Maps, whereas this is a representation of actual storage values)
|
||||
*/
|
||||
export default class KeyValue extends Tuple {
|
||||
public constructor (value?: KeyValueValue | Uint8Array) {
|
||||
super({
|
||||
key: StorageKey,
|
||||
value: StorageData
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[StorageKey]]
|
||||
*/
|
||||
public get key (): StorageKey {
|
||||
return this[0] as StorageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[StorageData]]
|
||||
*/
|
||||
public get value (): StorageData {
|
||||
return this[1] as StorageData;
|
||||
}
|
||||
}
|
||||
|
||||
export type KeyValueOptionValue = [AnyU8a, AnyU8a?];
|
||||
|
||||
/**
|
||||
* @name KeyValueOption
|
||||
* @description
|
||||
* A key/value change. This is similar to the [[KeyValue]] structure,
|
||||
* however in this case the value could be optional. Here it extends
|
||||
* from a [[Tuple]], indicating the use inside areas such as [[StorageChangeSet]]
|
||||
*/
|
||||
export class KeyValueOption extends Tuple {
|
||||
public constructor (value?: KeyValueOptionValue | Uint8Array) {
|
||||
super({
|
||||
StorageKey,
|
||||
'Option<StorageData>': Option.with(StorageData)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[StorageKey]]
|
||||
*/
|
||||
public get key (): StorageKey {
|
||||
return this[0] as StorageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Option]] [[StorageData]]
|
||||
*/
|
||||
public get value (): Option<StorageData> {
|
||||
return this[1] as Option<StorageData>;
|
||||
}
|
||||
}
|
||||
@@ -131,11 +131,3 @@ export default class Moment extends Date implements Codec {
|
||||
return bnToU8a(this.toNumber(), BITLENGTH, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name MomentOf
|
||||
* @description
|
||||
* The Substrate MomentOf representation as a [[Moment]].
|
||||
*/
|
||||
export class MomentOf extends Moment {
|
||||
}
|
||||
|
||||
@@ -69,14 +69,3 @@ export default class Null implements Codec {
|
||||
return new Uint8Array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Phantom
|
||||
* @description
|
||||
* Implements a type that does not contain anything (apart from `null`)
|
||||
*/
|
||||
export class Phantom extends Null {
|
||||
public toRawType (): string {
|
||||
return 'Phantom';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +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 './Bytes';
|
||||
|
||||
/**
|
||||
* @name StorageData
|
||||
* @description
|
||||
* Data retrieved via Storage queries and data for key-value pairs
|
||||
*/
|
||||
export default class StorageData extends Bytes {
|
||||
}
|
||||
@@ -13,37 +13,38 @@
|
||||
export { default as AccountId } from './AccountId';
|
||||
export { default as AccountIndex } from './AccountIndex';
|
||||
export { default as Address } from './Address';
|
||||
export { default as Event, EventIndex } from './Event';
|
||||
export { default as EventRecord, EventRecord0to76 } from './EventRecord';
|
||||
export { default as Event } from './Event';
|
||||
export { default as Block } from './Block';
|
||||
export { default as Bool, default as bool } from './Bool';
|
||||
export { default as Bytes } from './Bytes';
|
||||
export { default as ConsensusEngineId } from './ConsensusEngineId';
|
||||
export { default as Data } from './Data';
|
||||
export { default as Digest, DigestItem } from './Digest';
|
||||
export * from './Extrinsic';
|
||||
export { default as H160 } from './H160';
|
||||
export { default as H256 } from './H256';
|
||||
export { default as H512 } from './H512';
|
||||
export { default as I8, default as i8 } from './I8';
|
||||
export { default as I16, default as i16 } from './I16';
|
||||
export { default as I32, default as i32 } from './I32';
|
||||
export { default as I64, default as i64 } from './I64';
|
||||
export { default as Header } from './Header';
|
||||
export { default as i8, default as I8 } from './I8';
|
||||
export { default as i16, default as I16 } from './I16';
|
||||
export { default as i32, default as I32 } from './I32';
|
||||
export { default as i64, default as I64 } from './I64';
|
||||
export { default as Fixed64 } from './I64Fixed';
|
||||
export { default as I128, default as i128 } from './I128';
|
||||
export { default as I256, default as i256 } from './I256';
|
||||
export { default as KeyValue } from './KeyValue';
|
||||
export { default as i128, default as I128 } from './I128';
|
||||
export { default as i256, default as I256 } from './I256';
|
||||
export { default as Method } from './Method';
|
||||
export { default as Moment, MomentOf } from './Moment';
|
||||
export { default as Null, Phantom } from './Null';
|
||||
export { default as Moment } from './Moment';
|
||||
export { default as Null } from './Null';
|
||||
export { default as Origin } from './Origin';
|
||||
export { default as StorageData } from './StorageData';
|
||||
export { default as StorageHasher } from './StorageHasher';
|
||||
export { default as StorageKey } from './StorageKey';
|
||||
export { default as Text } from './Text';
|
||||
export { default as Type } from './Type';
|
||||
export { default as U8, default as u8 } from './U8';
|
||||
export { default as U16, default as u16 } from './U16';
|
||||
export { default as U32, default as u32 } from './U32';
|
||||
export { default as U64, default as u64 } from './U64';
|
||||
export { default as U128, default as u128 } from './U128';
|
||||
export { default as U256, default as u256 } from './U256';
|
||||
export { default as USize, default as usize } from './USize';
|
||||
export { default as u8, default as U8 } from './U8';
|
||||
export { default as u16, default as U16 } from './U16';
|
||||
export { default as u32, default as U32 } from './U32';
|
||||
export { default as u64, default as U64 } from './U64';
|
||||
export { default as u128, default as U128 } from './U128';
|
||||
export { default as u256, default as U256 } from './U256';
|
||||
export { default as usize } from './USize';
|
||||
export { default as Vote } from './Vote';
|
||||
|
||||
@@ -1,31 +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 ChainProperties from './ChainProperties';
|
||||
|
||||
describe('ChainProperties', (): void => {
|
||||
it('decodes from a null value', (): void => {
|
||||
expect(
|
||||
[...new ChainProperties(null).entries()]
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('decodes from an actual object', (): void => {
|
||||
expect(
|
||||
[...new ChainProperties({
|
||||
decimals: 15,
|
||||
tokenSymbol: 'BBQ'
|
||||
}).entries()]
|
||||
).toEqual([['decimals', 15], ['tokenSymbol', 'BBQ']]);
|
||||
});
|
||||
|
||||
it('checks equality', (): void => {
|
||||
expect(
|
||||
new ChainProperties({
|
||||
decimals: 15,
|
||||
tokenSymbol: 'BBQ'
|
||||
}).eq([['tokenSymbol', 'BBQ'], ['decimals', 15]])
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,26 +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 StructAny from '../codec/StructAny';
|
||||
|
||||
/**
|
||||
* @name ChainProperties
|
||||
* @description
|
||||
* Wraps the properties retrieved from the chain via the `system.properties` RPC call.
|
||||
*/
|
||||
export default class ChainProperties extends StructAny {
|
||||
/**
|
||||
* @description The token decimals, if defined (de-facto standard only)
|
||||
*/
|
||||
public get tokenDecimals (): number | undefined {
|
||||
return this.get('tokenDecimals');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The token system, if defined (de-facto standard only)
|
||||
*/
|
||||
public get tokenSymbol (): string | undefined {
|
||||
return this.get('tokenSymbol');
|
||||
}
|
||||
}
|
||||
@@ -1,415 +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 { Hash, Signature } from '../srml/runtime/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { assert, bnToBn } from '@polkadot/util';
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
import Struct from '../codec/Struct';
|
||||
import Tuple from '../codec/Tuple';
|
||||
import Vector from '../codec/Vector';
|
||||
import Bytes from '../primitive/Bytes';
|
||||
import U32 from '../primitive/U32';
|
||||
import U64 from '../primitive/U64';
|
||||
|
||||
// Should import AuthorityId (however, move these to generated types)
|
||||
import AuthorityId from '../primitive/AccountId';
|
||||
import { ClassOf } from '../codec';
|
||||
|
||||
const CID_AURA = 0x61727561; // 'aura'
|
||||
const CID_BABE = 0x65626162; // 'babe'
|
||||
const CID_GRPA = 0x4b4e5246; // 'FRNK' (don't ask, used to be afg1)
|
||||
|
||||
export { CID_AURA, CID_BABE, CID_GRPA };
|
||||
|
||||
/**
|
||||
* @name AuthoritiesChange
|
||||
* @description
|
||||
* Log for Authories changed
|
||||
*/
|
||||
export class AuthoritiesChange extends Vector.with(AuthorityId) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name ConsensusEngineId
|
||||
* @description
|
||||
* A 4-byte identifier (actually a [u8; 4]) identifying the engine, e.g. for Aura it would be [b'a', b'u', b'r', b'a']
|
||||
*/
|
||||
export class ConsensusEngineId extends U32 {
|
||||
public static idToString (input: number | BN): string {
|
||||
return bnToBn(input)
|
||||
.toArray('le')
|
||||
.map((code): string => String.fromCharCode(code))
|
||||
.join('');
|
||||
}
|
||||
|
||||
public static stringToId (input: string): number {
|
||||
return input
|
||||
.split('')
|
||||
.reverse()
|
||||
.reduce((result, char): number => (result * 256) + char.charCodeAt(0), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if the engine matches aura
|
||||
*/
|
||||
public get isAura (): boolean {
|
||||
return this.eq(CID_AURA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` is the engine matches babe
|
||||
*/
|
||||
public get isBabe (): boolean {
|
||||
return this.eq(CID_BABE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` is the engine matches grandpa
|
||||
*/
|
||||
public get isGrandpa (): boolean {
|
||||
return this.eq(CID_GRPA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description From the input bytes, decode into an aura-tuple
|
||||
*/
|
||||
public extractSlot (bytes: Bytes): U64 {
|
||||
assert(this.isAura, 'Invalid engine for asAura conversion');
|
||||
|
||||
return new U64(
|
||||
// no compact prefix, only use the correct number of supplied bytes
|
||||
bytes.toU8a(true).subarray(0, 8)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Override the default toString to return a 4-byte string
|
||||
*/
|
||||
public toString (): string {
|
||||
return ConsensusEngineId.idToString(this as BN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Consensus
|
||||
* @description
|
||||
* Log item indicating consensus
|
||||
*/
|
||||
export class Consensus extends Tuple {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
ConsensusEngineId,
|
||||
Bytes
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped engine [[ConsensusEngineId]]
|
||||
*/
|
||||
public get engine (): ConsensusEngineId {
|
||||
return this[0] as ConsensusEngineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Bytes]]
|
||||
*/
|
||||
public get data (): Bytes {
|
||||
return this[1] as Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The slot extracted from the raw data (fails on non-Aura)
|
||||
*/
|
||||
public get slot (): U64 {
|
||||
return this.engine.extractSlot(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name SealV0
|
||||
* @description
|
||||
* Log item indicating a sealing event. This has been replaced in later versions with a renamed [[Seal]], we however have kept compatibility with the old version
|
||||
*/
|
||||
export class SealV0 extends Tuple {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
U64,
|
||||
Signature: ClassOf<Signature>('Signature')
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Signature]]
|
||||
*/
|
||||
public get signature (): Signature {
|
||||
return this[1] as Signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[U64]] slot
|
||||
*/
|
||||
public get slot (): U64 {
|
||||
return this[0] as U64;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Seal
|
||||
* @description
|
||||
* Log item indicating a sealing event.
|
||||
*/
|
||||
export class Seal extends Tuple {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
ConsensusEngineId,
|
||||
Bytes
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Bytes]]
|
||||
*/
|
||||
public get data (): Bytes {
|
||||
return this[1] as Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[U64]] slot
|
||||
*/
|
||||
public get slot (): U64 {
|
||||
return this[0] as U64;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Other
|
||||
* @description
|
||||
* Log item that is just a stream of [[Bytes]]
|
||||
*/
|
||||
export class Other extends Bytes {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name PreRuntime
|
||||
* @description
|
||||
* These are messages from the consensus engine to the runtime, although the consensus engine the consensus engine can (and should) read them itself to avoid ode and state duplication.
|
||||
*/
|
||||
export class PreRuntime extends Tuple {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
ConsensusEngineId,
|
||||
Bytes
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[ConsensusEngineId]]
|
||||
*/
|
||||
public get engine (): ConsensusEngineId {
|
||||
return this[0] as ConsensusEngineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Bytes]]
|
||||
*/
|
||||
public get data (): Bytes {
|
||||
return this[1] as Bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The slot extracted from the raw data (fails on non-Aura)
|
||||
*/
|
||||
public get slot (): U64 {
|
||||
return this.engine.extractSlot(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name DigestItem
|
||||
* @description
|
||||
* A [[Enum]] the specifies the specific item in the logs of a [[Digest]]
|
||||
*/
|
||||
export class DigestItem extends Enum {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
Other, // 0
|
||||
AuthoritiesChange, // 1
|
||||
ChangesTrieRoot: ClassOf<Hash>('Hash'), // 2
|
||||
SealV0, // 3
|
||||
Consensus, // 4
|
||||
Seal, // 5
|
||||
PreRuntime // 6
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[AuthoritiesChange]]
|
||||
*/
|
||||
public get asAuthoritiesChange (): AuthoritiesChange {
|
||||
assert(this.isAuthoritiesChange, `Cannot convert '${this.type}' via asAuthoritiesChange`);
|
||||
|
||||
return this.value as AuthoritiesChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[ChangesTrieRoot]]
|
||||
*/
|
||||
public get asChangesTrieRoot (): Hash {
|
||||
assert(this.isChangesTrieRoot, `Cannot convert '${this.type}' via asChangesTrieRoot`);
|
||||
|
||||
return this.value as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desciption Retuns the item as a [[Consensus]]
|
||||
*/
|
||||
public get asConsensus (): Consensus {
|
||||
assert(this.isConsensus, `Cannot convert '${this.type}' via asConsensus`);
|
||||
|
||||
return this.value as Consensus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Other]]
|
||||
*/
|
||||
public get asOther (): Other {
|
||||
assert(this.isOther, `Cannot convert '${this.type}' via asOther`);
|
||||
|
||||
return this.value as Other;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[PreRuntime]]
|
||||
*/
|
||||
public get asPreRuntime (): PreRuntime {
|
||||
assert(this.isPreRuntime, `Cannot convert '${this.type}' via asPreRuntime`);
|
||||
|
||||
return this.value as PreRuntime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Seal]]
|
||||
*/
|
||||
public get asSeal (): Seal {
|
||||
assert(this.isSeal, `Cannot convert '${this.type}' via asSeal`);
|
||||
|
||||
return this.value as Seal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[SealV0]]
|
||||
*/
|
||||
public get asSealV0 (): SealV0 {
|
||||
assert(this.isSealV0, `Cannot convert '${this.type}' via asSealV0`);
|
||||
|
||||
return this.value as SealV0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[AuthoritiesChange]]
|
||||
*/
|
||||
public get isAuthoritiesChange (): boolean {
|
||||
return this.type === 'AuthoritiesChange';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[ChangesTrieRoot]]
|
||||
*/
|
||||
public get isChangesTrieRoot (): boolean {
|
||||
return this.type === 'ChangesTrieRoot';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Consensus]]
|
||||
*/
|
||||
public get isConsensus (): boolean {
|
||||
return this.type === 'Consensus';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Other]]
|
||||
*/
|
||||
public get isOther (): boolean {
|
||||
return this.type === 'Other';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[PreRuntime]]
|
||||
*/
|
||||
public get isPreRuntime (): boolean {
|
||||
return this.type === 'PreRuntime';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[Seal]]
|
||||
*/
|
||||
public get isSeal (): boolean {
|
||||
return this.type === 'Seal';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true on [[SealV0]]
|
||||
*/
|
||||
public get isSealV0 (): boolean {
|
||||
return this.type === 'SealV0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers. For logs, we overrides to produce the hex version (sligning with substrate gives in actual JSON responses)
|
||||
*/
|
||||
public toJSON (): string {
|
||||
return this.toHex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the type of engine
|
||||
*/
|
||||
public get type (): string {
|
||||
return super.type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Digest
|
||||
* @description
|
||||
* A [[Header]] Digest
|
||||
*/
|
||||
export default class Digest extends Struct {
|
||||
public constructor (value: any) {
|
||||
super({
|
||||
logs: Vector.with(DigestItem)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs
|
||||
*/
|
||||
public get logs (): Vector<DigestItem> {
|
||||
return this.get('logs') as Vector<DigestItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs, filtered, filter items included. This is useful for derive functionality where only a certain type of log is to be returned.
|
||||
*/
|
||||
public logsWith (...include: string[]): Vector<DigestItem> {
|
||||
return this.logs.filter(({ type }): boolean => include.includes(type)) as Vector<DigestItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[DigestItem]] logs, filtered, filter items exluded. This is useful for stripping headers for eg. WASM runtime execution.
|
||||
*/
|
||||
public logsWithout (...exclude: string[]): Vector<DigestItem> {
|
||||
return this.logs.filter(({ type }): boolean => !exclude.includes(type)) as Vector<DigestItem>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name DigestOf
|
||||
* @description
|
||||
* A [[Header]] Digest
|
||||
*/
|
||||
export class DigestOf extends Digest { }
|
||||
@@ -1,144 +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 { Hash } from '../srml/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Enum from '../codec/Enum';
|
||||
import Vector from '../codec/Vector';
|
||||
import Null from '../primitive/Null';
|
||||
import Text from '../primitive/Text';
|
||||
|
||||
/**
|
||||
* @name ExtrinsicStatus
|
||||
* @description
|
||||
* An [[Enum]] that indicates the status of the [[Extrinsic]] as been submitted
|
||||
*/
|
||||
export default class ExtrinsicStatus extends Enum {
|
||||
public constructor (value: any, index?: number) {
|
||||
super({
|
||||
Future: Null,
|
||||
Ready: Null,
|
||||
Finalized: ClassOf('Hash'),
|
||||
Usurped: ClassOf('Hash'),
|
||||
Broadcast: Vector.with(Text),
|
||||
Dropped: Null,
|
||||
Invalid: Null
|
||||
}, value, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Broadcast]]
|
||||
*/
|
||||
public get asBroadcast (): Vector<Text> {
|
||||
assert(this.isBroadcast, `Cannot convert '${this.type}' via asBroadcast`);
|
||||
|
||||
return this.value as Vector<Text>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Dropped]]
|
||||
*/
|
||||
public get asDropped (): Null {
|
||||
assert(this.isDropped, `Cannot convert '${this.type}' via asDropped`);
|
||||
|
||||
return this.value as Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Finalized]]
|
||||
*/
|
||||
public get asFinalized (): Hash {
|
||||
assert(this.isFinalized, `Cannot convert '${this.type}' via asFinalized`);
|
||||
|
||||
return this.value as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Future]]
|
||||
*/
|
||||
public get asFuture (): Null {
|
||||
assert(this.isFuture, `Cannot convert '${this.type}' via asFuture`);
|
||||
|
||||
return this.value as Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Invalid]]
|
||||
*/
|
||||
public get asInvalid (): Null {
|
||||
assert(this.isInvalid, `Cannot convert '${this.type}' via asInvalid`);
|
||||
|
||||
return this.value as Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Ready]]
|
||||
*/
|
||||
public get asReady (): Null {
|
||||
assert(this.isReady, `Cannot convert '${this.type}' via asReady`);
|
||||
|
||||
return this.value as Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the item as a [[Usurped]]
|
||||
*/
|
||||
public get asUsurped (): Hash {
|
||||
assert(this.isUsurped, `Cannot convert '${this.type}' via asUsurped`);
|
||||
|
||||
return this.value as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is boadcast
|
||||
*/
|
||||
public get isBroadcast (): boolean {
|
||||
return this.type === 'Broadcast';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is dropped
|
||||
*/
|
||||
public get isDropped (): boolean {
|
||||
return this.type === 'Dropped';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is finalized
|
||||
*/
|
||||
public get isFinalized (): boolean {
|
||||
return this.type === 'Finalized';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is future
|
||||
*/
|
||||
public get isFuture (): boolean {
|
||||
return this.type === 'Future';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is invalid
|
||||
*/
|
||||
public get isInvalid (): boolean {
|
||||
return this.type === 'Invalid';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is eady
|
||||
*/
|
||||
public get isReady (): boolean {
|
||||
return this.type === 'Ready';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the status is usurped
|
||||
*/
|
||||
public get isUsurped (): boolean {
|
||||
return this.type === 'Usurped';
|
||||
}
|
||||
}
|
||||
@@ -1,43 +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 Bool from '../primitive/Bool';
|
||||
import U64 from '../primitive/U64';
|
||||
|
||||
/**
|
||||
* @name Health
|
||||
* @description
|
||||
* A system health indicator, reported back over RPC
|
||||
*/
|
||||
export default class Health extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
peers: U64,
|
||||
isSyncing: Bool,
|
||||
shouldHavePeers: Bool
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The sync status
|
||||
*/
|
||||
public get isSyncing (): Bool {
|
||||
return this.get('isSyncing') as Bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The numbers of peers as [[U64]]
|
||||
*/
|
||||
public get peers (): U64 {
|
||||
return this.get('peers') as U64;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Should this node have peers (not active on --dev)
|
||||
*/
|
||||
public get shouldHavePeers (): Bool {
|
||||
return this.get('shouldHavePeers') as Bool;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +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 StructAny from '../codec/StructAny';
|
||||
|
||||
/**
|
||||
* @name NetworkState
|
||||
* @description
|
||||
* Wraps the properties retrieved from the chain via the `system.network_state` RPC call.
|
||||
*/
|
||||
export default class NetworkState extends StructAny {
|
||||
}
|
||||
@@ -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 { BlockNumber, Hash } from '../srml/runtime/types';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Text from '../primitive/Text';
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name PeerInfo
|
||||
* @description
|
||||
* A system peer info indicator, reported back over RPC
|
||||
*/
|
||||
export default class PeerInfo extends Struct {
|
||||
public constructor (value?: any) {
|
||||
super({
|
||||
peerId: Text,
|
||||
roles: Text,
|
||||
protocolVersion: U32,
|
||||
bestHash: ClassOf('Hash'),
|
||||
bestNumber: ClassOf('BlockNumber')
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The best block hash for the peer
|
||||
*/
|
||||
public get bestHash (): Hash {
|
||||
return this.get('bestHash') as Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The best block hash for the peer
|
||||
*/
|
||||
public get bestNumber (): BlockNumber {
|
||||
return this.get('bestNumber') as BlockNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The p2p network id for the peer
|
||||
*/
|
||||
public get peerId (): Text {
|
||||
return this.get('peerId') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The index of the peer in our list
|
||||
*/
|
||||
public get protocolVersion (): U32 {
|
||||
return this.get('protocolVersion') as U32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The roles of the peer on the network
|
||||
*/
|
||||
public get roles (): Text {
|
||||
return this.get('roles') as Text;
|
||||
}
|
||||
}
|
||||
@@ -1,125 +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 { AnyNumber, AnyU8a, RuntimeVersionInterface } from '../types';
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import Tuple from '../codec/Tuple';
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
import Vector from '../codec/Vector';
|
||||
import Text from '../primitive/Text';
|
||||
import U32 from '../primitive/U32';
|
||||
|
||||
/**
|
||||
* @name ApiId
|
||||
* @description
|
||||
* An identifier for the runtime API
|
||||
*/
|
||||
export class ApiId extends U8aFixed {
|
||||
public constructor (value?: AnyU8a) {
|
||||
super(value, 64);
|
||||
}
|
||||
}
|
||||
|
||||
interface RuntimeVersionApiValue {
|
||||
id?: AnyU8a;
|
||||
version?: AnyNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name RuntimeVersionApi
|
||||
* @description
|
||||
* A [[Tuple]] that conatins the [[ApiId]] and [[U32]] version
|
||||
*/
|
||||
export class RuntimeVersionApi extends Tuple {
|
||||
public constructor (value?: RuntimeVersionApiValue | Uint8Array) {
|
||||
super({
|
||||
ApiId,
|
||||
U32
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ApiId]]
|
||||
*/
|
||||
public get id (): ApiId {
|
||||
return this[0] as ApiId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The specific version as [[U32]]
|
||||
*/
|
||||
public get version (): U32 {
|
||||
return this[1] as U32;
|
||||
}
|
||||
}
|
||||
|
||||
interface RuntimeVersionValue {
|
||||
specName?: string;
|
||||
implName?: string;
|
||||
authoringVersion?: AnyNumber;
|
||||
specVersion?: AnyNumber;
|
||||
implVersion?: AnyNumber;
|
||||
apis?: RuntimeVersionApiValue[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @name RuntimeVersion
|
||||
* @description
|
||||
* A defintion of the runtime and the associated versions thereof
|
||||
*/
|
||||
export default class RuntimeVersion extends Struct implements RuntimeVersionInterface {
|
||||
public constructor (value?: RuntimeVersionValue | Uint8Array) {
|
||||
super({
|
||||
specName: Text,
|
||||
implName: Text,
|
||||
authoringVersion: U32,
|
||||
specVersion: U32,
|
||||
implVersion: U32,
|
||||
apis: Vector.with(RuntimeVersionApi)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The available APIs as [[RuntimeVersionApi]]
|
||||
*/
|
||||
public get apis (): Vector<RuntimeVersionApi> {
|
||||
return this.get('apis') as Vector<RuntimeVersionApi>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The authoring version as [[U32]]
|
||||
*/
|
||||
public get authoringVersion (): U32 {
|
||||
return this.get('authoringVersion') as U32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The implementation name
|
||||
*/
|
||||
public get implName (): Text {
|
||||
return this.get('implName') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The implementation version
|
||||
*/
|
||||
public get implVersion (): U32 {
|
||||
return this.get('implVersion') as U32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The specification name
|
||||
*/
|
||||
public get specName (): Text {
|
||||
return this.get('specName') as Text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The specification version
|
||||
*/
|
||||
public get specVersion (): U32 {
|
||||
return this.get('specVersion') as U32;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +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 { Hash, Justification } from '../srml/runtime/types';
|
||||
import { AnyU8a } from '../types';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Block, { BlockValue } from './Block';
|
||||
|
||||
interface SignedBlockValue {
|
||||
block?: BlockValue;
|
||||
justification?: AnyU8a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name SignedBlock
|
||||
* @description
|
||||
* A [[Block]] that has been signed and contains a [[Justification]]
|
||||
*/
|
||||
export default class SignedBlock extends Struct {
|
||||
public constructor (value?: SignedBlockValue | Uint8Array) {
|
||||
super({
|
||||
block: Block,
|
||||
justification: ClassOf('Justification')
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Block]]
|
||||
*/
|
||||
public get block (): Block {
|
||||
return this.get('block') as Block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Block/header [[Hash]]
|
||||
*/
|
||||
public get hash (): Hash {
|
||||
return this.block.hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The wrapped [[Justification]]
|
||||
*/
|
||||
public get justification (): Justification {
|
||||
return this.get('justification') as Justification;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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 { Hash } from '../srml/runtime/types';
|
||||
import { AnyU8a } from '../types';
|
||||
|
||||
import { ClassOf } from '../codec/createType';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vector from '../codec/Vector';
|
||||
import { KeyValueOption, KeyValueOptionValue } from '../primitive/KeyValue';
|
||||
|
||||
interface StorageChangeSetValue {
|
||||
block?: AnyU8a;
|
||||
changes?: KeyValueOptionValue[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @name StorageChangeSet
|
||||
* @description
|
||||
* A set of storage changes. It contains the [[Block]] hash and
|
||||
* a list of the actual changes that took place as an array of
|
||||
* [[KeyValueOption]]
|
||||
*/
|
||||
export default class StorageChangeSet extends Struct {
|
||||
public constructor (value?: StorageChangeSetValue | Uint8Array) {
|
||||
super({
|
||||
block: ClassOf('Hash'),
|
||||
changes: Vector.with(KeyValueOption)
|
||||
}, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The applicable changes as [[KeyValueOption]]
|
||||
*/
|
||||
public get changes (): Vector<KeyValueOption> {
|
||||
return this.get('changes') as Vector<KeyValueOption>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[Hash]]
|
||||
*/
|
||||
public get block (): Hash {
|
||||
return this.get('block') as Hash;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +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.
|
||||
|
||||
// NOTE When adding any types here, we need to update the coumentation links as
|
||||
// well - <root>/docs/SUMMARY.md as well as ../README.md
|
||||
|
||||
/**
|
||||
* @summary Type definitions that are used in the rpc
|
||||
*/
|
||||
export { default as Block } from './Block';
|
||||
export { default as ChainProperties } from './ChainProperties';
|
||||
export { default as Digest, DigestItem, DigestOf } from './Digest';
|
||||
export { default as ExtrinsicStatus } from './ExtrinsicStatus';
|
||||
export { default as Header } from './Header';
|
||||
export { default as Health } from './Health';
|
||||
export { default as NetworkState } from './NetworkState';
|
||||
export { default as PeerInfo } from './PeerInfo';
|
||||
export { default as RuntimeVersion } from './RuntimeVersion';
|
||||
export { default as SignedBlock } from './SignedBlock';
|
||||
export { default as StorageChangeSet } from './StorageChangeSet';
|
||||
@@ -2,6 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '../injector';
|
||||
|
||||
import fs from 'fs';
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ interface TypeImports {
|
||||
primitiveTypes: TypeExist;
|
||||
}
|
||||
|
||||
const HEADER = '/* eslint-disable @typescript-eslint/no-empty-interface */\n// Auto-generated via `yarn build:srmlTs`, do not edit\n\n';
|
||||
const HEADER = '// Auto-generated via `yarn build:srmlTs`, do not edit\n\n';
|
||||
const FOOTER = '\n';
|
||||
|
||||
// Maps the types as found to the source location. This is used to generate the
|
||||
@@ -68,14 +68,19 @@ function isCompactEncodable (Child: Constructor<any>): boolean {
|
||||
return Object.values(COMPACT_ENCODABLE).some((CompactEncodable): boolean => isChildClass(CompactEncodable, Child));
|
||||
}
|
||||
|
||||
// helper to generate a `export interface<Name> extends <Base> {<Body>}
|
||||
function createInterface (name: string = '', base: string, body: string = ''): string {
|
||||
return `export interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
||||
// helper to generate a `export interface <Name> extends <Base> {<Body>}
|
||||
function exportInterface (name: string = '', base: string, body: string = ''): string {
|
||||
return `/** ${base} */\nexport interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
||||
}
|
||||
|
||||
// helper to create an `export <Name> = <Base>`
|
||||
function exportType (name: string = '', base: string): string {
|
||||
return `/** ${base} */\nexport type ${name} = ${base};`;
|
||||
}
|
||||
|
||||
// helper to generate a `readonly <Name>: <Type>;` getter
|
||||
function createGetter (name: string = '', type: string): string {
|
||||
return ` readonly ${name}: ${type};\n`;
|
||||
function createGetter (name: string = '', type: string, doc?: string): string {
|
||||
return ` /** ${doc || type} */\n readonly ${name}: ${type};\n`;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@@ -91,7 +96,7 @@ function tsCompact ({ name: compactName, sub }: TypeDef, imports: TypeImports):
|
||||
switch (def.info) {
|
||||
case TypeDefInfo.Plain:
|
||||
setImports(imports, [def.type]);
|
||||
return createInterface(compactName, `Compact<${def.type}>`);
|
||||
return exportType(compactName, `Compact<${def.type}>`);
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${compactName}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
@@ -106,18 +111,19 @@ function tsEnum ({ name: enumName, sub }: TypeDef, imports: TypeImports): string
|
||||
const [enumType, asGetter] = type === 'Null'
|
||||
? ['', '']
|
||||
: [`(${type})`, createGetter(`as${getter}`, type)];
|
||||
const isGetter = createGetter(`is${getter}`, 'boolean');
|
||||
const isGetter = createGetter(`is${getter}`, 'boolean', `${index}:: ${name}${enumType}`);
|
||||
|
||||
switch (info) {
|
||||
case TypeDefInfo.Plain:
|
||||
return ` /**\n * @description ${index}:: ${name}${enumType}\n */\n${isGetter}${asGetter}`;
|
||||
case TypeDefInfo.Vec:
|
||||
return `${isGetter}${asGetter}`;
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${enumName}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
}
|
||||
});
|
||||
|
||||
return createInterface(enumName, 'Enum', keys.join(''));
|
||||
return exportInterface(enumName, 'Enum', keys.join(''));
|
||||
}
|
||||
|
||||
function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): string {
|
||||
@@ -128,7 +134,7 @@ function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): st
|
||||
switch (def.info) {
|
||||
case TypeDefInfo.Plain:
|
||||
setImports(imports, [def.type]);
|
||||
return createInterface(optionName, `Option<${def.type}>`);
|
||||
return exportType(optionName, `Option<${def.type}>`);
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${optionName}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
@@ -138,7 +144,7 @@ function tsOption ({ name: optionName, sub }: TypeDef, imports: TypeImports): st
|
||||
function tsPlain ({ name: plainName, type }: TypeDef, imports: TypeImports): string {
|
||||
setImports(imports, [type]);
|
||||
|
||||
return createInterface(plainName, type);
|
||||
return exportType(plainName, type);
|
||||
}
|
||||
|
||||
function _tsStructGetterType (structName: string | undefined, { info, sub, type }: TypeDef, imports: TypeImports): [string, string] {
|
||||
@@ -162,12 +168,12 @@ function _tsStructGetterType (structName: string | undefined, { info, sub, type
|
||||
case TypeDefInfo.Plain:
|
||||
return [type, type];
|
||||
|
||||
case TypeDefInfo.Vector:
|
||||
case TypeDefInfo.Vec:
|
||||
_type = (sub as TypeDef).type;
|
||||
|
||||
setImports(imports, ['Vector']);
|
||||
setImports(imports, ['Vec']);
|
||||
|
||||
return [_type, `Vector<${_type}>`];
|
||||
return [_type, `Vec<${_type}>`];
|
||||
|
||||
default:
|
||||
throw new Error(`Struct: ${structName}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
@@ -181,7 +187,7 @@ function tsSet ({ name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
createGetter(`is${name}`, 'boolean')
|
||||
);
|
||||
|
||||
return createInterface(setName, 'Set', types.join(''));
|
||||
return exportInterface(setName, 'Set', types.join(''));
|
||||
}
|
||||
|
||||
function tsStruct ({ name: structName, sub }: TypeDef, imports: TypeImports): string {
|
||||
@@ -193,7 +199,7 @@ function tsStruct ({ name: structName, sub }: TypeDef, imports: TypeImports): st
|
||||
return createGetter(typedef.name, returnType);
|
||||
});
|
||||
|
||||
return createInterface(structName, 'Struct', keys.join(''));
|
||||
return exportInterface(structName, 'Struct', keys.join(''));
|
||||
}
|
||||
|
||||
function _tsTupleGetterType (tupleName: string | undefined, { info, sub, type }: TypeDef, imports: TypeImports): string {
|
||||
@@ -219,20 +225,18 @@ function tsTuple ({ name: tupleName, sub }: TypeDef, imports: TypeImports): stri
|
||||
const types = (sub as TypeDef[]).map((typedef): string =>
|
||||
_tsTupleGetterType(tupleName, typedef, imports)
|
||||
);
|
||||
const exp = createInterface(tupleName, `Codec, _${tupleName}`);
|
||||
|
||||
// TODO We need some way here of identifying the fields
|
||||
return `type _${tupleName} = [${types.join(', ')}];\n${exp}`;
|
||||
return exportType(tupleName, `[${types.join(', ')}] & Codec`);
|
||||
}
|
||||
|
||||
function tsVector ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeImports): string {
|
||||
const type = info === TypeDefInfo.VectorFixed
|
||||
function tsVec ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeImports): string {
|
||||
const type = info === TypeDefInfo.VecFixed
|
||||
? (ext as TypeDefExtVecFixed).type
|
||||
: (sub as TypeDef).type;
|
||||
|
||||
setImports(imports, ['Vector', type]);
|
||||
setImports(imports, ['Vec', type]);
|
||||
|
||||
return createInterface(vectorName, `Vector<${type}>`);
|
||||
return exportType(vectorName, `Vec<${type}>`);
|
||||
}
|
||||
|
||||
// creates the import lines
|
||||
@@ -250,13 +254,13 @@ function createImportCode (header: string, checks: { file: string; types: string
|
||||
function getDerivedTypes (type: string, primitiveName: string, imports: TypeImports, indent: number = 2): string {
|
||||
// `primitiveName` represents the actual primitive type our type is mapped to
|
||||
const isCompact = isCompactEncodable((primitiveClasses as any)[primitiveName]);
|
||||
setImports(imports, ['Option', 'Vector', isCompact ? 'Compact' : '']);
|
||||
setImports(imports, ['Option', 'Vec', isCompact ? 'Compact' : '']);
|
||||
|
||||
return [
|
||||
`${type}: ${type};`,
|
||||
isCompact ? `'Compact<${type}>': Compact<${type}>;` : undefined,
|
||||
`'Option<${type}>': Option<${type}>;`,
|
||||
`'Vec<${type}>': Vector<${type}>;`
|
||||
`'Vec<${type}>': Vec<${type}>;`
|
||||
]
|
||||
.filter((x): boolean => !!x)
|
||||
.map((line): string => `${' '.repeat(indent)}${line}`) // Add indentation
|
||||
@@ -289,8 +293,8 @@ function generateTsDef (srmlName: string, { types }: { types: Record<string, any
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Struct]: tsStruct,
|
||||
[TypeDefInfo.Tuple]: tsTuple,
|
||||
[TypeDefInfo.Vector]: tsVector,
|
||||
[TypeDefInfo.VectorFixed]: tsVector
|
||||
[TypeDefInfo.Vec]: tsVec,
|
||||
[TypeDefInfo.VecFixed]: tsVec
|
||||
};
|
||||
|
||||
const codecTypes: TypeExist = {};
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Enum, Option, Vector } from '../../codec';
|
||||
import { Enum, Option, Vec } from '../../codec';
|
||||
import { AccountId } from '../../primitive';
|
||||
import { BlockNumber, Hash } from '../runtime/types';
|
||||
|
||||
export interface InclusionHeight extends BlockNumber {}
|
||||
/** BlockNumber */
|
||||
export type InclusionHeight = BlockNumber;
|
||||
|
||||
type _Uncle = [Hash, Option<AccountId>];
|
||||
export interface Uncle extends Codec, _Uncle {}
|
||||
/** [Hash, Option<AccountId>] & Codec */
|
||||
export type Uncle = [Hash, Option<AccountId>] & Codec;
|
||||
|
||||
/** Enum */
|
||||
export interface UncleEntryItem extends Enum {
|
||||
/**
|
||||
* @description 0:: InclusionHeight(InclusionHeight)
|
||||
*/
|
||||
/** 0:: InclusionHeight(InclusionHeight) */
|
||||
readonly isInclusionHeight: boolean;
|
||||
/** InclusionHeight */
|
||||
readonly asInclusionHeight: InclusionHeight;
|
||||
/**
|
||||
* @description 1:: Uncle(Uncle)
|
||||
*/
|
||||
/** 1:: Uncle(Uncle) */
|
||||
readonly isUncle: boolean;
|
||||
/** Uncle */
|
||||
readonly asUncle: Uncle;
|
||||
}
|
||||
|
||||
@@ -28,12 +27,12 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
InclusionHeight: InclusionHeight;
|
||||
'Option<InclusionHeight>': Option<InclusionHeight>;
|
||||
'Vec<InclusionHeight>': Vector<InclusionHeight>;
|
||||
'Vec<InclusionHeight>': Vec<InclusionHeight>;
|
||||
Uncle: Uncle;
|
||||
'Option<Uncle>': Option<Uncle>;
|
||||
'Vec<Uncle>': Vector<Uncle>;
|
||||
'Vec<Uncle>': Vec<Uncle>;
|
||||
UncleEntryItem: UncleEntryItem;
|
||||
'Option<UncleEntryItem>': Option<UncleEntryItem>;
|
||||
'Vec<UncleEntryItem>': Vector<UncleEntryItem>;
|
||||
'Vec<UncleEntryItem>': Vec<UncleEntryItem>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Option, Vector } from '../../codec';
|
||||
import { Compact, Option, Vec } from '../../codec';
|
||||
import { u64 } from '../../primitive';
|
||||
|
||||
export interface BabeWeight extends u64 {}
|
||||
/** u64 */
|
||||
export type BabeWeight = u64;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
BabeWeight: BabeWeight;
|
||||
'Compact<BabeWeight>': Compact<BabeWeight>;
|
||||
'Option<BabeWeight>': Option<BabeWeight>;
|
||||
'Vec<BabeWeight>': Vector<BabeWeight>;
|
||||
'Vec<BabeWeight>': Vec<BabeWeight>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,37 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Option, Set, Struct, Vector } from '../../codec';
|
||||
import { Option, Set, Struct, Vec } from '../../codec';
|
||||
import { Balance, BlockNumber, LockIdentifier } from '../runtime/types';
|
||||
|
||||
/** Struct */
|
||||
export interface BalanceLock extends Struct {
|
||||
/** LockIdentifier */
|
||||
readonly id: LockIdentifier;
|
||||
/** Balance */
|
||||
readonly amount: Balance;
|
||||
/** BlockNumber */
|
||||
readonly until: BlockNumber;
|
||||
/** WithdrawReasons */
|
||||
readonly reasons: WithdrawReasons;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface VestingSchedule extends Struct {
|
||||
/** Balance */
|
||||
readonly offset: Balance;
|
||||
/** Balance */
|
||||
readonly perBlock: Balance;
|
||||
}
|
||||
|
||||
/** Set */
|
||||
export interface WithdrawReasons extends Set {
|
||||
/** boolean */
|
||||
readonly isTransactionPayment: boolean;
|
||||
/** boolean */
|
||||
readonly isTransfer: boolean;
|
||||
/** boolean */
|
||||
readonly isReserve: boolean;
|
||||
/** boolean */
|
||||
readonly isFee: boolean;
|
||||
}
|
||||
|
||||
@@ -27,12 +39,12 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
VestingSchedule: VestingSchedule;
|
||||
'Option<VestingSchedule>': Option<VestingSchedule>;
|
||||
'Vec<VestingSchedule>': Vector<VestingSchedule>;
|
||||
'Vec<VestingSchedule>': Vec<VestingSchedule>;
|
||||
WithdrawReasons: WithdrawReasons;
|
||||
'Option<WithdrawReasons>': Option<WithdrawReasons>;
|
||||
'Vec<WithdrawReasons>': Vector<WithdrawReasons>;
|
||||
'Vec<WithdrawReasons>': Vec<WithdrawReasons>;
|
||||
BalanceLock: BalanceLock;
|
||||
'Option<BalanceLock>': Option<BalanceLock>;
|
||||
'Vec<BalanceLock>': Vector<BalanceLock>;
|
||||
'Vec<BalanceLock>': Vec<BalanceLock>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Option, Struct, Vec } from '../../codec';
|
||||
import { AccountId, u32, u64 } from '../../primitive';
|
||||
|
||||
export interface MemberCount extends u64 {}
|
||||
/** u64 */
|
||||
export type MemberCount = u64;
|
||||
|
||||
export interface ProposalIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type ProposalIndex = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface Votes extends Struct {
|
||||
/** ProposalIndex */
|
||||
readonly index: ProposalIndex;
|
||||
/** MemberCount */
|
||||
readonly threshold: MemberCount;
|
||||
readonly ayes: Vector<AccountId>;
|
||||
readonly nays: Vector<AccountId>;
|
||||
/** Vec<AccountId> */
|
||||
readonly ayes: Vec<AccountId>;
|
||||
/** Vec<AccountId> */
|
||||
readonly nays: Vec<AccountId>;
|
||||
}
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
@@ -20,13 +26,13 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
MemberCount: MemberCount;
|
||||
'Compact<MemberCount>': Compact<MemberCount>;
|
||||
'Option<MemberCount>': Option<MemberCount>;
|
||||
'Vec<MemberCount>': Vector<MemberCount>;
|
||||
'Vec<MemberCount>': Vec<MemberCount>;
|
||||
ProposalIndex: ProposalIndex;
|
||||
'Compact<ProposalIndex>': Compact<ProposalIndex>;
|
||||
'Option<ProposalIndex>': Option<ProposalIndex>;
|
||||
'Vec<ProposalIndex>': Vector<ProposalIndex>;
|
||||
'Vec<ProposalIndex>': Vec<ProposalIndex>;
|
||||
Votes: Votes;
|
||||
'Option<Votes>': Option<Votes>;
|
||||
'Vec<Votes>': Vector<Votes>;
|
||||
'Vec<Votes>': Vec<Votes>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Option, Vector } from '../../codec';
|
||||
import { Option, Vec } from '../../codec';
|
||||
import { AccountId } from '../../primitive';
|
||||
|
||||
export interface AuthorityId extends AccountId {}
|
||||
/** AccountId */
|
||||
export type AuthorityId = AccountId;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
AuthorityId: AuthorityId;
|
||||
'Option<AuthorityId>': Option<AuthorityId>;
|
||||
'Vec<AuthorityId>': Vector<AuthorityId>;
|
||||
'Vec<AuthorityId>': Vec<AuthorityId>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +1,141 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { Bool, Bytes, Null, u32, u64, u8 } from '../../primitive';
|
||||
import { Balance, BlockNumber, Hash } from '../runtime/types';
|
||||
|
||||
/** Struct */
|
||||
export interface AliveContractInfo extends Struct {
|
||||
/** TrieId */
|
||||
readonly trieId: TrieId;
|
||||
/** u32 */
|
||||
readonly storageSize: u32;
|
||||
/** CodeHash */
|
||||
readonly codeHash: CodeHash;
|
||||
/** Balance */
|
||||
readonly rentAllowance: Balance;
|
||||
/** BlockNumber */
|
||||
readonly deductBlock: BlockNumber;
|
||||
/** Option<BlockNumber> */
|
||||
readonly lastWrite: Option<BlockNumber>;
|
||||
}
|
||||
|
||||
export interface CodeHash extends Hash {}
|
||||
/** Hash */
|
||||
export type CodeHash = Hash;
|
||||
|
||||
/** Enum */
|
||||
export interface ContractInfo extends Enum {
|
||||
/**
|
||||
* @description 0:: Alive(AliveContractInfo)
|
||||
*/
|
||||
/** 0:: Alive(AliveContractInfo) */
|
||||
readonly isAlive: boolean;
|
||||
/** AliveContractInfo */
|
||||
readonly asAlive: AliveContractInfo;
|
||||
/**
|
||||
* @description 1:: Tombstone(TombstoneContractInfo)
|
||||
*/
|
||||
/** 1:: Tombstone(TombstoneContractInfo) */
|
||||
readonly isTombstone: boolean;
|
||||
/** TombstoneContractInfo */
|
||||
readonly asTombstone: TombstoneContractInfo;
|
||||
}
|
||||
|
||||
export interface ContractStorageKey extends Vector<u8> {}
|
||||
/** Vec<u8> */
|
||||
export type ContractStorageKey = Vec<u8>;
|
||||
|
||||
export interface Gas extends u64 {}
|
||||
/** u64 */
|
||||
export type Gas = u64;
|
||||
|
||||
/** Struct */
|
||||
export interface PrefabWasmModule extends Struct {
|
||||
/** Compact<u32> */
|
||||
readonly scheduleVersion: Compact<u32>;
|
||||
/** Compact<u32> */
|
||||
readonly initial: Compact<u32>;
|
||||
/** Compact<u32> */
|
||||
readonly maximum: Compact<u32>;
|
||||
/** PrefabWasmModuleReserved */
|
||||
readonly _reserved: PrefabWasmModuleReserved;
|
||||
/** Bytes */
|
||||
readonly code: Bytes;
|
||||
}
|
||||
|
||||
export interface PrefabWasmModuleReserved extends Option<Null> {}
|
||||
/** Option<Null> */
|
||||
export type PrefabWasmModuleReserved = Option<Null>;
|
||||
|
||||
/** Struct */
|
||||
export interface Schedule extends Struct {
|
||||
/** u32 */
|
||||
readonly version: u32;
|
||||
/** Gas */
|
||||
readonly putCodePerByteCost: Gas;
|
||||
/** Gas */
|
||||
readonly growMemCost: Gas;
|
||||
/** Gas */
|
||||
readonly regularOpCost: Gas;
|
||||
/** Gas */
|
||||
readonly returnDataPerByteCost: Gas;
|
||||
/** Gas */
|
||||
readonly eventDataPerByteCost: Gas;
|
||||
/** Gas */
|
||||
readonly eventPerTopicCost: Gas;
|
||||
/** Gas */
|
||||
readonly eventBaseCost: Gas;
|
||||
/** Gas */
|
||||
readonly sandboxDataReadCost: Gas;
|
||||
/** Gas */
|
||||
readonly sandboxDataWriteCost: Gas;
|
||||
/** u32 */
|
||||
readonly maxEventTopics: u32;
|
||||
/** u32 */
|
||||
readonly maxStackHeight: u32;
|
||||
/** u32 */
|
||||
readonly maxMemoryPages: u32;
|
||||
/** Bool */
|
||||
readonly enablePrintln: Bool;
|
||||
/** u32 */
|
||||
readonly maxSubjectLen: u32;
|
||||
}
|
||||
|
||||
export interface SeedOf extends Hash {}
|
||||
/** Hash */
|
||||
export type SeedOf = Hash;
|
||||
|
||||
export interface TombstoneContractInfo extends Hash {}
|
||||
/** Hash */
|
||||
export type TombstoneContractInfo = Hash;
|
||||
|
||||
export interface TrieId extends Bytes {}
|
||||
/** Bytes */
|
||||
export type TrieId = Bytes;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
CodeHash: CodeHash;
|
||||
'Option<CodeHash>': Option<CodeHash>;
|
||||
'Vec<CodeHash>': Vector<CodeHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
TrieId: TrieId;
|
||||
'Option<TrieId>': Option<TrieId>;
|
||||
'Vec<TrieId>': Vector<TrieId>;
|
||||
'Vec<TrieId>': Vec<TrieId>;
|
||||
AliveContractInfo: AliveContractInfo;
|
||||
'Option<AliveContractInfo>': Option<AliveContractInfo>;
|
||||
'Vec<AliveContractInfo>': Vector<AliveContractInfo>;
|
||||
'Vec<AliveContractInfo>': Vec<AliveContractInfo>;
|
||||
TombstoneContractInfo: TombstoneContractInfo;
|
||||
'Option<TombstoneContractInfo>': Option<TombstoneContractInfo>;
|
||||
'Vec<TombstoneContractInfo>': Vector<TombstoneContractInfo>;
|
||||
'Vec<TombstoneContractInfo>': Vec<TombstoneContractInfo>;
|
||||
ContractInfo: ContractInfo;
|
||||
'Option<ContractInfo>': Option<ContractInfo>;
|
||||
'Vec<ContractInfo>': Vector<ContractInfo>;
|
||||
'Vec<ContractInfo>': Vec<ContractInfo>;
|
||||
ContractStorageKey: ContractStorageKey;
|
||||
'Option<ContractStorageKey>': Option<ContractStorageKey>;
|
||||
'Vec<ContractStorageKey>': Vector<ContractStorageKey>;
|
||||
'Vec<ContractStorageKey>': Vec<ContractStorageKey>;
|
||||
Gas: Gas;
|
||||
'Compact<Gas>': Compact<Gas>;
|
||||
'Option<Gas>': Option<Gas>;
|
||||
'Vec<Gas>': Vector<Gas>;
|
||||
'Vec<Gas>': Vec<Gas>;
|
||||
PrefabWasmModuleReserved: PrefabWasmModuleReserved;
|
||||
'Option<PrefabWasmModuleReserved>': Option<PrefabWasmModuleReserved>;
|
||||
'Vec<PrefabWasmModuleReserved>': Vector<PrefabWasmModuleReserved>;
|
||||
'Vec<PrefabWasmModuleReserved>': Vec<PrefabWasmModuleReserved>;
|
||||
PrefabWasmModule: PrefabWasmModule;
|
||||
'Option<PrefabWasmModule>': Option<PrefabWasmModule>;
|
||||
'Vec<PrefabWasmModule>': Vector<PrefabWasmModule>;
|
||||
'Vec<PrefabWasmModule>': Vec<PrefabWasmModule>;
|
||||
Schedule: Schedule;
|
||||
'Option<Schedule>': Option<Schedule>;
|
||||
'Vec<Schedule>': Vector<Schedule>;
|
||||
'Vec<Schedule>': Vec<Schedule>;
|
||||
SeedOf: SeedOf;
|
||||
'Option<SeedOf>': Option<SeedOf>;
|
||||
'Vec<SeedOf>': Vector<SeedOf>;
|
||||
'Vec<SeedOf>': Vec<SeedOf>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,3 +34,6 @@ export { default as parachains } from './parachains/definitions';
|
||||
export { default as staking } from './staking/definitions';
|
||||
export { default as system } from './system/definitions';
|
||||
export { default as treasury } from './treasury/definitions';
|
||||
|
||||
// pull in rpc last, assuming that is uses info from above
|
||||
export { default as rpc } from './rpc/definitions';
|
||||
|
||||
@@ -1,48 +1,44 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { Method, u32 } from '../../primitive';
|
||||
import { BlockNumber } from '../runtime/types';
|
||||
import { VoteThreshold } from '../elections/types';
|
||||
|
||||
/** Enum */
|
||||
export interface Conviction extends Enum {
|
||||
/**
|
||||
* @description 0:: None
|
||||
*/
|
||||
/** 0:: None */
|
||||
readonly isNone: boolean;
|
||||
/**
|
||||
* @description 1:: Locked1x
|
||||
*/
|
||||
/** 1:: Locked1x */
|
||||
readonly isLocked1X: boolean;
|
||||
/**
|
||||
* @description 2:: Locked2x
|
||||
*/
|
||||
/** 2:: Locked2x */
|
||||
readonly isLocked2X: boolean;
|
||||
/**
|
||||
* @description 3:: Locked3x
|
||||
*/
|
||||
/** 3:: Locked3x */
|
||||
readonly isLocked3X: boolean;
|
||||
/**
|
||||
* @description 4:: Locked4x
|
||||
*/
|
||||
/** 4:: Locked4x */
|
||||
readonly isLocked4X: boolean;
|
||||
/**
|
||||
* @description 5:: Locked5x
|
||||
*/
|
||||
/** 5:: Locked5x */
|
||||
readonly isLocked5X: boolean;
|
||||
}
|
||||
|
||||
export interface PropIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type PropIndex = u32;
|
||||
|
||||
export interface Proposal extends Method {}
|
||||
/** Method */
|
||||
export type Proposal = Method;
|
||||
|
||||
export interface ReferendumIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type ReferendumIndex = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface ReferendumInfo extends Struct {
|
||||
/** BlockNumber */
|
||||
readonly end: BlockNumber;
|
||||
/** Proposal */
|
||||
readonly proposal: Proposal;
|
||||
/** VoteThreshold */
|
||||
readonly threshold: VoteThreshold;
|
||||
/** BlockNumber */
|
||||
readonly delay: BlockNumber;
|
||||
}
|
||||
|
||||
@@ -50,20 +46,20 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
Conviction: Conviction;
|
||||
'Option<Conviction>': Option<Conviction>;
|
||||
'Vec<Conviction>': Vector<Conviction>;
|
||||
'Vec<Conviction>': Vec<Conviction>;
|
||||
PropIndex: PropIndex;
|
||||
'Compact<PropIndex>': Compact<PropIndex>;
|
||||
'Option<PropIndex>': Option<PropIndex>;
|
||||
'Vec<PropIndex>': Vector<PropIndex>;
|
||||
'Vec<PropIndex>': Vec<PropIndex>;
|
||||
Proposal: Proposal;
|
||||
'Option<Proposal>': Option<Proposal>;
|
||||
'Vec<Proposal>': Vector<Proposal>;
|
||||
'Vec<Proposal>': Vec<Proposal>;
|
||||
ReferendumIndex: ReferendumIndex;
|
||||
'Compact<ReferendumIndex>': Compact<ReferendumIndex>;
|
||||
'Option<ReferendumIndex>': Option<ReferendumIndex>;
|
||||
'Vec<ReferendumIndex>': Vector<ReferendumIndex>;
|
||||
'Vec<ReferendumIndex>': Vec<ReferendumIndex>;
|
||||
ReferendumInfo: ReferendumInfo;
|
||||
'Option<ReferendumInfo>': Option<ReferendumInfo>;
|
||||
'Vec<ReferendumInfo>': Vector<ReferendumInfo>;
|
||||
'Vec<ReferendumInfo>': Vec<ReferendumInfo>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,71 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { AccountId, Bytes, Null, i8, u32, u64 } from '../../primitive';
|
||||
import { Balance } from '../runtime/types';
|
||||
|
||||
/** Struct */
|
||||
export interface AccountInfo extends Struct {
|
||||
/** Bytes */
|
||||
readonly trieId: Bytes;
|
||||
/** u64 */
|
||||
readonly currentMemStored: u64;
|
||||
}
|
||||
|
||||
export interface Amount extends Balance {}
|
||||
/** Balance */
|
||||
export type Amount = Balance;
|
||||
|
||||
export interface AssetOf extends u32 {}
|
||||
/** u32 */
|
||||
export type AssetOf = u32;
|
||||
|
||||
export interface InherentOfflineReport extends Null {}
|
||||
/** Null */
|
||||
export type InherentOfflineReport = Null;
|
||||
|
||||
export interface LockPeriods extends i8 {}
|
||||
/** i8 */
|
||||
export type LockPeriods = i8;
|
||||
|
||||
/** Enum */
|
||||
export interface NewAccountOutcome extends Enum {
|
||||
/**
|
||||
* @description 0:: NoHint
|
||||
*/
|
||||
/** 0:: NoHint */
|
||||
readonly isNoHint: boolean;
|
||||
/**
|
||||
* @description 1:: GoodHint
|
||||
*/
|
||||
/** 1:: GoodHint */
|
||||
readonly isGoodHint: boolean;
|
||||
/**
|
||||
* @description 2:: BadHint
|
||||
*/
|
||||
/** 2:: BadHint */
|
||||
readonly isBadHint: boolean;
|
||||
}
|
||||
|
||||
export interface OpaqueKey extends Bytes {}
|
||||
/** Bytes */
|
||||
export type OpaqueKey = Bytes;
|
||||
|
||||
export interface SessionKey extends AccountId {}
|
||||
/** AccountId */
|
||||
export type SessionKey = AccountId;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
NewAccountOutcome: NewAccountOutcome;
|
||||
'Option<NewAccountOutcome>': Option<NewAccountOutcome>;
|
||||
'Vec<NewAccountOutcome>': Vector<NewAccountOutcome>;
|
||||
'Vec<NewAccountOutcome>': Vec<NewAccountOutcome>;
|
||||
Amount: Amount;
|
||||
'Option<Amount>': Option<Amount>;
|
||||
'Vec<Amount>': Vector<Amount>;
|
||||
'Vec<Amount>': Vec<Amount>;
|
||||
AssetOf: AssetOf;
|
||||
'Compact<AssetOf>': Compact<AssetOf>;
|
||||
'Option<AssetOf>': Option<AssetOf>;
|
||||
'Vec<AssetOf>': Vector<AssetOf>;
|
||||
'Vec<AssetOf>': Vec<AssetOf>;
|
||||
AccountInfo: AccountInfo;
|
||||
'Option<AccountInfo>': Option<AccountInfo>;
|
||||
'Vec<AccountInfo>': Vector<AccountInfo>;
|
||||
'Vec<AccountInfo>': Vec<AccountInfo>;
|
||||
LockPeriods: LockPeriods;
|
||||
'Compact<LockPeriods>': Compact<LockPeriods>;
|
||||
'Option<LockPeriods>': Option<LockPeriods>;
|
||||
'Vec<LockPeriods>': Vector<LockPeriods>;
|
||||
'Vec<LockPeriods>': Vec<LockPeriods>;
|
||||
InherentOfflineReport: InherentOfflineReport;
|
||||
'Option<InherentOfflineReport>': Option<InherentOfflineReport>;
|
||||
'Vec<InherentOfflineReport>': Vector<InherentOfflineReport>;
|
||||
'Vec<InherentOfflineReport>': Vec<InherentOfflineReport>;
|
||||
SessionKey: SessionKey;
|
||||
'Option<SessionKey>': Option<SessionKey>;
|
||||
'Vec<SessionKey>': Vector<SessionKey>;
|
||||
'Vec<SessionKey>': Vec<SessionKey>;
|
||||
OpaqueKey: OpaqueKey;
|
||||
'Option<OpaqueKey>': Option<OpaqueKey>;
|
||||
'Vec<OpaqueKey>': Vector<OpaqueKey>;
|
||||
'Vec<OpaqueKey>': Vec<OpaqueKey>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { u32 } from '../../primitive';
|
||||
import { Balance } from '../runtime/types';
|
||||
|
||||
export interface ApprovalFlag extends u32 {}
|
||||
/** u32 */
|
||||
export type ApprovalFlag = u32;
|
||||
|
||||
export interface SetIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type SetIndex = u32;
|
||||
|
||||
export interface VoteIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type VoteIndex = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface VoterInfo extends Struct {
|
||||
/** VoteIndex */
|
||||
readonly lastActive: VoteIndex;
|
||||
/** VoteIndex */
|
||||
readonly lastWin: VoteIndex;
|
||||
/** Balance */
|
||||
readonly pot: Balance;
|
||||
/** Balance */
|
||||
readonly stake: Balance;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface VoteThreshold extends Enum {
|
||||
/**
|
||||
* @description 0:: Super majority approval
|
||||
*/
|
||||
/** 0:: Super majority approval */
|
||||
readonly isSuperMajorityApproval: boolean;
|
||||
/**
|
||||
* @description 1:: Super majority rejection
|
||||
*/
|
||||
/** 1:: Super majority rejection */
|
||||
readonly isSuperMajorityRejection: boolean;
|
||||
/**
|
||||
* @description 2:: Simple majority
|
||||
*/
|
||||
/** 2:: Simple majority */
|
||||
readonly isSimpleMajority: boolean;
|
||||
}
|
||||
|
||||
@@ -38,20 +40,20 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
ApprovalFlag: ApprovalFlag;
|
||||
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
|
||||
'Option<ApprovalFlag>': Option<ApprovalFlag>;
|
||||
'Vec<ApprovalFlag>': Vector<ApprovalFlag>;
|
||||
'Vec<ApprovalFlag>': Vec<ApprovalFlag>;
|
||||
SetIndex: SetIndex;
|
||||
'Compact<SetIndex>': Compact<SetIndex>;
|
||||
'Option<SetIndex>': Option<SetIndex>;
|
||||
'Vec<SetIndex>': Vector<SetIndex>;
|
||||
'Vec<SetIndex>': Vec<SetIndex>;
|
||||
VoteIndex: VoteIndex;
|
||||
'Compact<VoteIndex>': Compact<VoteIndex>;
|
||||
'Option<VoteIndex>': Option<VoteIndex>;
|
||||
'Vec<VoteIndex>': Vector<VoteIndex>;
|
||||
'Vec<VoteIndex>': Vec<VoteIndex>;
|
||||
VoterInfo: VoterInfo;
|
||||
'Option<VoterInfo>': Option<VoterInfo>;
|
||||
'Vec<VoterInfo>': Vector<VoterInfo>;
|
||||
'Vec<VoterInfo>': Vec<VoterInfo>;
|
||||
VoteThreshold: VoteThreshold;
|
||||
'Option<VoteThreshold>': Option<VoteThreshold>;
|
||||
'Vec<VoteThreshold>': Vector<VoteThreshold>;
|
||||
'Vec<VoteThreshold>': Vec<VoteThreshold>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,56 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { u64 } from '../../primitive';
|
||||
import { BlockNumber } from '../runtime/types';
|
||||
import { AuthorityId } from '../consensus/types';
|
||||
|
||||
export interface AuthorityWeight extends u64 {}
|
||||
/** u64 */
|
||||
export type AuthorityWeight = u64;
|
||||
|
||||
type _NextAuthority = [AuthorityId, u64];
|
||||
export interface NextAuthority extends Codec, _NextAuthority {}
|
||||
/** [AuthorityId, u64] & Codec */
|
||||
export type NextAuthority = [AuthorityId, u64] & Codec;
|
||||
|
||||
/** Struct */
|
||||
export interface PendingPause extends Struct {
|
||||
/** BlockNumber */
|
||||
readonly scheduledAt: BlockNumber;
|
||||
/** BlockNumber */
|
||||
readonly delay: BlockNumber;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface PendingResume extends Struct {
|
||||
/** BlockNumber */
|
||||
readonly scheduledAt: BlockNumber;
|
||||
/** BlockNumber */
|
||||
readonly delay: BlockNumber;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface StoredPendingChange extends Struct {
|
||||
/** BlockNumber */
|
||||
readonly scheduledAt: BlockNumber;
|
||||
/** BlockNumber */
|
||||
readonly delay: BlockNumber;
|
||||
readonly nextAuthorities: Vector<NextAuthority>;
|
||||
/** Vec<NextAuthority> */
|
||||
readonly nextAuthorities: Vec<NextAuthority>;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface StoredState extends Enum {
|
||||
/**
|
||||
* @description 0:: Live
|
||||
*/
|
||||
/** 0:: Live */
|
||||
readonly isLive: boolean;
|
||||
/**
|
||||
* @description 1:: PendingPause(PendingPause)
|
||||
*/
|
||||
/** 1:: PendingPause(PendingPause) */
|
||||
readonly isPendingPause: boolean;
|
||||
/** PendingPause */
|
||||
readonly asPendingPause: PendingPause;
|
||||
/**
|
||||
* @description 2:: Paused
|
||||
*/
|
||||
/** 2:: Paused */
|
||||
readonly isPaused: boolean;
|
||||
/**
|
||||
* @description 3:: PendingResume(PendingResume)
|
||||
*/
|
||||
/** 3:: PendingResume(PendingResume) */
|
||||
readonly isPendingResume: boolean;
|
||||
/** PendingResume */
|
||||
readonly asPendingResume: PendingResume;
|
||||
}
|
||||
|
||||
@@ -54,21 +59,21 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
AuthorityWeight: AuthorityWeight;
|
||||
'Compact<AuthorityWeight>': Compact<AuthorityWeight>;
|
||||
'Option<AuthorityWeight>': Option<AuthorityWeight>;
|
||||
'Vec<AuthorityWeight>': Vector<AuthorityWeight>;
|
||||
'Vec<AuthorityWeight>': Vec<AuthorityWeight>;
|
||||
NextAuthority: NextAuthority;
|
||||
'Option<NextAuthority>': Option<NextAuthority>;
|
||||
'Vec<NextAuthority>': Vector<NextAuthority>;
|
||||
'Vec<NextAuthority>': Vec<NextAuthority>;
|
||||
PendingPause: PendingPause;
|
||||
'Option<PendingPause>': Option<PendingPause>;
|
||||
'Vec<PendingPause>': Vector<PendingPause>;
|
||||
'Vec<PendingPause>': Vec<PendingPause>;
|
||||
PendingResume: PendingResume;
|
||||
'Option<PendingResume>': Option<PendingResume>;
|
||||
'Vec<PendingResume>': Vector<PendingResume>;
|
||||
'Vec<PendingResume>': Vec<PendingResume>;
|
||||
StoredPendingChange: StoredPendingChange;
|
||||
'Option<StoredPendingChange>': Option<StoredPendingChange>;
|
||||
'Vec<StoredPendingChange>': Vector<StoredPendingChange>;
|
||||
'Vec<StoredPendingChange>': Vec<StoredPendingChange>;
|
||||
StoredState: StoredState;
|
||||
'Option<StoredState>': Option<StoredState>;
|
||||
'Vec<StoredState>': Vector<StoredState>;
|
||||
'Vec<StoredState>': Vec<StoredState>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,50 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Option, Struct, Vector } from '../../codec';
|
||||
import { Option, Struct, Vec } from '../../codec';
|
||||
import { Bytes } from '../../primitive';
|
||||
import { BlockNumber } from '../runtime/types';
|
||||
import { AuthorityId } from '../consensus/types';
|
||||
import { SessionIndex } from '../session/types';
|
||||
|
||||
/** Struct */
|
||||
export interface Heartbeat extends Struct {
|
||||
/** BlockNumber */
|
||||
readonly blockNumber: BlockNumber;
|
||||
/** OpaqueNetworkState */
|
||||
readonly networkState: OpaqueNetworkState;
|
||||
/** SessionIndex */
|
||||
readonly sessionIndex: SessionIndex;
|
||||
/** AuthorityId */
|
||||
readonly authorityId: AuthorityId;
|
||||
}
|
||||
|
||||
export interface OpaqueMultiaddr extends Bytes {}
|
||||
/** Bytes */
|
||||
export type OpaqueMultiaddr = Bytes;
|
||||
|
||||
/** Struct */
|
||||
export interface OpaqueNetworkState extends Struct {
|
||||
/** OpaquePeerId */
|
||||
readonly peerId: OpaquePeerId;
|
||||
readonly externalAddresses: Vector<OpaqueMultiaddr>;
|
||||
/** Vec<OpaqueMultiaddr> */
|
||||
readonly externalAddresses: Vec<OpaqueMultiaddr>;
|
||||
}
|
||||
|
||||
export interface OpaquePeerId extends Bytes {}
|
||||
/** Bytes */
|
||||
export type OpaquePeerId = Bytes;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
OpaqueMultiaddr: OpaqueMultiaddr;
|
||||
'Option<OpaqueMultiaddr>': Option<OpaqueMultiaddr>;
|
||||
'Vec<OpaqueMultiaddr>': Vector<OpaqueMultiaddr>;
|
||||
'Vec<OpaqueMultiaddr>': Vec<OpaqueMultiaddr>;
|
||||
OpaquePeerId: OpaquePeerId;
|
||||
'Option<OpaquePeerId>': Option<OpaquePeerId>;
|
||||
'Vec<OpaquePeerId>': Vector<OpaquePeerId>;
|
||||
'Vec<OpaquePeerId>': Vec<OpaquePeerId>;
|
||||
OpaqueNetworkState: OpaqueNetworkState;
|
||||
'Option<OpaqueNetworkState>': Option<OpaqueNetworkState>;
|
||||
'Vec<OpaqueNetworkState>': Vector<OpaqueNetworkState>;
|
||||
'Vec<OpaqueNetworkState>': Vec<OpaqueNetworkState>;
|
||||
Heartbeat: Heartbeat;
|
||||
'Option<Heartbeat>': Option<Heartbeat>;
|
||||
'Vec<Heartbeat>': Vector<Heartbeat>;
|
||||
'Vec<Heartbeat>': Vec<Heartbeat>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 { ClassOf } from '../codec/createType';
|
||||
import getTypeRegistry from '../codec/typeRegistry';
|
||||
import * as srmlTypes from './definitions';
|
||||
|
||||
@@ -14,4 +15,7 @@ export function injectDefinitions (): void {
|
||||
Object.values(srmlTypes).forEach(({ types }): void =>
|
||||
registry.register(types)
|
||||
);
|
||||
|
||||
// Here we setup the fallbacks
|
||||
ClassOf('EventRecord').Fallback = ClassOf('EventRecord0to76');
|
||||
}
|
||||
|
||||
@@ -1,261 +1,266 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { AccountId, Bytes, u32, u64 } from '../../primitive';
|
||||
import { BalanceOf, BlockNumber, Hash, Signature } from '../runtime/types';
|
||||
|
||||
/** Struct */
|
||||
export interface AttestedCandidate extends Struct {
|
||||
/** CandidateReceipt */
|
||||
readonly candidate: CandidateReceipt;
|
||||
readonly validityVotes: Vector<ValidityVote>;
|
||||
/** Vec<ValidityVote> */
|
||||
readonly validityVotes: Vec<ValidityVote>;
|
||||
}
|
||||
|
||||
export interface AuctionIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type AuctionIndex = u32;
|
||||
|
||||
type _BalanceUpload = [AccountId, u64];
|
||||
export interface BalanceUpload extends Codec, _BalanceUpload {}
|
||||
/** [AccountId, u64] & Codec */
|
||||
export type BalanceUpload = [AccountId, u64] & Codec;
|
||||
|
||||
/** Enum */
|
||||
export interface Bidder extends Enum {
|
||||
/**
|
||||
* @description 0:: New(NewBidder)
|
||||
*/
|
||||
/** 0:: New(NewBidder) */
|
||||
readonly isNew: boolean;
|
||||
/** NewBidder */
|
||||
readonly asNew: NewBidder;
|
||||
/**
|
||||
* @description 1:: Existing(ParaId)
|
||||
*/
|
||||
/** 1:: Existing(ParaId) */
|
||||
readonly isExisting: boolean;
|
||||
/** ParaId */
|
||||
readonly asExisting: ParaId;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface CandidateReceipt extends Struct {
|
||||
/** ParaId */
|
||||
readonly parachainIndex: ParaId;
|
||||
/** AccountId */
|
||||
readonly collator: AccountId;
|
||||
/** CollatorSignature */
|
||||
readonly signature: CollatorSignature;
|
||||
/** HeadData */
|
||||
readonly headData: HeadData;
|
||||
readonly balanceUploads: Vector<BalanceUpload>;
|
||||
readonly egressQueueRoots: Vector<EgressQueueRoot>;
|
||||
/** Vec<BalanceUpload> */
|
||||
readonly balanceUploads: Vec<BalanceUpload>;
|
||||
/** Vec<EgressQueueRoot> */
|
||||
readonly egressQueueRoots: Vec<EgressQueueRoot>;
|
||||
/** u64 */
|
||||
readonly fees: u64;
|
||||
/** Hash */
|
||||
readonly blockDataHash: Hash;
|
||||
}
|
||||
|
||||
export interface CollatorSignature extends Signature {}
|
||||
/** Signature */
|
||||
export type CollatorSignature = Signature;
|
||||
|
||||
type _EgressQueueRoot = [ParaId, Hash];
|
||||
export interface EgressQueueRoot extends Codec, _EgressQueueRoot {}
|
||||
/** [ParaId, Hash] & Codec */
|
||||
export type EgressQueueRoot = [ParaId, Hash] & Codec;
|
||||
|
||||
export interface HeadData extends Bytes {}
|
||||
/** Bytes */
|
||||
export type HeadData = Bytes;
|
||||
|
||||
/** Enum */
|
||||
export interface IncomingParachain extends Enum {
|
||||
/**
|
||||
* @description 0:: Unset(NewBidder)
|
||||
*/
|
||||
/** 0:: Unset(NewBidder) */
|
||||
readonly isUnset: boolean;
|
||||
/** NewBidder */
|
||||
readonly asUnset: NewBidder;
|
||||
/**
|
||||
* @description 1:: Fixed(IncomingParachainFixed)
|
||||
*/
|
||||
/** 1:: Fixed(IncomingParachainFixed) */
|
||||
readonly isFixed: boolean;
|
||||
/** IncomingParachainFixed */
|
||||
readonly asFixed: IncomingParachainFixed;
|
||||
/**
|
||||
* @description 2:: Deploy(IncomingParachainDeploy)
|
||||
*/
|
||||
/** 2:: Deploy(IncomingParachainDeploy) */
|
||||
readonly isDeploy: boolean;
|
||||
/** IncomingParachainDeploy */
|
||||
readonly asDeploy: IncomingParachainDeploy;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface IncomingParachainDeploy extends Struct {
|
||||
/** Bytes */
|
||||
readonly code: Bytes;
|
||||
/** Bytes */
|
||||
readonly initialHeadData: Bytes;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface IncomingParachainFixed extends Struct {
|
||||
/** Hash */
|
||||
readonly codeHash: Hash;
|
||||
/** Bytes */
|
||||
readonly initialHeadData: Bytes;
|
||||
}
|
||||
|
||||
export interface LeasePeriod extends BlockNumber {}
|
||||
/** BlockNumber */
|
||||
export type LeasePeriod = BlockNumber;
|
||||
|
||||
export interface LeasePeriodOf extends LeasePeriod {}
|
||||
/** LeasePeriod */
|
||||
export type LeasePeriodOf = LeasePeriod;
|
||||
|
||||
/** Struct */
|
||||
export interface NewBidder extends Struct {
|
||||
/** AccountId */
|
||||
readonly who: AccountId;
|
||||
/** SubId */
|
||||
readonly sub: SubId;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface ParachainDispatchOrigin extends Enum {
|
||||
/**
|
||||
* @description 0:: Signed
|
||||
*/
|
||||
/** 0:: Signed */
|
||||
readonly isSigned: boolean;
|
||||
/**
|
||||
* @description 1:: Parachain
|
||||
*/
|
||||
/** 1:: Parachain */
|
||||
readonly isParachain: boolean;
|
||||
}
|
||||
|
||||
export interface ParaId extends u32 {}
|
||||
/** u32 */
|
||||
export type ParaId = u32;
|
||||
|
||||
export interface ParaIdOf extends ParaId {}
|
||||
/** ParaId */
|
||||
export type ParaIdOf = ParaId;
|
||||
|
||||
/** Enum */
|
||||
export interface SlotRange extends Enum {
|
||||
/**
|
||||
* @description 0:: ZeroZero
|
||||
*/
|
||||
/** 0:: ZeroZero */
|
||||
readonly isZeroZero: boolean;
|
||||
/**
|
||||
* @description 1:: ZeroOne
|
||||
*/
|
||||
/** 1:: ZeroOne */
|
||||
readonly isZeroOne: boolean;
|
||||
/**
|
||||
* @description 2:: ZeroTwo
|
||||
*/
|
||||
/** 2:: ZeroTwo */
|
||||
readonly isZeroTwo: boolean;
|
||||
/**
|
||||
* @description 3:: ZeroThree
|
||||
*/
|
||||
/** 3:: ZeroThree */
|
||||
readonly isZeroThree: boolean;
|
||||
/**
|
||||
* @description 4:: OneOne
|
||||
*/
|
||||
/** 4:: OneOne */
|
||||
readonly isOneOne: boolean;
|
||||
/**
|
||||
* @description 5:: OneTwo
|
||||
*/
|
||||
/** 5:: OneTwo */
|
||||
readonly isOneTwo: boolean;
|
||||
/**
|
||||
* @description 6:: OneThree
|
||||
*/
|
||||
/** 6:: OneThree */
|
||||
readonly isOneThree: boolean;
|
||||
/**
|
||||
* @description 7:: TwoTwo
|
||||
*/
|
||||
/** 7:: TwoTwo */
|
||||
readonly isTwoTwo: boolean;
|
||||
/**
|
||||
* @description 8:: TwoThree
|
||||
*/
|
||||
/** 8:: TwoThree */
|
||||
readonly isTwoThree: boolean;
|
||||
/**
|
||||
* @description 9:: ThreeThree
|
||||
*/
|
||||
/** 9:: ThreeThree */
|
||||
readonly isThreeThree: boolean;
|
||||
}
|
||||
|
||||
export interface SubId extends u32 {}
|
||||
/** u32 */
|
||||
export type SubId = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface UpwardMessage extends Struct {
|
||||
/** ParachainDispatchOrigin */
|
||||
readonly origin: ParachainDispatchOrigin;
|
||||
/** Bytes */
|
||||
readonly data: Bytes;
|
||||
}
|
||||
|
||||
export interface ValidatorIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type ValidatorIndex = u32;
|
||||
|
||||
/** Enum */
|
||||
export interface ValidityAttestation extends Enum {
|
||||
/**
|
||||
* @description 0:: None
|
||||
*/
|
||||
/** 0:: None */
|
||||
readonly isNone: boolean;
|
||||
/**
|
||||
* @description 1:: Implicit(CollatorSignature)
|
||||
*/
|
||||
/** 1:: Implicit(CollatorSignature) */
|
||||
readonly isImplicit: boolean;
|
||||
/** CollatorSignature */
|
||||
readonly asImplicit: CollatorSignature;
|
||||
/**
|
||||
* @description 2:: Explicit(CollatorSignature)
|
||||
*/
|
||||
/** 2:: Explicit(CollatorSignature) */
|
||||
readonly isExplicit: boolean;
|
||||
/** CollatorSignature */
|
||||
readonly asExplicit: CollatorSignature;
|
||||
}
|
||||
|
||||
type _ValidityVote = [ValidatorIndex, ValidityAttestation];
|
||||
export interface ValidityVote extends Codec, _ValidityVote {}
|
||||
/** [ValidatorIndex, ValidityAttestation] & Codec */
|
||||
export type ValidityVote = [ValidatorIndex, ValidityAttestation] & Codec;
|
||||
|
||||
export interface WinningData extends Vector<WinningDataEntry> {}
|
||||
/** Vec<WinningDataEntry> */
|
||||
export type WinningData = Vec<WinningDataEntry>;
|
||||
|
||||
type _WinningDataEntry = [AccountId, ParaIdOf, BalanceOf];
|
||||
export interface WinningDataEntry extends Codec, _WinningDataEntry {}
|
||||
/** [AccountId, ParaIdOf, BalanceOf] & Codec */
|
||||
export type WinningDataEntry = [AccountId, ParaIdOf, BalanceOf] & Codec;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
AuctionIndex: AuctionIndex;
|
||||
'Compact<AuctionIndex>': Compact<AuctionIndex>;
|
||||
'Option<AuctionIndex>': Option<AuctionIndex>;
|
||||
'Vec<AuctionIndex>': Vector<AuctionIndex>;
|
||||
'Vec<AuctionIndex>': Vec<AuctionIndex>;
|
||||
CollatorSignature: CollatorSignature;
|
||||
'Option<CollatorSignature>': Option<CollatorSignature>;
|
||||
'Vec<CollatorSignature>': Vector<CollatorSignature>;
|
||||
'Vec<CollatorSignature>': Vec<CollatorSignature>;
|
||||
ValidityAttestation: ValidityAttestation;
|
||||
'Option<ValidityAttestation>': Option<ValidityAttestation>;
|
||||
'Vec<ValidityAttestation>': Vector<ValidityAttestation>;
|
||||
'Vec<ValidityAttestation>': Vec<ValidityAttestation>;
|
||||
ParaId: ParaId;
|
||||
'Compact<ParaId>': Compact<ParaId>;
|
||||
'Option<ParaId>': Option<ParaId>;
|
||||
'Vec<ParaId>': Vector<ParaId>;
|
||||
'Vec<ParaId>': Vec<ParaId>;
|
||||
ParaIdOf: ParaIdOf;
|
||||
'Option<ParaIdOf>': Option<ParaIdOf>;
|
||||
'Vec<ParaIdOf>': Vector<ParaIdOf>;
|
||||
'Vec<ParaIdOf>': Vec<ParaIdOf>;
|
||||
ValidatorIndex: ValidatorIndex;
|
||||
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
|
||||
'Option<ValidatorIndex>': Option<ValidatorIndex>;
|
||||
'Vec<ValidatorIndex>': Vector<ValidatorIndex>;
|
||||
'Vec<ValidatorIndex>': Vec<ValidatorIndex>;
|
||||
ValidityVote: ValidityVote;
|
||||
'Option<ValidityVote>': Option<ValidityVote>;
|
||||
'Vec<ValidityVote>': Vector<ValidityVote>;
|
||||
'Vec<ValidityVote>': Vec<ValidityVote>;
|
||||
BalanceUpload: BalanceUpload;
|
||||
'Option<BalanceUpload>': Option<BalanceUpload>;
|
||||
'Vec<BalanceUpload>': Vector<BalanceUpload>;
|
||||
'Vec<BalanceUpload>': Vec<BalanceUpload>;
|
||||
EgressQueueRoot: EgressQueueRoot;
|
||||
'Option<EgressQueueRoot>': Option<EgressQueueRoot>;
|
||||
'Vec<EgressQueueRoot>': Vector<EgressQueueRoot>;
|
||||
'Vec<EgressQueueRoot>': Vec<EgressQueueRoot>;
|
||||
HeadData: HeadData;
|
||||
'Option<HeadData>': Option<HeadData>;
|
||||
'Vec<HeadData>': Vector<HeadData>;
|
||||
'Vec<HeadData>': Vec<HeadData>;
|
||||
CandidateReceipt: CandidateReceipt;
|
||||
'Option<CandidateReceipt>': Option<CandidateReceipt>;
|
||||
'Vec<CandidateReceipt>': Vector<CandidateReceipt>;
|
||||
'Vec<CandidateReceipt>': Vec<CandidateReceipt>;
|
||||
AttestedCandidate: AttestedCandidate;
|
||||
'Option<AttestedCandidate>': Option<AttestedCandidate>;
|
||||
'Vec<AttestedCandidate>': Vector<AttestedCandidate>;
|
||||
'Vec<AttestedCandidate>': Vec<AttestedCandidate>;
|
||||
SubId: SubId;
|
||||
'Compact<SubId>': Compact<SubId>;
|
||||
'Option<SubId>': Option<SubId>;
|
||||
'Vec<SubId>': Vector<SubId>;
|
||||
'Vec<SubId>': Vec<SubId>;
|
||||
NewBidder: NewBidder;
|
||||
'Option<NewBidder>': Option<NewBidder>;
|
||||
'Vec<NewBidder>': Vector<NewBidder>;
|
||||
'Vec<NewBidder>': Vec<NewBidder>;
|
||||
Bidder: Bidder;
|
||||
'Option<Bidder>': Option<Bidder>;
|
||||
'Vec<Bidder>': Vector<Bidder>;
|
||||
'Vec<Bidder>': Vec<Bidder>;
|
||||
IncomingParachainDeploy: IncomingParachainDeploy;
|
||||
'Option<IncomingParachainDeploy>': Option<IncomingParachainDeploy>;
|
||||
'Vec<IncomingParachainDeploy>': Vector<IncomingParachainDeploy>;
|
||||
'Vec<IncomingParachainDeploy>': Vec<IncomingParachainDeploy>;
|
||||
IncomingParachainFixed: IncomingParachainFixed;
|
||||
'Option<IncomingParachainFixed>': Option<IncomingParachainFixed>;
|
||||
'Vec<IncomingParachainFixed>': Vector<IncomingParachainFixed>;
|
||||
'Vec<IncomingParachainFixed>': Vec<IncomingParachainFixed>;
|
||||
IncomingParachain: IncomingParachain;
|
||||
'Option<IncomingParachain>': Option<IncomingParachain>;
|
||||
'Vec<IncomingParachain>': Vector<IncomingParachain>;
|
||||
'Vec<IncomingParachain>': Vec<IncomingParachain>;
|
||||
LeasePeriod: LeasePeriod;
|
||||
'Option<LeasePeriod>': Option<LeasePeriod>;
|
||||
'Vec<LeasePeriod>': Vector<LeasePeriod>;
|
||||
'Vec<LeasePeriod>': Vec<LeasePeriod>;
|
||||
LeasePeriodOf: LeasePeriodOf;
|
||||
'Option<LeasePeriodOf>': Option<LeasePeriodOf>;
|
||||
'Vec<LeasePeriodOf>': Vector<LeasePeriodOf>;
|
||||
'Vec<LeasePeriodOf>': Vec<LeasePeriodOf>;
|
||||
ParachainDispatchOrigin: ParachainDispatchOrigin;
|
||||
'Option<ParachainDispatchOrigin>': Option<ParachainDispatchOrigin>;
|
||||
'Vec<ParachainDispatchOrigin>': Vector<ParachainDispatchOrigin>;
|
||||
'Vec<ParachainDispatchOrigin>': Vec<ParachainDispatchOrigin>;
|
||||
SlotRange: SlotRange;
|
||||
'Option<SlotRange>': Option<SlotRange>;
|
||||
'Vec<SlotRange>': Vector<SlotRange>;
|
||||
'Vec<SlotRange>': Vec<SlotRange>;
|
||||
UpwardMessage: UpwardMessage;
|
||||
'Option<UpwardMessage>': Option<UpwardMessage>;
|
||||
'Vec<UpwardMessage>': Vector<UpwardMessage>;
|
||||
'Vec<UpwardMessage>': Vec<UpwardMessage>;
|
||||
WinningDataEntry: WinningDataEntry;
|
||||
'Option<WinningDataEntry>': Option<WinningDataEntry>;
|
||||
'Vec<WinningDataEntry>': Vector<WinningDataEntry>;
|
||||
'Vec<WinningDataEntry>': Vec<WinningDataEntry>;
|
||||
WinningData: WinningData;
|
||||
'Option<WinningData>': Option<WinningData>;
|
||||
'Vec<WinningData>': Vector<WinningData>;
|
||||
'Vec<WinningData>': Vec<WinningData>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// 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 createType from '../../codec/createType';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('ChainProperties', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
it('decodes from a null value', (): void => {
|
||||
expect(
|
||||
[...createType('ChainProperties', null).entries()]
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('decodes from an actual object', (): void => {
|
||||
const { tokenDecimals, tokenSymbol } = createType('ChainProperties', {
|
||||
tokenDecimals: 15,
|
||||
tokenSymbol: 'BBQ'
|
||||
});
|
||||
|
||||
expect(tokenDecimals.eq(15)).toBe(true);
|
||||
expect(tokenSymbol.eq('BBQ')).toBe(true);
|
||||
});
|
||||
});
|
||||
+6
-4
@@ -2,9 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { injectDefinitions } from '../srml';
|
||||
import rpc from '../json/ExtrinsicStatus.001.json';
|
||||
import ExtrinsicStatus from './ExtrinsicStatus';
|
||||
import { ExtrinsicStatus } from './types';
|
||||
|
||||
import createType from '../../codec/createType';
|
||||
import rpc from '../../json/ExtrinsicStatus.001.json';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('ExtrinsicStatus', (): void => {
|
||||
let status: ExtrinsicStatus;
|
||||
@@ -12,7 +14,7 @@ describe('ExtrinsicStatus', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
|
||||
status = new ExtrinsicStatus(rpc.params.result);
|
||||
status = createType('ExtrinsicStatus', rpc.params.result);
|
||||
});
|
||||
|
||||
it('has the correct type', (): void => {
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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 createType from '../../codec/createType';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('KeyValueOption', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
it('exposes the properties for key/value', (): void => {
|
||||
const [key, value] = createType('KeyValueOption', [
|
||||
'0x11223344'
|
||||
]);
|
||||
|
||||
expect(key.toHex()).toEqual('0x11223344');
|
||||
expect(value.isNone).toEqual(true);
|
||||
});
|
||||
});
|
||||
+14
-6
@@ -2,21 +2,29 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import rpc from '../json/RuntimeVersion.002.json';
|
||||
import RuntimeVersion from './RuntimeVersion';
|
||||
import { RuntimeVersion } from './types';
|
||||
|
||||
import createType from '../../codec/createType';
|
||||
import rpc from '../../json/RuntimeVersion.002.json';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('RuntimeVersion', (): void => {
|
||||
const version = new RuntimeVersion(rpc.result);
|
||||
let version: RuntimeVersion;
|
||||
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
version = createType('RuntimeVersion', rpc.result);
|
||||
});
|
||||
|
||||
it('has the correct authoring', (): void => {
|
||||
expect(version.authoringVersion.toNumber()).toEqual(10);
|
||||
});
|
||||
|
||||
it('has the apis', (): void => {
|
||||
const api = version.apis[0];
|
||||
const [apiId, apiVersion] = version.apis[0];
|
||||
|
||||
expect(api.id.toHex()).toEqual('0xdf6acb689907609b');
|
||||
expect(api.version.toNumber()).toEqual(2);
|
||||
expect(apiId.toHex()).toEqual('0xdf6acb689907609b');
|
||||
expect(apiVersion.toNumber()).toEqual(2);
|
||||
});
|
||||
|
||||
it('has the correct implementation', (): void => {
|
||||
+9
-9
@@ -4,12 +4,12 @@
|
||||
|
||||
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
|
||||
import Method from '../primitive/Method';
|
||||
import events from '../json/SignedBlock.002.json';
|
||||
import immortalTxs from '../json/SignedBlock.004.immortal.json';
|
||||
import mortalTxs from '../json/SignedBlock.004.mortal.json';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import SignedBlock from './SignedBlock';
|
||||
import createType from '../../codec/createType';
|
||||
import Method from '../../primitive/Method';
|
||||
import events from '../../json/SignedBlock.002.json';
|
||||
import immortalTxs from '../../json/SignedBlock.004.immortal.json';
|
||||
import mortalTxs from '../../json/SignedBlock.004.mortal.json';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('SignedBlock', (): void => {
|
||||
beforeEach((): void => {
|
||||
@@ -18,7 +18,7 @@ describe('SignedBlock', (): void => {
|
||||
});
|
||||
|
||||
it('decodes a full block', (): void => {
|
||||
const s = new SignedBlock(events.result);
|
||||
const s = createType('SignedBlock', events.result);
|
||||
|
||||
expect(
|
||||
s.block.header.stateRoot.toString()
|
||||
@@ -38,7 +38,7 @@ describe('SignedBlock', (): void => {
|
||||
|
||||
describe('extrinsics', (): void => {
|
||||
it('can decode immortals', (): void => {
|
||||
const s = new SignedBlock(immortalTxs.result);
|
||||
const s = createType('SignedBlock', immortalTxs.result);
|
||||
const immortalTx = s.block.extrinsics[2];
|
||||
|
||||
expect(immortalTx.method.methodName).toEqual('transfer');
|
||||
@@ -46,7 +46,7 @@ describe('SignedBlock', (): void => {
|
||||
});
|
||||
|
||||
it('can decode mortals', (): void => {
|
||||
const s = new SignedBlock(mortalTxs.result);
|
||||
const s = createType('SignedBlock', mortalTxs.result);
|
||||
const mortalTx = s.block.extrinsics[2];
|
||||
|
||||
expect(mortalTx.method.methodName).toEqual('transfer');
|
||||
+12
-7
@@ -3,12 +3,17 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { createType } from '@polkadot/types';
|
||||
import json from '../json/StorageChangeSet.001.json';
|
||||
import StorageChangeSet from './StorageChangeSet';
|
||||
|
||||
import json from '../../json/StorageChangeSet.001.json';
|
||||
import { injectDefinitions } from '../';
|
||||
|
||||
describe('StorageChangeSet', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
describe('construction', (): void => {
|
||||
const set = new StorageChangeSet({
|
||||
const set = createType('StorageChangeSet', {
|
||||
block: '0x1234',
|
||||
changes: [
|
||||
['0xab', '0xcd']
|
||||
@@ -23,13 +28,13 @@ describe('StorageChangeSet', (): void => {
|
||||
|
||||
it('wraps key/value', (): void => {
|
||||
expect(
|
||||
set.changes[0].value.toString()
|
||||
set.changes[0][1].toString()
|
||||
).toEqual('0xcd');
|
||||
});
|
||||
});
|
||||
|
||||
describe('json', (): void => {
|
||||
const set = new StorageChangeSet(json.params.result);
|
||||
const set = createType('StorageChangeSet', json.params.result);
|
||||
|
||||
it('has the correct hash', (): void => {
|
||||
expect(
|
||||
@@ -39,11 +44,11 @@ describe('StorageChangeSet', (): void => {
|
||||
|
||||
it('has the changes', (): void => {
|
||||
expect(set.changes).toHaveLength(1);
|
||||
expect(set.changes[0].key.toHex()).toEqual('0x54bdbdb5e438d574dd4da05ee6131cee');
|
||||
expect(set.changes[0][0].toHex()).toEqual('0x54bdbdb5e438d574dd4da05ee6131cee');
|
||||
});
|
||||
|
||||
it('converts result data to Bytes', (): void => {
|
||||
const bytes = createType('Bytes', set.changes[0].value.unwrap());
|
||||
const bytes = createType('Bytes', set.changes[0][1].unwrap());
|
||||
|
||||
expect(bytes).toHaveLength(4452);
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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: {
|
||||
ApiId: '[u8; 8]',
|
||||
ChainProperties: {
|
||||
tokenDecimals: 'u32',
|
||||
tokenSymbol: 'Text'
|
||||
},
|
||||
Consensus: '(ConsensusEngineId, Bytes)',
|
||||
ExtrinsicStatus: {
|
||||
_enum: {
|
||||
Future: 'Null',
|
||||
Ready: 'Null',
|
||||
Finalized: 'Hash',
|
||||
Usurped: 'Hash',
|
||||
Broadcast: 'Vec<Text>',
|
||||
Dropped: 'Null',
|
||||
Invalid: 'Null'
|
||||
}
|
||||
},
|
||||
Health: {
|
||||
peers: 'u64',
|
||||
isSyncing: 'bool',
|
||||
shouldHavePeers: 'bool'
|
||||
},
|
||||
KeyValueOption: '(StorageKey, Option<StorageData>)',
|
||||
NetworkState: {
|
||||
peerId: 'Text'
|
||||
},
|
||||
PeerInfo: {
|
||||
peerId: 'Text',
|
||||
roles: 'Text',
|
||||
protocolVersion: 'u32',
|
||||
bestHash: 'Hash',
|
||||
bestNumber: 'BlockNumber'
|
||||
},
|
||||
PreRuntime: '(ConsensusEngineId, Bytes)',
|
||||
RuntimeVersionApi: '(ApiId, u32)',
|
||||
RuntimeVersion: {
|
||||
specName: 'Text',
|
||||
implName: 'Text',
|
||||
authoringVersion: 'u32',
|
||||
specVersion: 'u32',
|
||||
implVersion: 'u32',
|
||||
apis: 'Vec<RuntimeVersionApi>'
|
||||
},
|
||||
SealV0: '(u64, Signature)',
|
||||
Seal: '(ConsensusEngineId, Bytes)',
|
||||
SignedBlock: {
|
||||
block: 'Block',
|
||||
justification: 'Justification'
|
||||
},
|
||||
StorageChangeSet: {
|
||||
block: 'Hash',
|
||||
changes: 'Vec<KeyValueOption>'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { Block, Bytes, ConsensusEngineId, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive';
|
||||
import { BlockNumber, Hash, Justification, Signature, StorageData } from '../runtime/types';
|
||||
|
||||
/** Vec<u8> */
|
||||
export type ApiId = Vec<u8>;
|
||||
|
||||
/** Struct */
|
||||
export interface ChainProperties extends Struct {
|
||||
/** u32 */
|
||||
readonly tokenDecimals: u32;
|
||||
/** Text */
|
||||
readonly tokenSymbol: Text;
|
||||
}
|
||||
|
||||
/** [ConsensusEngineId, Bytes] & Codec */
|
||||
export type Consensus = [ConsensusEngineId, Bytes] & Codec;
|
||||
|
||||
/** Enum */
|
||||
export interface ExtrinsicStatus extends Enum {
|
||||
/** 0:: Future */
|
||||
readonly isFuture: boolean;
|
||||
/** 1:: Ready */
|
||||
readonly isReady: boolean;
|
||||
/** 2:: Finalized(Hash) */
|
||||
readonly isFinalized: boolean;
|
||||
/** Hash */
|
||||
readonly asFinalized: Hash;
|
||||
/** 3:: Usurped(Hash) */
|
||||
readonly isUsurped: boolean;
|
||||
/** Hash */
|
||||
readonly asUsurped: Hash;
|
||||
/** 4:: Broadcast(Vec<Text>) */
|
||||
readonly isBroadcast: boolean;
|
||||
/** Vec<Text> */
|
||||
readonly asBroadcast: Vec<Text>;
|
||||
/** 5:: Dropped */
|
||||
readonly isDropped: boolean;
|
||||
/** 6:: Invalid */
|
||||
readonly isInvalid: boolean;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface Health extends Struct {
|
||||
/** u64 */
|
||||
readonly peers: u64;
|
||||
/** bool */
|
||||
readonly isSyncing: bool;
|
||||
/** bool */
|
||||
readonly shouldHavePeers: bool;
|
||||
}
|
||||
|
||||
/** [StorageKey, Option<StorageData>] & Codec */
|
||||
export type KeyValueOption = [StorageKey, Option<StorageData>] & Codec;
|
||||
|
||||
/** Struct */
|
||||
export interface NetworkState extends Struct {
|
||||
/** Text */
|
||||
readonly peerId: Text;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface PeerInfo extends Struct {
|
||||
/** Text */
|
||||
readonly peerId: Text;
|
||||
/** Text */
|
||||
readonly roles: Text;
|
||||
/** u32 */
|
||||
readonly protocolVersion: u32;
|
||||
/** Hash */
|
||||
readonly bestHash: Hash;
|
||||
/** BlockNumber */
|
||||
readonly bestNumber: BlockNumber;
|
||||
}
|
||||
|
||||
/** [ConsensusEngineId, Bytes] & Codec */
|
||||
export type PreRuntime = [ConsensusEngineId, Bytes] & Codec;
|
||||
|
||||
/** Struct */
|
||||
export interface RuntimeVersion extends Struct {
|
||||
/** Text */
|
||||
readonly specName: Text;
|
||||
/** Text */
|
||||
readonly implName: Text;
|
||||
/** u32 */
|
||||
readonly authoringVersion: u32;
|
||||
/** u32 */
|
||||
readonly specVersion: u32;
|
||||
/** u32 */
|
||||
readonly implVersion: u32;
|
||||
/** Vec<RuntimeVersionApi> */
|
||||
readonly apis: Vec<RuntimeVersionApi>;
|
||||
}
|
||||
|
||||
/** [ApiId, u32] & Codec */
|
||||
export type RuntimeVersionApi = [ApiId, u32] & Codec;
|
||||
|
||||
/** [ConsensusEngineId, Bytes] & Codec */
|
||||
export type Seal = [ConsensusEngineId, Bytes] & Codec;
|
||||
|
||||
/** [u64, Signature] & Codec */
|
||||
export type SealV0 = [u64, Signature] & Codec;
|
||||
|
||||
/** Struct */
|
||||
export interface SignedBlock extends Struct {
|
||||
/** Block */
|
||||
readonly block: Block;
|
||||
/** Justification */
|
||||
readonly justification: Justification;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface StorageChangeSet extends Struct {
|
||||
/** Hash */
|
||||
readonly block: Hash;
|
||||
/** Vec<KeyValueOption> */
|
||||
readonly changes: Vec<KeyValueOption>;
|
||||
}
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
ApiId: ApiId;
|
||||
'Option<ApiId>': Option<ApiId>;
|
||||
'Vec<ApiId>': Vec<ApiId>;
|
||||
ChainProperties: ChainProperties;
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
Consensus: Consensus;
|
||||
'Option<Consensus>': Option<Consensus>;
|
||||
'Vec<Consensus>': Vec<Consensus>;
|
||||
ExtrinsicStatus: ExtrinsicStatus;
|
||||
'Option<ExtrinsicStatus>': Option<ExtrinsicStatus>;
|
||||
'Vec<ExtrinsicStatus>': Vec<ExtrinsicStatus>;
|
||||
Health: Health;
|
||||
'Option<Health>': Option<Health>;
|
||||
'Vec<Health>': Vec<Health>;
|
||||
KeyValueOption: KeyValueOption;
|
||||
'Option<KeyValueOption>': Option<KeyValueOption>;
|
||||
'Vec<KeyValueOption>': Vec<KeyValueOption>;
|
||||
NetworkState: NetworkState;
|
||||
'Option<NetworkState>': Option<NetworkState>;
|
||||
'Vec<NetworkState>': Vec<NetworkState>;
|
||||
PeerInfo: PeerInfo;
|
||||
'Option<PeerInfo>': Option<PeerInfo>;
|
||||
'Vec<PeerInfo>': Vec<PeerInfo>;
|
||||
PreRuntime: PreRuntime;
|
||||
'Option<PreRuntime>': Option<PreRuntime>;
|
||||
'Vec<PreRuntime>': Vec<PreRuntime>;
|
||||
RuntimeVersionApi: RuntimeVersionApi;
|
||||
'Option<RuntimeVersionApi>': Option<RuntimeVersionApi>;
|
||||
'Vec<RuntimeVersionApi>': Vec<RuntimeVersionApi>;
|
||||
RuntimeVersion: RuntimeVersion;
|
||||
'Option<RuntimeVersion>': Option<RuntimeVersion>;
|
||||
'Vec<RuntimeVersion>': Vec<RuntimeVersion>;
|
||||
SealV0: SealV0;
|
||||
'Option<SealV0>': Option<SealV0>;
|
||||
'Vec<SealV0>': Vec<SealV0>;
|
||||
Seal: Seal;
|
||||
'Option<Seal>': Option<Seal>;
|
||||
'Vec<Seal>': Vec<Seal>;
|
||||
SignedBlock: SignedBlock;
|
||||
'Option<SignedBlock>': Option<SignedBlock>;
|
||||
'Vec<SignedBlock>': Vec<SignedBlock>;
|
||||
StorageChangeSet: StorageChangeSet;
|
||||
'Option<StorageChangeSet>': Option<StorageChangeSet>;
|
||||
'Vec<StorageChangeSet>': Vec<StorageChangeSet>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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 { KeyValue } from './types';
|
||||
|
||||
import createType from '../../codec/createType';
|
||||
import { injectDefinitions } from '..';
|
||||
|
||||
describe('KeyValue', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
it('decodes KeyValue from u8a', (): void => {
|
||||
expect(
|
||||
createType('KeyValue', Uint8Array.from([
|
||||
4 << 2,
|
||||
0x11, 0x22, 0x33, 0x44,
|
||||
9 << 2,
|
||||
0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
|
||||
])).toJSON()
|
||||
).toEqual(['0x11223344', '0x998877665544332211']);
|
||||
});
|
||||
|
||||
it('encodes KeyValue from JSON', (): void => {
|
||||
expect(
|
||||
createType('KeyValue', ['0x11223344', '0x998877665544332211']).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
4 << 2,
|
||||
0x11, 0x22, 0x33, 0x44,
|
||||
9 << 2,
|
||||
0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('exposes the properties for key/value', (): void => {
|
||||
const [key, value] = createType<KeyValue>('KeyValue', ['0x11223344', '0x998877665544332211']);
|
||||
|
||||
expect(key.toHex()).toEqual('0x11223344');
|
||||
expect(value.toHex()).toEqual('0x998877665544332211');
|
||||
});
|
||||
});
|
||||
@@ -15,12 +15,15 @@ export default {
|
||||
Index: 'u64',
|
||||
Perbill: 'u32',
|
||||
Permill: 'u32',
|
||||
Phantom: 'Null',
|
||||
SessionKeys: {
|
||||
ed25519: 'AccountId'
|
||||
},
|
||||
Signature: 'H512',
|
||||
Ed25519Signature: 'Signature',
|
||||
Sr25519Signature: 'Signature',
|
||||
StorageData: 'Bytes',
|
||||
KeyValue: '(StorageKey, StorageData)',
|
||||
ValidatorId: 'AccountId',
|
||||
Weight: 'u32',
|
||||
WeightMultiplier: 'Fixed64'
|
||||
|
||||
@@ -1,110 +1,146 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Option, Struct, Vector } from '../../codec';
|
||||
import { AccountId, Bytes, Fixed64, H256, H512, u128, u32, u64, u8 } from '../../primitive';
|
||||
import { Codec } from '../../types';
|
||||
import { Compact, Option, Struct, Vec } from '../../codec';
|
||||
import { AccountId, Bytes, Fixed64, H256, H512, Null, StorageKey, u128, u32, u64, u8 } from '../../primitive';
|
||||
|
||||
export interface AccountIdOf extends AccountId {}
|
||||
/** AccountId */
|
||||
export type AccountIdOf = AccountId;
|
||||
|
||||
export interface Balance extends u128 {}
|
||||
/** u128 */
|
||||
export type Balance = u128;
|
||||
|
||||
export interface BalanceOf extends Balance {}
|
||||
/** Balance */
|
||||
export type BalanceOf = Balance;
|
||||
|
||||
export interface BlockNumber extends u64 {}
|
||||
/** u64 */
|
||||
export type BlockNumber = u64;
|
||||
|
||||
export interface Ed25519Signature extends Signature {}
|
||||
/** Signature */
|
||||
export type Ed25519Signature = Signature;
|
||||
|
||||
export interface Hash extends H256 {}
|
||||
/** H256 */
|
||||
export type Hash = H256;
|
||||
|
||||
export interface Index extends u64 {}
|
||||
/** u64 */
|
||||
export type Index = u64;
|
||||
|
||||
export interface Justification extends Bytes {}
|
||||
/** Bytes */
|
||||
export type Justification = Bytes;
|
||||
|
||||
export interface KeyTypeId extends u32 {}
|
||||
/** u32 */
|
||||
export type KeyTypeId = u32;
|
||||
|
||||
export interface LockIdentifier extends Vector<u8> {}
|
||||
/** [StorageKey, StorageData] & Codec */
|
||||
export type KeyValue = [StorageKey, StorageData] & Codec;
|
||||
|
||||
export interface Perbill extends u32 {}
|
||||
/** Vec<u8> */
|
||||
export type LockIdentifier = Vec<u8>;
|
||||
|
||||
export interface Permill extends u32 {}
|
||||
/** u32 */
|
||||
export type Perbill = u32;
|
||||
|
||||
/** u32 */
|
||||
export type Permill = u32;
|
||||
|
||||
/** Null */
|
||||
export type Phantom = Null;
|
||||
|
||||
/** Struct */
|
||||
export interface SessionKeys extends Struct {
|
||||
/** AccountId */
|
||||
readonly ed25519: AccountId;
|
||||
}
|
||||
|
||||
export interface Signature extends H512 {}
|
||||
/** H512 */
|
||||
export type Signature = H512;
|
||||
|
||||
export interface Sr25519Signature extends Signature {}
|
||||
/** Signature */
|
||||
export type Sr25519Signature = Signature;
|
||||
|
||||
export interface ValidatorId extends AccountId {}
|
||||
/** Bytes */
|
||||
export type StorageData = Bytes;
|
||||
|
||||
export interface Weight extends u32 {}
|
||||
/** AccountId */
|
||||
export type ValidatorId = AccountId;
|
||||
|
||||
export interface WeightMultiplier extends Fixed64 {}
|
||||
/** u32 */
|
||||
export type Weight = u32;
|
||||
|
||||
/** Fixed64 */
|
||||
export type WeightMultiplier = Fixed64;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
AccountIdOf: AccountIdOf;
|
||||
'Option<AccountIdOf>': Option<AccountIdOf>;
|
||||
'Vec<AccountIdOf>': Vector<AccountIdOf>;
|
||||
'Vec<AccountIdOf>': Vec<AccountIdOf>;
|
||||
Balance: Balance;
|
||||
'Compact<Balance>': Compact<Balance>;
|
||||
'Option<Balance>': Option<Balance>;
|
||||
'Vec<Balance>': Vector<Balance>;
|
||||
'Vec<Balance>': Vec<Balance>;
|
||||
BalanceOf: BalanceOf;
|
||||
'Option<BalanceOf>': Option<BalanceOf>;
|
||||
'Vec<BalanceOf>': Vector<BalanceOf>;
|
||||
'Vec<BalanceOf>': Vec<BalanceOf>;
|
||||
BlockNumber: BlockNumber;
|
||||
'Compact<BlockNumber>': Compact<BlockNumber>;
|
||||
'Option<BlockNumber>': Option<BlockNumber>;
|
||||
'Vec<BlockNumber>': Vector<BlockNumber>;
|
||||
'Vec<BlockNumber>': Vec<BlockNumber>;
|
||||
Hash: Hash;
|
||||
'Option<Hash>': Option<Hash>;
|
||||
'Vec<Hash>': Vector<Hash>;
|
||||
'Vec<Hash>': Vec<Hash>;
|
||||
Justification: Justification;
|
||||
'Option<Justification>': Option<Justification>;
|
||||
'Vec<Justification>': Vector<Justification>;
|
||||
'Vec<Justification>': Vec<Justification>;
|
||||
KeyTypeId: KeyTypeId;
|
||||
'Compact<KeyTypeId>': Compact<KeyTypeId>;
|
||||
'Option<KeyTypeId>': Option<KeyTypeId>;
|
||||
'Vec<KeyTypeId>': Vector<KeyTypeId>;
|
||||
'Vec<KeyTypeId>': Vec<KeyTypeId>;
|
||||
LockIdentifier: LockIdentifier;
|
||||
'Option<LockIdentifier>': Option<LockIdentifier>;
|
||||
'Vec<LockIdentifier>': Vector<LockIdentifier>;
|
||||
'Vec<LockIdentifier>': Vec<LockIdentifier>;
|
||||
Index: Index;
|
||||
'Compact<Index>': Compact<Index>;
|
||||
'Option<Index>': Option<Index>;
|
||||
'Vec<Index>': Vector<Index>;
|
||||
'Vec<Index>': Vec<Index>;
|
||||
Perbill: Perbill;
|
||||
'Compact<Perbill>': Compact<Perbill>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Vec<Perbill>': Vector<Perbill>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
Permill: Permill;
|
||||
'Compact<Permill>': Compact<Permill>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Vec<Permill>': Vector<Permill>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
Phantom: Phantom;
|
||||
'Option<Phantom>': Option<Phantom>;
|
||||
'Vec<Phantom>': Vec<Phantom>;
|
||||
SessionKeys: SessionKeys;
|
||||
'Option<SessionKeys>': Option<SessionKeys>;
|
||||
'Vec<SessionKeys>': Vector<SessionKeys>;
|
||||
'Vec<SessionKeys>': Vec<SessionKeys>;
|
||||
Signature: Signature;
|
||||
'Option<Signature>': Option<Signature>;
|
||||
'Vec<Signature>': Vector<Signature>;
|
||||
'Vec<Signature>': Vec<Signature>;
|
||||
Ed25519Signature: Ed25519Signature;
|
||||
'Option<Ed25519Signature>': Option<Ed25519Signature>;
|
||||
'Vec<Ed25519Signature>': Vector<Ed25519Signature>;
|
||||
'Vec<Ed25519Signature>': Vec<Ed25519Signature>;
|
||||
Sr25519Signature: Sr25519Signature;
|
||||
'Option<Sr25519Signature>': Option<Sr25519Signature>;
|
||||
'Vec<Sr25519Signature>': Vector<Sr25519Signature>;
|
||||
'Vec<Sr25519Signature>': Vec<Sr25519Signature>;
|
||||
StorageData: StorageData;
|
||||
'Option<StorageData>': Option<StorageData>;
|
||||
'Vec<StorageData>': Vec<StorageData>;
|
||||
KeyValue: KeyValue;
|
||||
'Option<KeyValue>': Option<KeyValue>;
|
||||
'Vec<KeyValue>': Vec<KeyValue>;
|
||||
ValidatorId: ValidatorId;
|
||||
'Option<ValidatorId>': Option<ValidatorId>;
|
||||
'Vec<ValidatorId>': Vector<ValidatorId>;
|
||||
'Vec<ValidatorId>': Vec<ValidatorId>;
|
||||
Weight: Weight;
|
||||
'Compact<Weight>': Compact<Weight>;
|
||||
'Option<Weight>': Option<Weight>;
|
||||
'Vec<Weight>': Vector<Weight>;
|
||||
'Vec<Weight>': Vec<Weight>;
|
||||
WeightMultiplier: WeightMultiplier;
|
||||
'Compact<WeightMultiplier>': Compact<WeightMultiplier>;
|
||||
'Option<WeightMultiplier>': Option<WeightMultiplier>;
|
||||
'Vec<WeightMultiplier>': Vector<WeightMultiplier>;
|
||||
'Vec<WeightMultiplier>': Vec<WeightMultiplier>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Option, Vector } from '../../codec';
|
||||
import { Compact, Option, Vec } from '../../codec';
|
||||
import { u32 } from '../../primitive';
|
||||
import { SessionKeys } from '../runtime/types';
|
||||
|
||||
export interface Keys extends SessionKeys {}
|
||||
/** SessionKeys */
|
||||
export type Keys = SessionKeys;
|
||||
|
||||
export interface SessionIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type SessionIndex = u32;
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
SessionIndex: SessionIndex;
|
||||
'Compact<SessionIndex>': Compact<SessionIndex>;
|
||||
'Option<SessionIndex>': Option<SessionIndex>;
|
||||
'Vec<SessionIndex>': Vector<SessionIndex>;
|
||||
'Vec<SessionIndex>': Vec<SessionIndex>;
|
||||
Keys: Keys;
|
||||
'Option<Keys>': Option<Keys>;
|
||||
'Vec<Keys>': Vector<Keys>;
|
||||
'Vec<Keys>': Vec<Keys>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export default {
|
||||
own: 'Compact<Balance>',
|
||||
others: 'Vec<IndividualExposure>'
|
||||
},
|
||||
MomentOf: 'Moment',
|
||||
RewardDestination: {
|
||||
_enum: [
|
||||
'Staked',
|
||||
|
||||
@@ -1,57 +1,76 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Compact, Enum, Option, Struct, Vector } from '../../codec';
|
||||
import { AccountId, u32 } from '../../primitive';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { AccountId, Moment, u32 } from '../../primitive';
|
||||
import { Balance, BlockNumber } from '../runtime/types';
|
||||
|
||||
export interface EraIndex extends u32 {}
|
||||
/** u32 */
|
||||
export type EraIndex = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface EraRewards extends Struct {
|
||||
/** u32 */
|
||||
readonly total: u32;
|
||||
readonly rewards: Vector<u32>;
|
||||
/** Vec<u32> */
|
||||
readonly rewards: Vec<u32>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface Exposure extends Struct {
|
||||
/** Compact<Balance> */
|
||||
readonly total: Compact<Balance>;
|
||||
/** Compact<Balance> */
|
||||
readonly own: Compact<Balance>;
|
||||
readonly others: Vector<IndividualExposure>;
|
||||
/** Vec<IndividualExposure> */
|
||||
readonly others: Vec<IndividualExposure>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface IndividualExposure extends Struct {
|
||||
/** AccountId */
|
||||
readonly who: AccountId;
|
||||
/** Compact<Balance> */
|
||||
readonly value: Compact<Balance>;
|
||||
}
|
||||
|
||||
/** Moment */
|
||||
export type MomentOf = Moment;
|
||||
|
||||
/** Enum */
|
||||
export interface RewardDestination extends Enum {
|
||||
/**
|
||||
* @description 0:: Staked
|
||||
*/
|
||||
/** 0:: Staked */
|
||||
readonly isStaked: boolean;
|
||||
/**
|
||||
* @description 1:: Stash
|
||||
*/
|
||||
/** 1:: Stash */
|
||||
readonly isStash: boolean;
|
||||
/**
|
||||
* @description 2:: Controller
|
||||
*/
|
||||
/** 2:: Controller */
|
||||
readonly isController: boolean;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface StakingLedger extends Struct {
|
||||
/** AccountId */
|
||||
readonly stash: AccountId;
|
||||
/** Compact<Balance> */
|
||||
readonly total: Compact<Balance>;
|
||||
/** Compact<Balance> */
|
||||
readonly active: Compact<Balance>;
|
||||
readonly unlocking: Vector<UnlockChunk>;
|
||||
/** Vec<UnlockChunk> */
|
||||
readonly unlocking: Vec<UnlockChunk>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface UnlockChunk extends Struct {
|
||||
/** Compact<Balance> */
|
||||
readonly value: Compact<Balance>;
|
||||
/** Compact<BlockNumber> */
|
||||
readonly era: Compact<BlockNumber>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface ValidatorPrefs extends Struct {
|
||||
/** Compact<u32> */
|
||||
readonly unstakeThreshold: Compact<u32>;
|
||||
/** Compact<Balance> */
|
||||
readonly validatorPayment: Compact<Balance>;
|
||||
}
|
||||
|
||||
@@ -60,27 +79,30 @@ declare module '@polkadot/types/interfaceRegistry' {
|
||||
EraIndex: EraIndex;
|
||||
'Compact<EraIndex>': Compact<EraIndex>;
|
||||
'Option<EraIndex>': Option<EraIndex>;
|
||||
'Vec<EraIndex>': Vector<EraIndex>;
|
||||
'Vec<EraIndex>': Vec<EraIndex>;
|
||||
EraRewards: EraRewards;
|
||||
'Option<EraRewards>': Option<EraRewards>;
|
||||
'Vec<EraRewards>': Vector<EraRewards>;
|
||||
'Vec<EraRewards>': Vec<EraRewards>;
|
||||
IndividualExposure: IndividualExposure;
|
||||
'Option<IndividualExposure>': Option<IndividualExposure>;
|
||||
'Vec<IndividualExposure>': Vector<IndividualExposure>;
|
||||
'Vec<IndividualExposure>': Vec<IndividualExposure>;
|
||||
Exposure: Exposure;
|
||||
'Option<Exposure>': Option<Exposure>;
|
||||
'Vec<Exposure>': Vector<Exposure>;
|
||||
'Vec<Exposure>': Vec<Exposure>;
|
||||
MomentOf: MomentOf;
|
||||
'Option<MomentOf>': Option<MomentOf>;
|
||||
'Vec<MomentOf>': Vec<MomentOf>;
|
||||
RewardDestination: RewardDestination;
|
||||
'Option<RewardDestination>': Option<RewardDestination>;
|
||||
'Vec<RewardDestination>': Vector<RewardDestination>;
|
||||
'Vec<RewardDestination>': Vec<RewardDestination>;
|
||||
UnlockChunk: UnlockChunk;
|
||||
'Option<UnlockChunk>': Option<UnlockChunk>;
|
||||
'Vec<UnlockChunk>': Vector<UnlockChunk>;
|
||||
'Vec<UnlockChunk>': Vec<UnlockChunk>;
|
||||
StakingLedger: StakingLedger;
|
||||
'Option<StakingLedger>': Option<StakingLedger>;
|
||||
'Vec<StakingLedger>': Vector<StakingLedger>;
|
||||
'Vec<StakingLedger>': Vec<StakingLedger>;
|
||||
ValidatorPrefs: ValidatorPrefs;
|
||||
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
|
||||
'Vec<ValidatorPrefs>': Vector<ValidatorPrefs>;
|
||||
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-15
@@ -2,29 +2,32 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import createType from '../codec/createType';
|
||||
import Vector from '../codec/Vector';
|
||||
import json1 from '../json/EventRecord.001.json';
|
||||
import json3 from '../json/EventRecord.003.json';
|
||||
import { injectDefinitions } from '../srml';
|
||||
import Metadata from '../Metadata';
|
||||
import metadataV0 from '../Metadata/v0/static';
|
||||
import metadata from '../Metadata/static';
|
||||
import Event from './Event';
|
||||
import EventRecord from './EventRecord';
|
||||
import { EventRecord } from './types';
|
||||
|
||||
import createType from '../../codec/createType';
|
||||
import Vec from '../../codec/Vec';
|
||||
import json1 from '../../json/EventRecord.001.json';
|
||||
import json3 from '../../json/EventRecord.003.json';
|
||||
import { injectDefinitions } from '..';
|
||||
import Metadata from '../../Metadata';
|
||||
import metadataV0 from '../../Metadata/v0/static';
|
||||
import metadata from '../../Metadata/static';
|
||||
import Event from '../../primitive/Event';
|
||||
|
||||
describe('EventRecord', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
});
|
||||
|
||||
describe('EventRecord_0_76', (): void => {
|
||||
beforeEach((): void => {
|
||||
injectDefinitions();
|
||||
|
||||
Event.injectMetadata(
|
||||
new Metadata(metadataV0)
|
||||
);
|
||||
});
|
||||
|
||||
it('decodes correctly', (): void => {
|
||||
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1]) as any;
|
||||
const records: Vec<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1]) as any;
|
||||
const er = records[0];
|
||||
|
||||
expect(er.phase.type).toEqual('ApplyExtrinsic');
|
||||
@@ -41,7 +44,7 @@ describe('EventRecord', (): void => {
|
||||
});
|
||||
|
||||
it('decodes older eventrecord correctly', (): void => {
|
||||
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1], true) as any;
|
||||
const records: Vec<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1], true) as any;
|
||||
const er = records[0];
|
||||
|
||||
expect(er.phase.type).toEqual('ApplyExtrinsic');
|
||||
@@ -49,7 +52,7 @@ describe('EventRecord', (): void => {
|
||||
|
||||
it('decodes eventrecord with topics correctly', (): void => {
|
||||
const hex = json3.params.result.changes[0][1];
|
||||
const records: Vector<EventRecord> = createType('Vec<EventRecord>', hex, true) as any;
|
||||
const records: Vec<EventRecord> = createType('Vec<EventRecord>', hex, true) as any;
|
||||
const er = records[0];
|
||||
|
||||
expect(er.phase.type).toEqual('ApplyExtrinsic');
|
||||
@@ -4,6 +4,25 @@
|
||||
|
||||
export default {
|
||||
types: {
|
||||
Key: 'Bytes'
|
||||
DigestOf: 'Digest',
|
||||
EventId: '[u8; 2]',
|
||||
EventIndex: 'u32',
|
||||
Key: 'Bytes',
|
||||
Phase: {
|
||||
_enum: {
|
||||
ApplyExtrinsic: 'u32',
|
||||
Finalization: 'Null'
|
||||
}
|
||||
},
|
||||
EventRecord0to76: {
|
||||
phase: 'Phase',
|
||||
event: 'Event'
|
||||
},
|
||||
// Fallback in injectDefinitions
|
||||
EventRecord: {
|
||||
phase: 'Phase',
|
||||
event: 'Event',
|
||||
topics: 'Vec<Hash>'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,15 +1,72 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Auto-generated via `yarn build:srmlTs`, do not edit
|
||||
|
||||
import { Option, Vector } from '../../codec';
|
||||
import { Bytes } from '../../primitive';
|
||||
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
|
||||
import { Bytes, Digest, Event, u32, u8 } from '../../primitive';
|
||||
import { Hash } from '../runtime/types';
|
||||
|
||||
export interface Key extends Bytes {}
|
||||
/** Digest */
|
||||
export type DigestOf = Digest;
|
||||
|
||||
/** Vec<u8> */
|
||||
export type EventId = Vec<u8>;
|
||||
|
||||
/** u32 */
|
||||
export type EventIndex = u32;
|
||||
|
||||
/** Struct */
|
||||
export interface EventRecord extends Struct {
|
||||
/** Phase */
|
||||
readonly phase: Phase;
|
||||
/** Event */
|
||||
readonly event: Event;
|
||||
/** Vec<Hash> */
|
||||
readonly topics: Vec<Hash>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface EventRecord0to76 extends Struct {
|
||||
/** Phase */
|
||||
readonly phase: Phase;
|
||||
/** Event */
|
||||
readonly event: Event;
|
||||
}
|
||||
|
||||
/** Bytes */
|
||||
export type Key = Bytes;
|
||||
|
||||
/** Enum */
|
||||
export interface Phase extends Enum {
|
||||
/** 0:: ApplyExtrinsic(u32) */
|
||||
readonly isApplyExtrinsic: boolean;
|
||||
/** u32 */
|
||||
readonly asApplyExtrinsic: u32;
|
||||
/** 1:: Finalization */
|
||||
readonly isFinalization: boolean;
|
||||
}
|
||||
|
||||
declare module '@polkadot/types/interfaceRegistry' {
|
||||
export interface InterfaceRegistry {
|
||||
DigestOf: DigestOf;
|
||||
'Option<DigestOf>': Option<DigestOf>;
|
||||
'Vec<DigestOf>': Vec<DigestOf>;
|
||||
EventId: EventId;
|
||||
'Option<EventId>': Option<EventId>;
|
||||
'Vec<EventId>': Vec<EventId>;
|
||||
EventIndex: EventIndex;
|
||||
'Compact<EventIndex>': Compact<EventIndex>;
|
||||
'Option<EventIndex>': Option<EventIndex>;
|
||||
'Vec<EventIndex>': Vec<EventIndex>;
|
||||
Key: Key;
|
||||
'Option<Key>': Option<Key>;
|
||||
'Vec<Key>': Vector<Key>;
|
||||
'Vec<Key>': Vec<Key>;
|
||||
Phase: Phase;
|
||||
'Option<Phase>': Option<Phase>;
|
||||
'Vec<Phase>': Vec<Phase>;
|
||||
EventRecord0to76: EventRecord0to76;
|
||||
'Option<EventRecord0to76>': Option<EventRecord0to76>;
|
||||
'Vec<EventRecord0to76>': Vec<EventRecord0to76>;
|
||||
EventRecord: EventRecord;
|
||||
'Option<EventRecord>': Option<EventRecord>;
|
||||
'Vec<EventRecord>': Vec<EventRecord>;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user