Moment as definition, u64 (#1210)

* Moment as definition, u64

* Move Signature (just above extrinsic/block)

* Ordering

* Vec<u8> === Bytes, re-introduce injected type checks
This commit is contained in:
Jaco Greeff
2019-07-27 10:57:06 +02:00
committed by GitHub
parent d516e9eefc
commit 3db898d104
19 changed files with 243 additions and 194 deletions
@@ -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 { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../codec/types';
import { isUndefined } from '@polkadot/util';
import { getTypeDef, TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../codec/createType';
import { getTypeDef } from '../../codec/createType';
import flattenUniq from './flattenUniq';
import { getTypeRegistry } from '../../codec';
+1 -1
View File
@@ -7,7 +7,7 @@ import '../injector';
import BN from 'bn.js';
import createType, { ClassOf } from '../codec/createType';
import Moment from '../primitive/Moment';
import Moment from './Date';
import U32 from '../primitive/U32';
import Compact from './Compact';
import UInt from './UInt';
+3 -3
View File
@@ -8,14 +8,14 @@ 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 { UIntBitLength } from './AbstractInt';
import CodecDate from './Date';
import UInt from './UInt';
import Base from './Base';
// List of codec types that are compact-encodable
export const COMPACT_ENCODABLE = [UInt, Moment];
export type CompactEncodable = UInt | Moment; // FIXME is there a way to do it not-manually from the array?
export const COMPACT_ENCODABLE = [UInt, CodecDate];
export type CompactEncodable = UInt | CodecDate; // FIXME is there a way to do it not-manually from the array?
/**
* @name Compact
@@ -5,18 +5,18 @@
import BN from 'bn.js';
import { CodecTo } from '../types';
import Moment from './Moment';
import U64 from './U64';
import CodecDate from './Date';
import U64 from '../primitive/U64';
describe('Moment', (): void => {
describe('Date', (): void => {
describe('decode', (): void => {
const testDecode = (type: string, input: Date | Moment | U64 | number, expected: string | number, toJSON: boolean = false): void =>
const testDecode = (type: string, input: Date | CodecDate | U64 | number, expected: string | number, toJSON: boolean = false): void =>
it(`can decode from ${type}`, (): void => {
expect(new Moment(input)[toJSON ? 'toJSON' : 'toISOString']()).toBe(expected);
expect(new CodecDate(input)[toJSON ? 'toJSON' : 'toISOString']()).toBe(expected);
});
testDecode('Date', new Date(1537968546280), '2018-09-26T13:29:06.280Z');
testDecode('Moment', new Moment(1234), 1234, true);
testDecode('CodecDate', new CodecDate(1234), 1234, true);
testDecode('number', 1234, 1234, true);
testDecode('U64', new U64(69), 69, true);
});
@@ -24,7 +24,7 @@ describe('Moment', (): void => {
describe('encode', (): void => {
const testEncode = (to: 'toBn' | 'toISOString' | 'toNumber' | CodecTo, expected: BN | number | string | Uint8Array): void =>
it(`can encode ${to}`, (): void => {
expect(new Moment(421)[to]()).toEqual(expected);
expect(new CodecDate(421)[to]()).toEqual(expected);
});
testEncode('toBn', new BN(421));
@@ -36,7 +36,7 @@ describe('Moment', (): void => {
it(`can encode toString`, (): void => {
expect(
new Moment(421)
new CodecDate(421)
.toString()
.startsWith('Thu Jan 01 1970') // The time depends on the timezone this test is run in
).toBe(true);
@@ -44,24 +44,24 @@ describe('Moment', (): void => {
it('encodes default BE hex', (): void => {
expect(
new Moment(3).toHex()
new CodecDate(3).toHex()
).toEqual('0x0000000000000003');
});
it('encodes options LE hex', (): void => {
expect(
new Moment(3).toHex(true)
new CodecDate(3).toHex(true)
).toEqual('0x0300000000000000');
});
});
describe('utils', (): void => {
it('compares values', (): void => {
expect(new Moment(123).eq(123)).toBe(true);
expect(new CodecDate(123).eq(123)).toBe(true);
});
it('compares values (non-match)', (): void => {
expect(new Moment(123).eq(456)).toBe(false);
expect(new CodecDate(123).eq(456)).toBe(false);
});
});
});
@@ -8,13 +8,13 @@ import BN from 'bn.js';
import { bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/util';
import { blake2AsU8a } from '@polkadot/util-crypto';
import createType from '../codec/createType';
import { UIntBitLength } from '../codec/AbstractInt';
import createType from './createType';
import { UIntBitLength } from './AbstractInt';
const BITLENGTH: UIntBitLength = 64;
/**
* @name Moment
* @name Date
* @description
* A wrapper around seconds/timestamps. Internally the representation only has
* second precicion (aligning with Rust), so any numbers passed an/out are always
@@ -23,18 +23,18 @@ const BITLENGTH: UIntBitLength = 64;
* and has all the methods available that are applicable to any `Date`
* @noInheritDoc
*/
export default class Moment extends Date implements Codec {
export default class CodecDate extends Date implements Codec {
protected raw: Date; // FIXME Remove this once we convert all types out of Base
public constructor (value: Moment | Date | AnyNumber = 0) {
public constructor (value: CodecDate | Date | AnyNumber = 0) {
super(
Moment.decodeMoment(value)
CodecDate.decodeDate(value)
);
this.raw = this;
}
public static decodeMoment (value: Moment | Date | AnyNumber): Date {
public static decodeDate (value: CodecDate | Date | AnyNumber): Date {
if (value instanceof Date) {
return value;
} else if (isU8a(value)) {
@@ -73,7 +73,7 @@ export default class Moment extends Date implements Codec {
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: any): boolean {
return Moment.decodeMoment(other).getTime() === this.getTime();
return CodecDate.decodeDate(other).getTime() === this.getTime();
}
/**
+9 -1
View File
@@ -5,8 +5,9 @@
import '../injector';
import { Codec, Constructor } from '../types';
import { TypeDef, TypeDefInfo } from './types';
import createType, { TypeDef, TypeDefInfo, createClass, createTypeUnsafe, getTypeClass, getTypeDef, typeSplit, ClassOf } from './createType';
import createType, { createClass, createTypeUnsafe, getTypeClass, getTypeDef, typeSplit, ClassOf } from './createType';
import CodecSet from './Set';
describe('typeSplit', (): void => {
@@ -220,6 +221,13 @@ describe('createClass', (): void => {
expect(a).toBe(b);
});
it('should return equivalents for Bytes & Vec<u8>', (): void => {
const a = createClass('Vec<u8>');
const b = createClass('Bytes');
expect(a).toBe(b);
});
});
describe('createType', (): void => {
+10 -32
View File
@@ -2,11 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from './types';
import memoizee from 'memoizee';
import { assert } from '@polkadot/util';
import { InterfaceRegistry } from '../interfaceRegistry';
import { Codec, Constructor } from '../types';
import Bytes from '../primitive/Bytes';
import Null from '../primitive/Null';
import Compact from './Compact';
import Enum from './Enum';
@@ -24,36 +27,6 @@ import getRegistry from './typeRegistry';
// Type which says: if `K` is in the InterfaceRegistry, then return InterfaceRegistry[K], else fallback to T
type FromReg<T extends Codec, K extends string> = K extends keyof InterfaceRegistry ? InterfaceRegistry[K] : T
export enum TypeDefInfo {
Compact,
DoubleMap,
Enum,
Linkage,
Option,
Plain,
Set,
Struct,
Tuple,
Vec,
VecFixed,
// anything not full supported (keep this as the last entry)
Null
}
export interface TypeDefExtVecFixed {
length: number;
type: string;
}
export interface TypeDef {
info: TypeDefInfo;
index?: number;
ext?: TypeDefExtVecFixed; // add additional here as required
name?: string;
type: string;
sub?: TypeDef | TypeDef[];
}
// safely split a string on ', ' while taking care of any nested occurences
export function typeSplit (type: string): string[] {
let cDepth = 0; // compact/doublemap/linkedmap/option/vector depth
@@ -292,8 +265,13 @@ export function getTypeClass<T extends Codec = Codec> (value: TypeDef, Fallback?
case TypeDefInfo.Vec:
assert(value.sub && !Array.isArray(value.sub), 'Expected subtype for Vec');
return Vec.with(
getTypeClass<Codec>(value.sub as TypeDef)
const vsub = value.sub as TypeDef;
return (
vsub.type === 'u8'
? Bytes
: Vec.with(getTypeClass<Codec>(vsub))
) as unknown as Constructor<T>;
case TypeDefInfo.VecFixed:
+4 -3
View File
@@ -9,19 +9,20 @@
// These are the base codec types, generally used for construction
export { default as Compact } from './Compact';
// export { default as Date } from './Date';
export { default as Enum } from './Enum';
export { default as EnumType } from './EnumType';
export { default as Option } from './Option';
export { default as Set } from './Set';
export { default as Struct } from './Struct';
export { default as StructAny } from './StructAny';
// export { default as StructAny } from './StructAny';
export { default as Tuple } from './Tuple';
export { default as Vec, default as Vector } from './Vec';
export { default as Vec } from './Vec';
// Convenience base classes, used as "anything of this type" bases
export { default as U8a } from './U8a';
export { default as UInt } from './UInt';
// Type management helper functions
export { default as createType, createClass, getTypeClass, getTypeDef, ClassOf, TypeDef, TypeDefInfo } from './createType';
export { default as createType, createClass, getTypeClass, getTypeDef, ClassOf } from './createType';
export { default as getTypeRegistry } from './typeRegistry';
+33
View File
@@ -0,0 +1,33 @@
// 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 enum TypeDefInfo {
Compact,
DoubleMap,
Enum,
Linkage,
Option,
Plain,
Set,
Struct,
Tuple,
Vec,
VecFixed,
// anything not fully supported (keep this as the last entry)
Null
}
export interface TypeDefExtVecFixed {
length: number;
type: string;
}
export interface TypeDef {
info: TypeDefInfo;
index?: number;
ext?: TypeDefExtVecFixed; // add additional here as required
name?: string;
type: string;
sub?: TypeDef | TypeDef[];
}
+48 -30
View File
@@ -6,42 +6,60 @@ import './injector';
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
import { Codec, Constructor } from './types';
import * as Classes from './index.types';
import { createTypeUnsafe } from './codec/createType';
import GenericMethod from './primitive/Generic/Method';
import { Codec } from './types';
import * as exported from './index.types';
import * as definitions from './interfaces/definitions';
const Types = Classes as Record<string, Constructor>;
const UNCONSTRUCTABLE = ['genericorigin', 'usize'];
// NOTE This is not a shortcut to implementing types incorrectly. This is here
// specifically for the types that _should_ throw in the constrtuctor, i.e
// `usize` is not allowed (runtime incompat) and `origin` is not passed through
// to any calls. All other types _must_ pass and allow for empty defaults
const UNCONSTRUCTABLE = ['genericorigin', 'origin', 'usize'];
describe('types', (): void => {
describe('default creation', (): void => {
Object.keys(Types).forEach((name): void => {
it(`creates an empty ${name}`, (): void => {
const constructFn = (): Codec =>
new Types[name]();
function testTypes (type: string, typeNames: string[]): void {
describe(type, (): void => {
describe(`${type}:: default creation`, (): void => {
typeNames.forEach((name): void => {
it(`creates an empty ${name}`, (): void => {
const constructFn = (): Codec =>
createTypeUnsafe(name);
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
expect(constructFn).toThrow();
} else {
expect(constructFn).not.toThrow();
}
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
expect(constructFn).toThrow();
} else {
expect(constructFn).not.toThrow();
}
});
});
});
describe(`${type}:: default creation (empty bytes)`, (): void => {
GenericMethod.injectMethods(extrinsics);
typeNames.forEach((name): void => {
it(`creates an empty ${name} (from empty bytes)`, (): void => {
const constructFn = (): Codec =>
createTypeUnsafe(name, [createTypeUnsafe('Bytes')]);
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
expect(constructFn).toThrow();
} else {
expect(constructFn).not.toThrow();
}
});
});
});
});
}
describe('default creation (empty bytes)', (): void => {
(Types.GenericMethod as any).injectMethods(extrinsics);
describe('type creation', (): void => {
testTypes('exported', Object.keys(exported));
Object.keys(Types).forEach((name): void => {
it(`creates an empty ${name} (from empty bytes)`, (): void => {
const constructFn = (): Codec =>
new Types[name](new Types.Bytes());
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
expect(constructFn).toThrow();
} else {
expect(constructFn).not.toThrow();
}
});
});
});
Object
.entries(definitions)
.forEach(([name, { types }]): void =>
testTypes(`${name} (injected)`, Object.keys(types))
);
});
+68 -69
View File
@@ -1,8 +1,8 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Compact, Option, Vec } from './codec';
import { Bytes, Data, Fixed64, H160, H256, H512, Moment, Null, StorageHasher, StorageKey, Text, Type, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive';
import { AccountId, AccountIdOf, AccountIndex, Address, Balance, BalanceOf, Block, BlockNumber, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Method, MortalEra, Origin, Perbill, Permill, Phantom, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, StorageData, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime';
import { Bytes, Data, Fixed64, H160, H256, H512, Null, StorageHasher, StorageKey, Text, Type, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive';
import { AccountId, AccountIdOf, AccountIndex, Address, Balance, BalanceOf, Block, BlockNumber, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Method, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, StorageData, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime';
import { AuthorityId } from './interfaces/consensus';
import { Keys, SessionIndex } from './interfaces/session';
import { AuthorityWeight, NextAuthority, PendingPause, PendingResume, StoredPendingChange, StoredState } from './interfaces/grandpa';
@@ -61,10 +61,6 @@ export interface InterfaceRegistry {
i256: i256;
'Option<i256>': Option<i256>;
'Vec<i256>': Vec<i256>;
Moment: Moment;
'Compact<Moment>': Compact<Moment>;
'Option<Moment>': Option<Moment>;
'Vec<Moment>': Vec<Moment>;
Null: Null;
'Option<Null>': Option<Null>;
'Vec<Null>': Vec<Null>;
@@ -132,6 +128,51 @@ export interface InterfaceRegistry {
'Compact<BlockNumber>': Compact<BlockNumber>;
'Option<BlockNumber>': Option<BlockNumber>;
'Vec<BlockNumber>': Vec<BlockNumber>;
Hash: Hash;
'Option<Hash>': Option<Hash>;
'Vec<Hash>': Vec<Hash>;
Index: Index;
'Compact<Index>': Compact<Index>;
'Option<Index>': Option<Index>;
'Vec<Index>': Vec<Index>;
KeyTypeId: KeyTypeId;
'Compact<KeyTypeId>': Compact<KeyTypeId>;
'Option<KeyTypeId>': Option<KeyTypeId>;
'Vec<KeyTypeId>': Vec<KeyTypeId>;
LockIdentifier: LockIdentifier;
'Option<LockIdentifier>': Option<LockIdentifier>;
'Vec<LockIdentifier>': Vec<LockIdentifier>;
Moment: Moment;
'Compact<Moment>': Compact<Moment>;
'Option<Moment>': Option<Moment>;
'Vec<Moment>': Vec<Moment>;
Perbill: Perbill;
'Compact<Perbill>': Compact<Perbill>;
'Option<Perbill>': Option<Perbill>;
'Vec<Perbill>': Vec<Perbill>;
Permill: Permill;
'Compact<Permill>': Compact<Permill>;
'Option<Permill>': Option<Permill>;
'Vec<Permill>': Vec<Permill>;
Phantom: Phantom;
'Option<Phantom>': Option<Phantom>;
'Vec<Phantom>': Vec<Phantom>;
ValidatorId: ValidatorId;
'Option<ValidatorId>': Option<ValidatorId>;
'Vec<ValidatorId>': Vec<ValidatorId>;
Weight: Weight;
'Compact<Weight>': Compact<Weight>;
'Option<Weight>': Option<Weight>;
'Vec<Weight>': Vec<Weight>;
WeightMultiplier: WeightMultiplier;
'Option<WeightMultiplier>': Option<WeightMultiplier>;
'Vec<WeightMultiplier>': Vec<WeightMultiplier>;
StorageData: StorageData;
'Option<StorageData>': Option<StorageData>;
'Vec<StorageData>': Vec<StorageData>;
KeyValue: KeyValue;
'Option<KeyValue>': Option<KeyValue>;
'Vec<KeyValue>': Vec<KeyValue>;
Signature: Signature;
'Option<Signature>': Option<Signature>;
'Vec<Signature>': Vec<Signature>;
@@ -141,6 +182,27 @@ export interface InterfaceRegistry {
Sr25519Signature: Sr25519Signature;
'Option<Sr25519Signature>': Option<Sr25519Signature>;
'Vec<Sr25519Signature>': Vec<Sr25519Signature>;
Method: Method;
'Option<Method>': Option<Method>;
'Vec<Method>': Vec<Method>;
Origin: Origin;
'Option<Origin>': Option<Origin>;
'Vec<Origin>': Vec<Origin>;
ImmortalEra: ImmortalEra;
'Option<ImmortalEra>': Option<ImmortalEra>;
'Vec<ImmortalEra>': Vec<ImmortalEra>;
MortalEra: MortalEra;
'Option<MortalEra>': Option<MortalEra>;
'Vec<MortalEra>': Vec<MortalEra>;
ExtrinsicEra: ExtrinsicEra;
'Option<ExtrinsicEra>': Option<ExtrinsicEra>;
'Vec<ExtrinsicEra>': Vec<ExtrinsicEra>;
ExtrinsicPayload: ExtrinsicPayload;
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
Extrinsic: Extrinsic;
'Option<Extrinsic>': Option<Extrinsic>;
'Vec<Extrinsic>': Vec<Extrinsic>;
ConsensusEngineId: ConsensusEngineId;
'Compact<ConsensusEngineId>': Compact<ConsensusEngineId>;
'Option<ConsensusEngineId>': Option<ConsensusEngineId>;
@@ -163,9 +225,6 @@ export interface InterfaceRegistry {
Digest: Digest;
'Option<Digest>': Option<Digest>;
'Vec<Digest>': Vec<Digest>;
Hash: Hash;
'Option<Hash>': Option<Hash>;
'Vec<Hash>': Vec<Hash>;
Header: Header;
'Option<Header>': Option<Header>;
'Vec<Header>': Vec<Header>;
@@ -178,65 +237,6 @@ export interface InterfaceRegistry {
SignedBlock: SignedBlock;
'Option<SignedBlock>': Option<SignedBlock>;
'Vec<SignedBlock>': Vec<SignedBlock>;
KeyTypeId: KeyTypeId;
'Compact<KeyTypeId>': Compact<KeyTypeId>;
'Option<KeyTypeId>': Option<KeyTypeId>;
'Vec<KeyTypeId>': Vec<KeyTypeId>;
LockIdentifier: LockIdentifier;
'Option<LockIdentifier>': Option<LockIdentifier>;
'Vec<LockIdentifier>': Vec<LockIdentifier>;
Index: Index;
'Compact<Index>': Compact<Index>;
'Option<Index>': Option<Index>;
'Vec<Index>': Vec<Index>;
Perbill: Perbill;
'Compact<Perbill>': Compact<Perbill>;
'Option<Perbill>': Option<Perbill>;
'Vec<Perbill>': Vec<Perbill>;
Permill: Permill;
'Compact<Permill>': Compact<Permill>;
'Option<Permill>': Option<Permill>;
'Vec<Permill>': Vec<Permill>;
Phantom: Phantom;
'Option<Phantom>': Option<Phantom>;
'Vec<Phantom>': Vec<Phantom>;
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>': Vec<ValidatorId>;
Weight: Weight;
'Compact<Weight>': Compact<Weight>;
'Option<Weight>': Option<Weight>;
'Vec<Weight>': Vec<Weight>;
WeightMultiplier: WeightMultiplier;
'Option<WeightMultiplier>': Option<WeightMultiplier>;
'Vec<WeightMultiplier>': Vec<WeightMultiplier>;
Method: Method;
'Option<Method>': Option<Method>;
'Vec<Method>': Vec<Method>;
Origin: Origin;
'Option<Origin>': Option<Origin>;
'Vec<Origin>': Vec<Origin>;
ImmortalEra: ImmortalEra;
'Option<ImmortalEra>': Option<ImmortalEra>;
'Vec<ImmortalEra>': Vec<ImmortalEra>;
MortalEra: MortalEra;
'Option<MortalEra>': Option<MortalEra>;
'Vec<MortalEra>': Vec<MortalEra>;
ExtrinsicEra: ExtrinsicEra;
'Option<ExtrinsicEra>': Option<ExtrinsicEra>;
'Vec<ExtrinsicEra>': Vec<ExtrinsicEra>;
ExtrinsicPayload: ExtrinsicPayload;
'Option<ExtrinsicPayload>': Option<ExtrinsicPayload>;
'Vec<ExtrinsicPayload>': Vec<ExtrinsicPayload>;
Extrinsic: Extrinsic;
'Option<Extrinsic>': Option<Extrinsic>;
'Vec<Extrinsic>': Vec<Extrinsic>;
AuthorityId: AuthorityId;
'Option<AuthorityId>': Option<AuthorityId>;
'Vec<AuthorityId>': Vec<AuthorityId>;
@@ -501,7 +501,6 @@ export interface InterfaceRegistry {
'Option<Exposure>': Option<Exposure>;
'Vec<Exposure>': Vec<Exposure>;
MomentOf: MomentOf;
'Compact<MomentOf>': Compact<MomentOf>;
'Option<MomentOf>': Option<MomentOf>;
'Vec<MomentOf>': Vec<MomentOf>;
RewardDestination: RewardDestination;
@@ -11,12 +11,37 @@ export default {
Balance: 'u128',
BalanceOf: 'Balance',
BlockNumber: 'u64',
Hash: 'H256',
Index: 'u64',
KeyTypeId: 'u32',
LockIdentifier: '[u8; 8]',
Moment: 'u64',
Perbill: 'u32',
Permill: 'u32',
Phantom: 'Null',
ValidatorId: 'AccountId',
Weight: 'u32',
WeightMultiplier: 'Fixed64',
// block
// :: signature
// storage helpers
StorageData: 'Bytes',
KeyValue: '(StorageKey, StorageData)',
// signatures (used in block & extrinsics)
Signature: 'H512',
Ed25519Signature: 'Signature',
Sr25519Signature: 'Signature',
// extrinsic definition
Method: 'GenericMethod',
Origin: 'GenericOrigin',
ImmortalEra: 'GenericImmortalEra',
MortalEra: 'GenericMortalEra',
ExtrinsicEra: 'GenericExtrinsicEra',
ExtrinsicPayload: 'GenericExtrinsicPayload',
Extrinsic: 'GenericExtrinsic',
// block definition
// :: digest
ConsensusEngineId: 'GenericConsensusEngineId',
PreRuntime: '(ConsensusEngineId, Bytes)',
@@ -25,7 +50,6 @@ export default {
Consensus: '(ConsensusEngineId, Bytes)',
DigestItem: 'GenericDigestItem',
Digest: 'GenericDigest',
Hash: 'H256',
// :: parts
Header: {
parentHash: 'Hash',
@@ -40,27 +64,6 @@ export default {
SignedBlock: {
block: 'Block',
justification: 'Justification'
},
KeyTypeId: 'u32',
LockIdentifier: '[u8; 8]',
Index: 'u64',
Perbill: 'u32',
Permill: 'u32',
Phantom: 'Null',
StorageData: 'Bytes',
KeyValue: '(StorageKey, StorageData)',
ValidatorId: 'AccountId',
Weight: 'u32',
WeightMultiplier: 'Fixed64',
// extrinsics
Method: 'GenericMethod',
Origin: 'GenericOrigin',
ImmortalEra: 'GenericImmortalEra',
MortalEra: 'GenericMortalEra',
ExtrinsicEra: 'GenericExtrinsicEra',
ExtrinsicPayload: 'GenericExtrinsicPayload',
Extrinsic: 'GenericExtrinsic'
}
}
};
@@ -90,6 +90,9 @@ export type LockIdentifier = Vec<u8>;
/** GenericMethod */
export type Method = GenericMethod;
/** u64 */
export type Moment = u64;
/** GenericMortalEra */
export type MortalEra = GenericMortalEra;
@@ -1,8 +1,8 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Compact, Enum, Struct, Vec } from '../../codec';
import { Moment, u32 } from '../../primitive';
import { AccountId, Balance, BlockNumber } from '../runtime';
import { u32 } from '../../primitive';
import { AccountId, Balance, BlockNumber, Moment } from '../runtime';
/** u32 */
export type EraIndex = u32;
@@ -2,12 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef } from '../../codec/types';
import { EventId } from '../../interfaces/system';
import { Constructor, Codec } from '../../types';
import { assert, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
import { ClassOf, TypeDef, getTypeClass, getTypeDef } from '../../codec/createType';
import { ClassOf, getTypeClass, getTypeDef } from '../../codec/createType';
import Struct from '../../codec/Struct';
import Tuple from '../../codec/Tuple';
import Metadata from '../../Metadata';
-1
View File
@@ -25,7 +25,6 @@ export { default as i64 } from './I64';
export { default as Fixed64 } from './I64Fixed';
export { default as i128 } from './I128';
export { default as i256 } from './I256';
export { default as Moment } from './Moment';
export { default as Null } from './Null';
export { default as StorageHasher } from './StorageHasher';
export { default as StorageKey } from './StorageKey';
+3 -1
View File
@@ -2,10 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../codec/types';
import fs from 'fs';
import { isString, stringCamelCase, stringUpperFirst } from '@polkadot/util';
import { getTypeDef, TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../codec/createType';
import { getTypeDef } from '../codec/createType';
import * as codecClasses from '../codec';
import { COMPACT_ENCODABLE } from '../codec/Compact';
import * as primitiveClasses from '../primitive';
+2
View File
@@ -12,6 +12,8 @@ import { FunctionMetadata } from './Metadata/v7/Calls';
import Method from './primitive/Generic/Method';
import Address from './primitive/Generic/Address';
export * from './codec/types';
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface IKeyringPair {
address: string;