From 25d1a1195ea3f60a98d9c4f00abc480ef235bf94 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 6 Oct 2019 13:51:19 +0200 Subject: [PATCH] Expose api.createType (#1450) --- packages/api/src/base/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/api/src/base/index.ts b/packages/api/src/base/index.ts index 2198e3b307..a34b3d74fe 100644 --- a/packages/api/src/base/index.ts +++ b/packages/api/src/base/index.ts @@ -4,11 +4,12 @@ import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types'; import { Hash, RuntimeVersion } from '@polkadot/types/interfaces'; -import { CallFunction, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types'; +import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry'; +import { CallFunction, InterfaceTypes, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types'; import { ApiOptions, ApiTypes, DecoratedRpc, DecorateMethod, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics, Signer } from '../types'; import { Constants } from '@polkadot/api-metadata/consts/types'; -import { GenericCall, Metadata, getTypeRegistry } from '@polkadot/types'; +import { GenericCall, Metadata, createType, getTypeRegistry } from '@polkadot/types'; import { assert, isString, isUndefined, u8aToHex, u8aToU8a } from '@polkadot/util'; import Init from './Init'; @@ -216,6 +217,13 @@ export default abstract class ApiBase extends Init { return assertResult(this._extrinsics); } + /** + * @description Creates an instance of a type as registered + */ + public createType (type: K, ...params: any[]): InterfaceRegistry[K] { + return createType(type, ...params); + } + /** * @description Disconnect from the underlying provider, halting all comms */