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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user