UNPKG

4.16 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 chainIsEthereum(): boolean;
15 get chainSS58(): number | undefined;
16 get chainTokens(): string[];
17 get firstCallIndex(): Uint8Array;
18 /**
19 * @description Returns true if the type is in a Compat format
20 */
21 isLookupType(value: string): value is LookupString;
22 /**
23 * @description Creates a lookup string from the supplied id
24 */
25 createLookupType(lookupId: SiLookupTypeId | number): LookupString;
26 get knownTypes(): RegisteredTypes;
27 get lookup(): PortableRegistry;
28 get metadata(): MetadataLatest;
29 get unknownTypes(): string[];
30 get signedExtensions(): string[];
31 clearCache(): void;
32 /**
33 * @describe Creates an instance of the class
34 */
35 createClass<T extends Codec = Codec, K extends string = string>(type: K): CodecClass<DetectCodec<T, K>>;
36 /**
37 * @describe Creates an instance of the class
38 */
39 createClassUnsafe<T extends Codec = Codec, K extends string = string>(type: K): CodecClass<T>;
40 /**
41 * @description Creates an instance of a type as registered
42 */
43 createType<T extends Codec = Codec, K extends string = string>(type: K, ...params: unknown[]): DetectCodec<T, K>;
44 /**
45 * @description Creates an instance of a type as registered
46 */
47 createTypeUnsafe<T extends Codec = Codec, K extends string = string>(type: K, params: unknown[], options?: CreateOptions): T;
48 findMetaCall(callIndex: Uint8Array): CallFunction;
49 findMetaError(errorIndex: Uint8Array | DispatchErrorModule | DispatchErrorModuleU8 | DispatchErrorModuleU8a): RegistryError;
50 findMetaEvent(eventIndex: Uint8Array): CodecClass<GenericEventData>;
51 get<T extends Codec = Codec, K extends string = string>(name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<T> | undefined;
52 getUnsafe<T extends Codec = Codec, K extends string = string>(name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<T> | undefined;
53 getChainProperties(): ChainProperties | undefined;
54 getClassName(Type: CodecClass): string | undefined;
55 getDefinition(typeName: string): string | undefined;
56 getModuleInstances(specName: AnyString, moduleName: string): string[] | undefined;
57 getOrThrow<T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>>(name: K): CodecClass<R>;
58 getOrUnknown<T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>>(name: K): CodecClass<R>;
59 getSignedExtensionExtra(): Record<string, string>;
60 getSignedExtensionTypes(): Record<string, string>;
61 hasClass(name: string): boolean;
62 hasDef(name: string): boolean;
63 hasType(name: string): boolean;
64 hash(data: Uint8Array): IU8a;
65 register(type: CodecClass | RegistryTypes): void;
66 register(name: string, type: CodecClass): void;
67 setChainProperties(properties?: ChainProperties): void;
68 setHasher(hasher?: CodecHasher | null): void;
69 setKnownTypes(knownTypes: RegisteredTypes): void;
70 setLookup(lookup: PortableRegistry): void;
71 setMetadata(metadata: Metadata, signedExtensions?: string[], userExtensions?: ExtDef, noInitWarn?: boolean): void;
72 setSignedExtensions(signedExtensions?: string[], userExtensions?: ExtDef, noInitWarn?: boolean): void;
73}