UNPKG

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