1 |
|
2 | import type { Observable } from 'rxjs';
|
3 | import type { AugmentedCall, QueryableCalls } from '@polkadot/api-base/types';
|
4 | import type { RpcInterface } from '@polkadot/rpc-core/types';
|
5 | import type { Metadata, Text } from '@polkadot/types';
|
6 | import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
7 | import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
8 | import type { AnyFunction, Codec, DefinitionCallNamed, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, DefinitionsCallEntry, DetectCodec, Registry, RegistryTypes } from '@polkadot/types/types';
|
9 | import type { HexString } from '@polkadot/util/types';
|
10 | import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types/index.js';
|
11 | import type { AllDerives } from '../util/decorate.js';
|
12 | import type { VersionedRegistry } from './types.js';
|
13 | import { BehaviorSubject } from 'rxjs';
|
14 | import { RpcCore } from '@polkadot/rpc-core';
|
15 | import { BN } from '@polkadot/util';
|
16 | import { Events } from './Events.js';
|
17 | interface FullDecoration<ApiType extends ApiTypes> {
|
18 | createdAt?: Uint8Array | undefined;
|
19 | decoratedApi: ApiDecoration<ApiType>;
|
20 | decoratedMeta: DecoratedMeta;
|
21 | }
|
22 | export declare abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
23 | #private;
|
24 | protected __phantom: BN;
|
25 | protected _type: ApiTypes;
|
26 | protected _call: QueryableCalls<ApiType>;
|
27 | protected _consts: QueryableConsts<ApiType>;
|
28 | protected _derive?: ReturnType<Decorate<ApiType>['_decorateDerive']>;
|
29 | protected _errors: DecoratedErrors<ApiType>;
|
30 | protected _events: DecoratedEvents<ApiType>;
|
31 | protected _extrinsics?: SubmittableExtrinsics<ApiType>;
|
32 | protected _extrinsicType: number;
|
33 | protected _genesisHash?: Hash;
|
34 | protected _isConnected: BehaviorSubject<boolean>;
|
35 | protected _isReady: boolean;
|
36 | protected _query: QueryableStorage<ApiType>;
|
37 | protected _queryMulti?: QueryableStorageMulti<ApiType>;
|
38 | protected _rpc?: DecoratedRpc<ApiType, RpcInterface>;
|
39 | protected _rpcCore: RpcCore & RpcInterface;
|
40 | protected _runtimeMap: Record<HexString, string>;
|
41 | protected _runtimeChain?: Text;
|
42 | protected _runtimeMetadata?: Metadata;
|
43 | protected _runtimeVersion?: RuntimeVersion;
|
44 | protected _rx: ApiInterfaceRx;
|
45 | protected readonly _options: ApiOptions;
|
46 | |
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | protected _decorateMethod: DecorateMethod<ApiType>;
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | constructor(options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>);
|
82 | abstract at(blockHash: Uint8Array | string, knownVersion?: RuntimeVersion): Promise<ApiDecoration<ApiType>>;
|
83 | /**
|
84 | * @description Return the current used registry
|
85 | */
|
86 | get registry(): Registry;
|
87 | /**
|
88 | * @description Creates an instance of a type as registered
|
89 | */
|
90 | createType<T extends Codec = Codec, K extends string = string>(type: K, ...params: unknown[]): DetectCodec<T, K>;
|
91 | /**
|
92 | * @description Register additional user-defined of chain-specific types in the type registry
|
93 | */
|
94 | registerTypes(types?: RegistryTypes): void;
|
95 | /**
|
96 | * @returns `true` if the API operates with subscriptions
|
97 | */
|
98 | get hasSubscriptions(): boolean;
|
99 | /**
|
100 | * @returns `true` if the API decorate multi-key queries
|
101 | */
|
102 | get supportMulti(): boolean;
|
103 | protected _emptyDecorated(registry: Registry, blockHash?: Uint8Array): ApiDecoration<ApiType>;
|
104 | protected _createDecorated(registry: VersionedRegistry<ApiType>, fromEmpty: boolean, decoratedApi: ApiDecoration<ApiType> | null, blockHash?: Uint8Array): FullDecoration<ApiType>;
|
105 | protected _injectMetadata(registry: VersionedRegistry<ApiType>, fromEmpty?: boolean): void;
|
106 | /**
|
107 | * @deprecated
|
108 | * backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
|
109 | */
|
110 | injectMetadata(metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void;
|
111 | private _decorateFunctionMeta;
|
112 | protected _filterRpc(methods: string[], additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void;
|
113 | protected _filterRpcMethods(exposed: string[]): void;
|
114 | private _rpcSubmitter;
|
115 | protected _decorateRpc<ApiType extends ApiTypes>(rpc: RpcCore & RpcInterface, decorateMethod: DecorateMethod<ApiType>, input?: Partial<DecoratedRpc<ApiType, RpcInterface>>): DecoratedRpc<ApiType, RpcInterface>;
|
116 | protected _addRuntimeDef(result: DefinitionsCall, additional?: DefinitionsCall): void;
|
117 | protected _getRuntimeDefs(registry: Registry, specName: Text, chain?: Text | string): [string, DefinitionsCallEntry[]][];
|
118 | protected _decorateCalls<ApiType extends ApiTypes>({ registry, runtimeVersion: { apis, specName, specVersion } }: VersionedRegistry<any>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType>;
|
119 | protected _decorateCall<ApiType extends ApiTypes>(registry: Registry, def: DefinitionCallNamed, stateCall: (method: string, bytes: Uint8Array) => Observable<Codec>, decorateMethod: DecorateMethod<ApiType>): AugmentedCall<ApiType>;
|
120 | protected _decorateMulti<ApiType extends ApiTypes>(decorateMethod: DecorateMethod<ApiType>): QueryableStorageMulti<ApiType>;
|
121 | protected _decorateMultiAt<ApiType extends ApiTypes>(atApi: ApiDecoration<ApiType>, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array | string): QueryableStorageMulti<ApiType>;
|
122 | protected _decorateExtrinsics<ApiType extends ApiTypes>({ tx }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>): SubmittableExtrinsics<ApiType>;
|
123 | private _decorateExtrinsicEntry;
|
124 | protected _decorateStorage<ApiType extends ApiTypes>({ query, registry }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array): QueryableStorage<ApiType>;
|
125 | private _decorateStorageEntry;
|
126 | private _decorateStorageEntryAt;
|
127 | private _queueStorage;
|
128 | private _decorateStorageCall;
|
129 | private _retrieveMulti;
|
130 | private _retrieveMapKeys;
|
131 | private _retrieveMapKeysPaged;
|
132 | private _retrieveMapEntries;
|
133 | private _retrieveMapEntriesPaged;
|
134 | protected _decorateDeriveRx(decorateMethod: DecorateMethod<ApiType>): AllDerives<'rxjs'>;
|
135 | protected _decorateDerive(decorateMethod: DecorateMethod<ApiType>): AllDerives<ApiType>;
|
136 | /**
|
137 | * Put the `this.onCall` function of ApiRx here, because it is needed by
|
138 | * `api._rx`.
|
139 | */
|
140 | protected _rxDecorateMethod: <Method extends AnyFunction>(method: Method) => Method;
|
141 | }
|
142 | export {};
|