From 83515fc0a26a659876666dc6284bd690f4286930 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 25 Jul 2019 20:18:35 +0200 Subject: [PATCH] ClassOf does not require (#1190) * Add InterfaceRegistry * Update srml script * Add compact * Add correct imports * Auto-generate InterfaceRegistry * Regenerate * Simplify code * add comment * Fix lint * Rename var * Compact encodable abtstactInt * Fix abstract isChildClass --- packages/api/src/checkTypes.manual.ts | 9 +- packages/types/src/codec/Compact.ts | 13 +- packages/types/src/codec/createType.ts | 25 ++- packages/types/src/interfaceRegistry.ts | 215 ++++++++++++++++++++ packages/types/src/scripts/srmlTS.ts | 101 ++++++++- packages/types/src/srml/authorship/types.ts | 16 +- packages/types/src/srml/babe/types.ts | 10 + packages/types/src/srml/balances/types.ts | 16 +- packages/types/src/srml/collective/types.ts | 18 +- packages/types/src/srml/consensus/types.ts | 9 + packages/types/src/srml/contracts/types.ts | 39 ++++ packages/types/src/srml/democracy/types.ts | 24 ++- packages/types/src/srml/deprecated/types.ts | 33 ++- packages/types/src/srml/elections/types.ts | 25 ++- packages/types/src/srml/grandpa/types.ts | 26 ++- packages/types/src/srml/imOnline/types.ts | 19 +- packages/types/src/srml/parachains/types.ts | 86 +++++++- packages/types/src/srml/runtime/types.ts | 69 ++++++- packages/types/src/srml/session/types.ts | 13 ++ packages/types/src/srml/staking/types.ts | 32 ++- packages/types/src/srml/system/types.ts | 9 + packages/types/src/srml/treasury/types.ts | 10 +- 22 files changed, 783 insertions(+), 34 deletions(-) create mode 100644 packages/types/src/interfaceRegistry.ts diff --git a/packages/api/src/checkTypes.manual.ts b/packages/api/src/checkTypes.manual.ts index e4cca25963..ad50b06d8c 100644 --- a/packages/api/src/checkTypes.manual.ts +++ b/packages/api/src/checkTypes.manual.ts @@ -11,7 +11,7 @@ import { HeaderExtended } from '@polkadot/api-derive'; import { ConstantCodec } from '@polkadot/api-metadata/consts/types'; import testKeyring from '@polkadot/keyring/testingPairs'; import { IExtrinsic, IMethod } from '@polkadot/types/types'; -import { Header } from '@polkadot/types'; +import { createType, Header } from '@polkadot/types'; import { SubmittableResult } from './'; @@ -92,4 +92,11 @@ export default async function test (): Promise { unsub2(); }); + + // check correct types with `createType` + const balance = createType('Balance', 2); + const overridden = createType('Gas', 2); + const gas = createType('Gas', 2); + const vec = createType('Vec', 2); + console.log(balance, overridden, gas, vec); } diff --git a/packages/types/src/codec/Compact.ts b/packages/types/src/codec/Compact.ts index 0bffeed301..f2be420c74 100644 --- a/packages/types/src/codec/Compact.ts +++ b/packages/types/src/codec/Compact.ts @@ -8,9 +8,12 @@ import { DEFAULT_BITLENGTH } from '@polkadot/util/compact/defaults'; import Moment from '../primitive/Moment'; import { AnyNumber, Constructor } from '../types'; -import { UIntBitLength } from './AbstractInt'; +import AbstractInt, { UIntBitLength } from './AbstractInt'; import Base from './Base'; -import UInt from './UInt'; + +// 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? /** * @name Compact @@ -20,12 +23,12 @@ import UInt from './UInt'; * used by other types to add length-prefixed encoding, or in the case of wrapped types, taking * a number and making the compact representation thereof */ -export default class Compact extends Base { +export default class Compact extends Base { public constructor (Type: Constructor, value: Compact | AnyNumber = 0) { super(Compact.decodeCompact(Type, value)); } - public static with (Type: Constructor): Constructor> { + public static with (Type: Constructor): Constructor> { return class extends Compact { public constructor (value?: any) { super(Type, value); @@ -50,7 +53,7 @@ export default class Compact extends Base { return value; } - public static decodeCompact (Type: Constructor, value: Compact | AnyNumber): Moment | UInt { + public static decodeCompact (Type: Constructor, value: Compact | AnyNumber): CompactEncodable { if (value instanceof Compact) { return new Type(value.raw); } else if (isString(value)) { diff --git a/packages/types/src/codec/createType.ts b/packages/types/src/codec/createType.ts index 79ee467af0..308de0eb73 100644 --- a/packages/types/src/codec/createType.ts +++ b/packages/types/src/codec/createType.ts @@ -5,6 +5,7 @@ import memoizee from 'memoizee'; import { assert } from '@polkadot/util'; +import { InterfaceRegistry } from '../interfaceRegistry'; import { Codec, Constructor } from '../types'; import Null from '../primitive/Null'; import StorageData from '../primitive/StorageData'; @@ -203,9 +204,11 @@ export function getTypeDef (_type: Text | string, name?: string): TypeDef { } // Memoized helper of the `createClass` function below -const memoizedCreateClass = memoizee((type: Text | string): Constructor => { +const memoizedCreateClass = memoizee(( + type: K +): Constructor => { // eslint-disable-next-line @typescript-eslint/no-use-before-define - return getTypeClass( + return getTypeClass( getTypeDef(type) ); }, { @@ -216,7 +219,9 @@ const memoizedCreateClass = memoizee((type: Text | stri normalizer: JSON.stringify }); -export function createClass (type: Text | string): Constructor { +export function createClass ( + type: K +): Constructor { return memoizedCreateClass(type); } @@ -318,11 +323,11 @@ export function getTypeClass (value: TypeDef, Fallback? } // alias for createClass -export function ClassOf (name: string): Constructor { +export function ClassOf (name: string): Constructor { return createClass(name); } -function initType (Type: Constructor, value?: any, isPedantic?: boolean): T { +function initType (Type: Constructor, value?: any, isPedantic?: boolean): T { try { const created = new Type(value); @@ -353,11 +358,13 @@ function initType (Type: Constructor, value?: any, i } } -export default function createType (type: Text | string, value?: any, isPedantic?: boolean): T { - // l.debug(() => ['createType', { type, value }]); - +export default function createType ( + type: K, + value?: any, + isPedantic?: boolean +): K extends keyof InterfaceRegistry ? InterfaceRegistry[K] : T { try { - return initType(createClass(type), value, isPedantic); + return initType(createClass(type), value, isPedantic); } catch (error) { throw new Error(`createType(${type}):: ${error.message}`); } diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts new file mode 100644 index 0000000000..9225516a7b --- /dev/null +++ b/packages/types/src/interfaceRegistry.ts @@ -0,0 +1,215 @@ +/* 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'; + +export interface InterfaceRegistry { + AccountId: AccountId; + 'Option': Option; + 'Vec': Vector; + AccountIndex: AccountIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Address: Address; + 'Option
': Option
; + 'Vec
': Vector
; + Event: Event; + 'Option': Option; + 'Vec': Vector; + EventIndex: EventIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + EventRecord: EventRecord; + 'Option': Option; + 'Vec': Vector; + EventRecord0to76: EventRecord0to76; + 'Option': Option; + 'Vec': Vector; + Bool: Bool; + 'Option': Option; + 'Vec': Vector; + bool: bool; + 'Option': Option; + 'Vec': Vector; + Bytes: Bytes; + 'Option': Option; + 'Vec': Vector; + Data: Data; + 'Option': Option; + 'Vec': Vector; + H160: H160; + 'Option': Option; + 'Vec': Vector; + H256: H256; + 'Option': Option; + 'Vec': Vector; + H512: H512; + 'Option': Option; + 'Vec': Vector; + I8: I8; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i8: i8; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + I16: I16; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i16: i16; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + I32: I32; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i32: i32; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + I64: I64; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i64: i64; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Fixed64: Fixed64; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + I128: I128; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i128: i128; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + I256: I256; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + i256: i256; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + KeyValue: KeyValue; + 'Option': Option; + 'Vec': Vector; + Method: Method; + 'Option': Option; + 'Vec': Vector; + Moment: Moment; + 'Option': Option; + 'Vec': Vector; + MomentOf: MomentOf; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Null: Null; + 'Option': Option; + 'Vec': Vector; + Phantom: Phantom; + 'Option': Option; + 'Vec': Vector; + Origin: Origin; + 'Option': Option; + 'Vec': Vector; + StorageData: StorageData; + 'Option': Option; + 'Vec': Vector; + StorageHasher: StorageHasher; + 'Option': Option; + 'Vec': Vector; + StorageKey: StorageKey; + 'Option': Option; + 'Vec': Vector; + Text: Text; + 'Option': Option; + 'Vec': Vector; + Type: Type; + 'Option': Option; + 'Vec': Vector; + U8: U8; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u8: u8; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + U16: U16; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u16: u16; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + U32: U32; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u32: u32; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + U64: U64; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u64: u64; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + U128: U128; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u128: u128; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + U256: U256; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + u256: u256; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + USize: USize; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + usize: usize; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Vote: Vote; + 'Option': Option; + 'Vec': Vector; + Extrinsic: Extrinsic; + 'Option': Option; + 'Vec': Vector; + ExtrinsicEra: ExtrinsicEra; + 'Option': Option; + 'Vec': Vector; + MortalEra: MortalEra; + 'Option': Option; + 'Vec': Vector; + ImmortalEra: ImmortalEra; + 'Option': Option; + 'Vec': Vector; + SignaturePayload: SignaturePayload; + 'Option': Option; + 'Vec': Vector; +} diff --git a/packages/types/src/scripts/srmlTS.ts b/packages/types/src/scripts/srmlTS.ts index c6860b2c28..ececaab70e 100644 --- a/packages/types/src/scripts/srmlTS.ts +++ b/packages/types/src/scripts/srmlTS.ts @@ -7,8 +7,10 @@ import { isString, stringCamelCase, stringUpperFirst } from '@polkadot/util'; import { getTypeDef, TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../codec/createType'; import * as codecClasses from '../codec'; +import { COMPACT_ENCODABLE } from '../codec/Compact'; import * as primitiveClasses from '../primitive'; import * as definitions from '../srml/definitions'; +import { Constructor } from '../types'; // these map all the codec and primitive types for import, see the TypeImports below. If // we have an unseen type, it is `undefined`/`false`, if we need to import it, it is `true` @@ -53,6 +55,19 @@ function setImports ({ codecTypes, localTypes, ownTypes, primitiveTypes }: TypeI }); } +// See if a class is child of another class +// FIMXE This could go in util some day +function isChildClass (Parent: Constructor, Child: Constructor): boolean { + // https://stackoverflow.com/questions/30993434/check-if-a-constructor-inherits-another-in-es6/30993664 + // eslint-disable-next-line no-prototype-builtins + return Parent.isPrototypeOf(Child); +} + +function isCompactEncodable (Child: Constructor): boolean { + // @ts-ignore AbstractInt is abstract, we shouldn't isChildClass it here, but it works + return Object.values(COMPACT_ENCODABLE).some((CompactEncodable): boolean => isChildClass(CompactEncodable, Child)); +} + // helper to generate a `export interface extends {} function createInterface (name: string = '', base: string, body: string = ''): string { return `export interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`; @@ -221,16 +236,44 @@ function tsVector ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeI } // creates the import lines -function createImportCode (header: string, checks: { file: string; types: string[]}[]): string { +function createImportCode (header: string, checks: { file: string; types: string[] }[]): string { return checks.reduce((result, { file, types }): string => { if (types.length) { - result += `import { ${types.sort().join(', ')} } from '../${file}';\n`; + result += `import { ${types.sort().join(', ')} } from '${file}';\n`; } return result; }, header) + '\n'; } +// From `T`, generate `Compact, Option, Vec` +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' : '']); + + return [ + `${type}: ${type};`, + isCompact ? `'Compact<${type}>': Compact<${type}>;` : undefined, + `'Option<${type}>': Option<${type}>;`, + `'Vec<${type}>': Vector<${type}>;` + ] + .filter((x): boolean => !!x) + .map((line): string => `${' '.repeat(indent)}${line}`) // Add indentation + .join('\n'); +} + +// Do module augmentation on srml types to populate InterfaceRegistry +function interfaceRegistry (types: Record, imports: TypeImports): string { + return ` + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { +${Object.keys(types).map((type): string => getDerivedTypes(type, types[type], imports, 4)).join('\n')} + } +}`; +} + function generateTsDef (srmlName: string, { types }: { types: Record }): void { // handlers are defined externally to use - this means that when we do a // `generators[typedef.info](...)` TS will show any unhandled types. Rather @@ -265,26 +308,27 @@ function generateTsDef (srmlName: string, { types }: { types: Record a[0].localeCompare(b[0])).map(([, definition]): string => definition).join('\n\n'); + const interfaceReg = interfaceRegistry(types, { codecTypes, localTypes, ownTypes, primitiveTypes }); const header = createImportCode(HEADER, [ { - file: '../types', + file: '../../types', types: codecTypes['Tuple'] ? ['Codec'] : [] }, { - file: '../codec', + file: '../../codec', types: Object.keys(codecTypes).filter((name): boolean => name !== 'Tuple') }, { - file: '../primitive', + file: '../../primitive', types: Object.keys(primitiveTypes) }, ...Object.keys(localTypes).map((moduleName): { file: string; types: string[] } => ({ - file: `${moduleName}/types`, + file: `../${moduleName}/types`, types: Object.keys(localTypes[moduleName]) })) ]); - fs.writeFileSync(`packages/types/src/srml/${srmlName}/types.ts`, header.concat(sortedDefs).concat(FOOTER), { flag: 'w' }); + fs.writeFileSync(`packages/types/src/srml/${srmlName}/types.ts`, header.concat(sortedDefs).concat(interfaceReg).concat(FOOTER), { flag: 'w' }); } Object.entries(definitions).forEach(([srmlName, obj]): void => { @@ -296,3 +340,46 @@ Object.entries(definitions).forEach(([srmlName, obj]): void => { console.log(`Writing srml/types.ts`); fs.writeFileSync(`packages/types/src/srml/types.ts`, HEADER.concat(Object.keys(definitions).map((moduleName): string => `export * from './${moduleName}/types';`).join('\n')).concat(FOOTER), { flag: 'w' }); + +function generateInterfaceRegistry (): void { + const codecTypes: TypeExist = {}; + const localTypes: LocalExist = {}; + const ownTypes: string[] = []; + const primitiveTypes: TypeExist = {}; + const substrateTypes: TypeExist = {}; + + const imports = { codecTypes, localTypes, ownTypes, primitiveTypes, substrateTypes }; + + const body = Object.keys(primitiveClasses).reduce((accumulator, primitiveName): string => { + setImports(imports, [primitiveName]); + + return [ + accumulator, + getDerivedTypes(primitiveName, primitiveName, imports) + ].join('\n'); + }, ''); + + const header = createImportCode(HEADER, [ + { + file: './codec', + types: Object.keys(codecTypes).filter((name): boolean => name !== 'Tuple') + }, + { + file: './primitive', + types: Object.keys(primitiveTypes) + } + ]); + + const interfaceStart = 'export interface InterfaceRegistry {'; + const interfaceEnd = '\n}'; + + fs.writeFileSync( + `packages/types/src/interfaceRegistry.ts`, + header.concat(interfaceStart).concat(body).concat(interfaceEnd).concat(FOOTER) + , { flag: 'w' } + ); +} + +console.log(`Writing interfaceRegistry.ts`); + +generateInterfaceRegistry(); diff --git a/packages/types/src/srml/authorship/types.ts b/packages/types/src/srml/authorship/types.ts index 4b1305006d..1a0cc74a33 100644 --- a/packages/types/src/srml/authorship/types.ts +++ b/packages/types/src/srml/authorship/types.ts @@ -2,7 +2,7 @@ // Auto-generated via `yarn build:srmlTs`, do not edit import { Codec } from '../../types'; -import { Enum, Option } from '../../codec'; +import { Enum, Option, Vector } from '../../codec'; import { AccountId } from '../../primitive'; import { BlockNumber, Hash } from '../runtime/types'; @@ -23,3 +23,17 @@ export interface UncleEntryItem extends Enum { readonly isUncle: boolean; readonly asUncle: Uncle; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + InclusionHeight: InclusionHeight; + 'Option': Option; + 'Vec': Vector; + Uncle: Uncle; + 'Option': Option; + 'Vec': Vector; + UncleEntryItem: UncleEntryItem; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/babe/types.ts b/packages/types/src/srml/babe/types.ts index 6a754b5e98..8bcc2347df 100644 --- a/packages/types/src/srml/babe/types.ts +++ b/packages/types/src/srml/babe/types.ts @@ -1,6 +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 { u64 } from '../../primitive'; export interface BabeWeight extends u64 {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + BabeWeight: BabeWeight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/balances/types.ts b/packages/types/src/srml/balances/types.ts index da9b6d02e7..3e17efe4bf 100644 --- a/packages/types/src/srml/balances/types.ts +++ b/packages/types/src/srml/balances/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Set, Struct } from '../../codec'; +import { Option, Set, Struct, Vector } from '../../codec'; import { Balance, BlockNumber, LockIdentifier } from '../runtime/types'; export interface BalanceLock extends Struct { @@ -22,3 +22,17 @@ export interface WithdrawReasons extends Set { readonly isReserve: boolean; readonly isFee: boolean; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + VestingSchedule: VestingSchedule; + 'Option': Option; + 'Vec': Vector; + WithdrawReasons: WithdrawReasons; + 'Option': Option; + 'Vec': Vector; + BalanceLock: BalanceLock; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/collective/types.ts b/packages/types/src/srml/collective/types.ts index 54437a9a65..aba727fa43 100644 --- a/packages/types/src/srml/collective/types.ts +++ b/packages/types/src/srml/collective/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Struct, Vector } from '../../codec'; +import { Compact, Option, Struct, Vector } from '../../codec'; import { AccountId, u32, u64 } from '../../primitive'; export interface MemberCount extends u64 {} @@ -14,3 +14,19 @@ export interface Votes extends Struct { readonly ayes: Vector; readonly nays: Vector; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + MemberCount: MemberCount; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + ProposalIndex: ProposalIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Votes: Votes; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/consensus/types.ts b/packages/types/src/srml/consensus/types.ts index 15a3d68aba..176419e531 100644 --- a/packages/types/src/srml/consensus/types.ts +++ b/packages/types/src/srml/consensus/types.ts @@ -1,6 +1,15 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit +import { Option, Vector } from '../../codec'; import { AccountId } from '../../primitive'; export interface AuthorityId extends AccountId {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + AuthorityId: AuthorityId; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/contracts/types.ts b/packages/types/src/srml/contracts/types.ts index 3cbb176a17..4a8f7003ad 100644 --- a/packages/types/src/srml/contracts/types.ts +++ b/packages/types/src/srml/contracts/types.ts @@ -66,3 +66,42 @@ export interface SeedOf extends Hash {} export interface TombstoneContractInfo extends Hash {} export interface TrieId extends Bytes {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + CodeHash: CodeHash; + 'Option': Option; + 'Vec': Vector; + TrieId: TrieId; + 'Option': Option; + 'Vec': Vector; + AliveContractInfo: AliveContractInfo; + 'Option': Option; + 'Vec': Vector; + TombstoneContractInfo: TombstoneContractInfo; + 'Option': Option; + 'Vec': Vector; + ContractInfo: ContractInfo; + 'Option': Option; + 'Vec': Vector; + ContractStorageKey: ContractStorageKey; + 'Option': Option; + 'Vec': Vector; + Gas: Gas; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + PrefabWasmModuleReserved: PrefabWasmModuleReserved; + 'Option': Option; + 'Vec': Vector; + PrefabWasmModule: PrefabWasmModule; + 'Option': Option; + 'Vec': Vector; + Schedule: Schedule; + 'Option': Option; + 'Vec': Vector; + SeedOf: SeedOf; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/democracy/types.ts b/packages/types/src/srml/democracy/types.ts index ef905a2aba..1ddb3a615f 100644 --- a/packages/types/src/srml/democracy/types.ts +++ b/packages/types/src/srml/democracy/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Enum, Struct } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { Method, u32 } from '../../primitive'; import { BlockNumber } from '../runtime/types'; import { VoteThreshold } from '../elections/types'; @@ -45,3 +45,25 @@ export interface ReferendumInfo extends Struct { readonly threshold: VoteThreshold; readonly delay: BlockNumber; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + Conviction: Conviction; + 'Option': Option; + 'Vec': Vector; + PropIndex: PropIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Proposal: Proposal; + 'Option': Option; + 'Vec': Vector; + ReferendumIndex: ReferendumIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + ReferendumInfo: ReferendumInfo; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/deprecated/types.ts b/packages/types/src/srml/deprecated/types.ts index a6c1f7d179..720d130759 100644 --- a/packages/types/src/srml/deprecated/types.ts +++ b/packages/types/src/srml/deprecated/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Enum, Struct } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { AccountId, Bytes, Null, i8, u32, u64 } from '../../primitive'; import { Balance } from '../runtime/types'; @@ -36,3 +36,34 @@ export interface NewAccountOutcome extends Enum { export interface OpaqueKey extends Bytes {} export interface SessionKey extends AccountId {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + NewAccountOutcome: NewAccountOutcome; + 'Option': Option; + 'Vec': Vector; + Amount: Amount; + 'Option': Option; + 'Vec': Vector; + AssetOf: AssetOf; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + AccountInfo: AccountInfo; + 'Option': Option; + 'Vec': Vector; + LockPeriods: LockPeriods; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + InherentOfflineReport: InherentOfflineReport; + 'Option': Option; + 'Vec': Vector; + SessionKey: SessionKey; + 'Option': Option; + 'Vec': Vector; + OpaqueKey: OpaqueKey; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/elections/types.ts b/packages/types/src/srml/elections/types.ts index 4fb5757f95..4ef1a380a3 100644 --- a/packages/types/src/srml/elections/types.ts +++ b/packages/types/src/srml/elections/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Enum, Struct } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { u32 } from '../../primitive'; import { Balance } from '../runtime/types'; @@ -32,3 +32,26 @@ export interface VoteThreshold extends Enum { */ readonly isSimpleMajority: boolean; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + ApprovalFlag: ApprovalFlag; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + SetIndex: SetIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + VoteIndex: VoteIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + VoterInfo: VoterInfo; + 'Option': Option; + 'Vec': Vector; + VoteThreshold: VoteThreshold; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/grandpa/types.ts b/packages/types/src/srml/grandpa/types.ts index eb16a9ff20..3f067847aa 100644 --- a/packages/types/src/srml/grandpa/types.ts +++ b/packages/types/src/srml/grandpa/types.ts @@ -2,7 +2,7 @@ // Auto-generated via `yarn build:srmlTs`, do not edit import { Codec } from '../../types'; -import { Enum, Struct, Vector } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { u64 } from '../../primitive'; import { BlockNumber } from '../runtime/types'; import { AuthorityId } from '../consensus/types'; @@ -48,3 +48,27 @@ export interface StoredState extends Enum { readonly isPendingResume: boolean; readonly asPendingResume: PendingResume; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + AuthorityWeight: AuthorityWeight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + NextAuthority: NextAuthority; + 'Option': Option; + 'Vec': Vector; + PendingPause: PendingPause; + 'Option': Option; + 'Vec': Vector; + PendingResume: PendingResume; + 'Option': Option; + 'Vec': Vector; + StoredPendingChange: StoredPendingChange; + 'Option': Option; + 'Vec': Vector; + StoredState: StoredState; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/imOnline/types.ts b/packages/types/src/srml/imOnline/types.ts index 37f9cb7373..2454391905 100644 --- a/packages/types/src/srml/imOnline/types.ts +++ b/packages/types/src/srml/imOnline/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Struct, Vector } from '../../codec'; +import { Option, Struct, Vector } from '../../codec'; import { Bytes } from '../../primitive'; import { BlockNumber } from '../runtime/types'; import { AuthorityId } from '../consensus/types'; @@ -22,3 +22,20 @@ export interface OpaqueNetworkState extends Struct { } export interface OpaquePeerId extends Bytes {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + OpaqueMultiaddr: OpaqueMultiaddr; + 'Option': Option; + 'Vec': Vector; + OpaquePeerId: OpaquePeerId; + 'Option': Option; + 'Vec': Vector; + OpaqueNetworkState: OpaqueNetworkState; + 'Option': Option; + 'Vec': Vector; + Heartbeat: Heartbeat; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/parachains/types.ts b/packages/types/src/srml/parachains/types.ts index bc15a95883..d5076f4a30 100644 --- a/packages/types/src/srml/parachains/types.ts +++ b/packages/types/src/srml/parachains/types.ts @@ -2,7 +2,7 @@ // Auto-generated via `yarn build:srmlTs`, do not edit import { Codec } from '../../types'; -import { Enum, Struct, Vector } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { AccountId, Bytes, u32, u64 } from '../../primitive'; import { BalanceOf, BlockNumber, Hash, Signature } from '../runtime/types'; @@ -175,3 +175,87 @@ export interface WinningData extends Vector {} type _WinningDataEntry = [AccountId, ParaIdOf, BalanceOf]; export interface WinningDataEntry extends Codec, _WinningDataEntry {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + AuctionIndex: AuctionIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + CollatorSignature: CollatorSignature; + 'Option': Option; + 'Vec': Vector; + ValidityAttestation: ValidityAttestation; + 'Option': Option; + 'Vec': Vector; + ParaId: ParaId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + ParaIdOf: ParaIdOf; + 'Option': Option; + 'Vec': Vector; + ValidatorIndex: ValidatorIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + ValidityVote: ValidityVote; + 'Option': Option; + 'Vec': Vector; + BalanceUpload: BalanceUpload; + 'Option': Option; + 'Vec': Vector; + EgressQueueRoot: EgressQueueRoot; + 'Option': Option; + 'Vec': Vector; + HeadData: HeadData; + 'Option': Option; + 'Vec': Vector; + CandidateReceipt: CandidateReceipt; + 'Option': Option; + 'Vec': Vector; + AttestedCandidate: AttestedCandidate; + 'Option': Option; + 'Vec': Vector; + SubId: SubId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + NewBidder: NewBidder; + 'Option': Option; + 'Vec': Vector; + Bidder: Bidder; + 'Option': Option; + 'Vec': Vector; + IncomingParachainDeploy: IncomingParachainDeploy; + 'Option': Option; + 'Vec': Vector; + IncomingParachainFixed: IncomingParachainFixed; + 'Option': Option; + 'Vec': Vector; + IncomingParachain: IncomingParachain; + 'Option': Option; + 'Vec': Vector; + LeasePeriod: LeasePeriod; + 'Option': Option; + 'Vec': Vector; + LeasePeriodOf: LeasePeriodOf; + 'Option': Option; + 'Vec': Vector; + ParachainDispatchOrigin: ParachainDispatchOrigin; + 'Option': Option; + 'Vec': Vector; + SlotRange: SlotRange; + 'Option': Option; + 'Vec': Vector; + UpwardMessage: UpwardMessage; + 'Option': Option; + 'Vec': Vector; + WinningDataEntry: WinningDataEntry; + 'Option': Option; + 'Vec': Vector; + WinningData: WinningData; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/runtime/types.ts b/packages/types/src/srml/runtime/types.ts index 68d8679c49..80f561e783 100644 --- a/packages/types/src/srml/runtime/types.ts +++ b/packages/types/src/srml/runtime/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Struct, Vector } from '../../codec'; +import { Compact, Option, Struct, Vector } from '../../codec'; import { AccountId, Bytes, Fixed64, H256, H512, u128, u32, u64, u8 } from '../../primitive'; export interface AccountIdOf extends AccountId {} @@ -41,3 +41,70 @@ export interface ValidatorId extends AccountId {} export interface Weight extends u32 {} export interface WeightMultiplier extends Fixed64 {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + AccountIdOf: AccountIdOf; + 'Option': Option; + 'Vec': Vector; + Balance: Balance; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + BalanceOf: BalanceOf; + 'Option': Option; + 'Vec': Vector; + BlockNumber: BlockNumber; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Hash: Hash; + 'Option': Option; + 'Vec': Vector; + Justification: Justification; + 'Option': Option; + 'Vec': Vector; + KeyTypeId: KeyTypeId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + LockIdentifier: LockIdentifier; + 'Option': Option; + 'Vec': Vector; + Index: Index; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Perbill: Perbill; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Permill: Permill; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + SessionKeys: SessionKeys; + 'Option': Option; + 'Vec': Vector; + Signature: Signature; + 'Option': Option; + 'Vec': Vector; + Ed25519Signature: Ed25519Signature; + 'Option': Option; + 'Vec': Vector; + Sr25519Signature: Sr25519Signature; + 'Option': Option; + 'Vec': Vector; + ValidatorId: ValidatorId; + 'Option': Option; + 'Vec': Vector; + Weight: Weight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + WeightMultiplier: WeightMultiplier; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/session/types.ts b/packages/types/src/srml/session/types.ts index 4d9928f360..63d464894e 100644 --- a/packages/types/src/srml/session/types.ts +++ b/packages/types/src/srml/session/types.ts @@ -1,9 +1,22 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit +import { Compact, Option, Vector } from '../../codec'; import { u32 } from '../../primitive'; import { SessionKeys } from '../runtime/types'; export interface Keys extends SessionKeys {} export interface SessionIndex extends u32 {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + SessionIndex: SessionIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + Keys: Keys; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/staking/types.ts b/packages/types/src/srml/staking/types.ts index 13626c1cb4..a3c3500fa9 100644 --- a/packages/types/src/srml/staking/types.ts +++ b/packages/types/src/srml/staking/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Compact, Enum, Struct, Vector } from '../../codec'; +import { Compact, Enum, Option, Struct, Vector } from '../../codec'; import { AccountId, u32 } from '../../primitive'; import { Balance, BlockNumber } from '../runtime/types'; @@ -54,3 +54,33 @@ export interface ValidatorPrefs extends Struct { readonly unstakeThreshold: Compact; readonly validatorPayment: Compact; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + EraIndex: EraIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vector; + EraRewards: EraRewards; + 'Option': Option; + 'Vec': Vector; + IndividualExposure: IndividualExposure; + 'Option': Option; + 'Vec': Vector; + Exposure: Exposure; + 'Option': Option; + 'Vec': Vector; + RewardDestination: RewardDestination; + 'Option': Option; + 'Vec': Vector; + UnlockChunk: UnlockChunk; + 'Option': Option; + 'Vec': Vector; + StakingLedger: StakingLedger; + 'Option': Option; + 'Vec': Vector; + ValidatorPrefs: ValidatorPrefs; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/system/types.ts b/packages/types/src/srml/system/types.ts index b3ab044cf4..74271159c5 100644 --- a/packages/types/src/srml/system/types.ts +++ b/packages/types/src/srml/system/types.ts @@ -1,6 +1,15 @@ /* 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'; export interface Key extends Bytes {} + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + Key: Key; + 'Option': Option; + 'Vec': Vector; + } +} diff --git a/packages/types/src/srml/treasury/types.ts b/packages/types/src/srml/treasury/types.ts index 0e8e18ca39..c28f57681f 100644 --- a/packages/types/src/srml/treasury/types.ts +++ b/packages/types/src/srml/treasury/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ // Auto-generated via `yarn build:srmlTs`, do not edit -import { Struct } from '../../codec'; +import { Option, Struct, Vector } from '../../codec'; import { AccountId } from '../../primitive'; import { Balance } from '../runtime/types'; @@ -11,3 +11,11 @@ export interface TreasuryProposal extends Struct { readonly beneficiary: AccountId; readonly bond: Balance; } + +declare module '@polkadot/types/interfaceRegistry' { + export interface InterfaceRegistry { + TreasuryProposal: TreasuryProposal; + 'Option': Option; + 'Vec': Vector; + } +}