Cleanup api.createType d.ts, add createType to registry (#1929)

* Cleanup api.createType d.ts, add createType to registry

* CHANGELOG
This commit is contained in:
Jaco Greeff
2020-02-23 14:57:30 +01:00
committed by GitHub
parent d09dcb8282
commit 51cb64ade7
5 changed files with 25 additions and 19 deletions
+8
View File
@@ -14,6 +14,7 @@ import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '
import { EventData } from '../generic/Event';
import Unconstructable from '../primitive/Unconstructable';
import { createClass, getTypeClass } from './createClass';
import { createType } from './createType';
import { getTypeDef } from './getTypeDef';
// create error mapping from metadata
@@ -127,6 +128,13 @@ export class TypeRegistry implements Registry {
: formatBalance.getDefaults().unit;
}
/**
* @description Creates an instance of a type as registered
*/
public createType <K extends keyof InterfaceTypes> (type: K, ...params: any[]): InterfaceTypes[K] {
return createType(this, type, ...params);
}
// find a specific call
public findMetaCall (callIndex: Uint8Array): CallFunction {
const hexIndex = u8aToHex(callIndex);
+1
View File
@@ -92,6 +92,7 @@ export interface Registry {
// keep this as a generic Codec, however the actual impl. returns the correct
findMetaEvent (eventIndex: Uint8Array): Constructor<any>;
createType <K extends keyof InterfaceTypes> (type: K, ...params: any[]): InterfaceTypes[K];
get <T extends Codec = Codec> (name: string, withUnknown?: boolean): Constructor<T> | undefined;
getChainProperties (): ChainProperties | undefined;
getDefinition (name: string): string | undefined;