UNPKG

3.96 kBTypeScriptView Raw
1import type { Codec, CodecClass, IU8a } from '@polkadot/types-codec/types';
2import type { CreateOptions, TypeDef } from '@polkadot/types-create/types';
3import type { ExtDef } from '../extrinsic/signedExtensions/types';
4import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8a, Hash, MetadataLatest, SiLookupTypeId } from '../interfaces/types';
5import type { CallFunction, CodecHasher, DetectCodec, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
6import { GenericEventData } from '../generic/Event';
7import { Metadata } from '../metadata/Metadata';
8import { PortableRegistry } from '../metadata/PortableRegistry';
9export declare class TypeRegistry implements Registry {
10 #private;
11 createdAtHash?: Hash;
12 constructor(createdAtHash?: Hash | Uint8Array | string);
13 get chainDecimals(): number[];
14 get chainSS58(): number | undefined;
15 get chainTokens(): string[];
16 /**
17 * @description Returns true if the type is in a Compat format
18 */
19 isLookupType(value: string): boolean;
20 /**
21 * @description Creates a lookup string from the supplied id
22 */
23 createLookupType(lookupId: SiLookupTypeId | number): string;
24 get knownTypes(): RegisteredTypes;
25 get lookup(): PortableRegistry;
26 get metadata(): MetadataLatest;
27 get unknownTypes(): string[];
28 get signedExtensions(): string[];
29 clearCache(): void;
30 /**
31 * @describe Creates an instance of the class
32 */
33 createClass<T extends Codec = Codec, K extends string = string>(type: K): CodecClass<DetectCodec<T, K>>;
34 /**
35 * @describe Creates an instance of the class
36 */
37 createClassUnsafe<T extends Codec = Codec, K extends string = string>(type: K): CodecClass<T>;
38 /**
39 * @description Creates an instance of a type as registered
40 */
41 createType<T extends Codec = Codec, K extends string = string>(type: K, ...params: unknown[]): DetectCodec<T, K>;
42 /**
43 * @description Creates an instance of a type as registered
44 */
45 createTypeUnsafe<T extends Codec = Codec, K extends string = string>(type: K, params: unknown[], options?: CreateOptions): T;
46 findMetaCall(callIndex: Uint8Array): CallFunction;
47 findMetaError(errorIndex: Uint8Array | DispatchErrorModule | DispatchErrorModuleU8a): RegistryError;
48 findMetaEvent(eventIndex: Uint8Array): CodecClass<GenericEventData>;
49 get<T extends Codec = Codec, K extends string = string>(name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<T> | undefined;
50 getUnsafe<T extends Codec = Codec, K extends string = string>(name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<T> | undefined;
51 getChainProperties(): ChainProperties | undefined;
52 getClassName(Type: CodecClass): string | undefined;
53 getDefinition(typeName: string): string | undefined;
54 getModuleInstances(specName: string, moduleName: string): string[] | undefined;
55 getOrThrow<T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>>(name: K, msg?: string): CodecClass<R>;
56 getOrUnknown<T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>>(name: K): CodecClass<R>;
57 getSignedExtensionExtra(): Record<string, string>;
58 getSignedExtensionTypes(): Record<string, string>;
59 hasClass(name: string): boolean;
60 hasDef(name: string): boolean;
61 hasType(name: string): boolean;
62 hash(data: Uint8Array): IU8a;
63 register(type: CodecClass | RegistryTypes): void;
64 register(name: string, type: CodecClass): void;
65 private _registerObject;
66 setChainProperties(properties?: ChainProperties): void;
67 setHasher(hasher?: CodecHasher | null): void;
68 setKnownTypes(knownTypes: RegisteredTypes): void;
69 setLookup(lookup: PortableRegistry): void;
70 setMetadata(metadata: Metadata, signedExtensions?: string[], userExtensions?: ExtDef): void;
71 setSignedExtensions(signedExtensions?: string[], userExtensions?: ExtDef): void;
72}