UNPKG

6.72 kBTypeScriptView Raw
1import type { RpcCoreStats, RpcInterface } from '@polkadot/rpc-core/types';
2import type { Text } from '@polkadot/types';
3import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
4import type { Metadata } from '@polkadot/types/metadata';
5import type { CallFunction, RegistryError } from '@polkadot/types/types';
6import type { ApiDecoration, ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types/index.js';
7import { Init } from './Init.js';
8export declare abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> implements ApiDecoration<ApiType> {
9 /**
10 * @description Runtime call interfaces (currently untyped, only decorated via API options)
11 */
12 get call(): QueryableCalls<ApiType>;
13 /**
14 * @description Contains the parameter types (constants) of all modules.
15 *
16 * The values are instances of the appropriate type and are accessible using `section`.`constantName`,
17 *
18 * @example
19 * <BR>
20 *
21 * ```javascript
22 * console.log(api.consts.democracy.enactmentPeriod.toString())
23 * ```
24 */
25 get consts(): QueryableConsts<ApiType>;
26 /**
27 * @description Derived results that are injected into the API, allowing for combinations of various query results.
28 *
29 * @example
30 * <BR>
31 *
32 * ```javascript
33 * api.derive.chain.bestNumber((number) => {
34 * console.log('best number', number);
35 * });
36 * ```
37 */
38 get derive(): ReturnType<Getters<ApiType>['_decorateDerive']>;
39 /**
40 * @description Errors from metadata
41 */
42 get errors(): DecoratedErrors<ApiType>;
43 /**
44 * @description Events from metadata
45 */
46 get events(): DecoratedEvents<ApiType>;
47 /**
48 * @description Returns the version of extrinsics in-use on this chain
49 */
50 get extrinsicVersion(): number;
51 /**
52 * @description Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
53 */
54 get genesisHash(): Hash;
55 /**
56 * @description true is the underlying provider is connected
57 */
58 get isConnected(): boolean;
59 /**
60 * @description The library information name & version (from package.json)
61 */
62 get libraryInfo(): string;
63 /**
64 * @description Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
65 *
66 * All calls inside the namespace, is denoted by `section`.`method` and may take an optional query parameter. As an example, `api.query.timestamp.now()` (current block timestamp) does not take parameters, while `api.query.system.account(<accountId>)` (retrieving the associated nonce & balances for an account), takes the `AccountId` as a parameter.
67 *
68 * @example
69 * <BR>
70 *
71 * ```javascript
72 * api.query.system.account(<accountId>, ([nonce, balance]) => {
73 * console.log('new free balance', balance.free, 'new nonce', nonce);
74 * });
75 * ```
76 */
77 get query(): QueryableStorage<ApiType>;
78 /**
79 * @description Allows for the querying of multiple storage entries and the combination thereof into a single result. This is a very optimal way to make multiple queries since it only makes a single connection to the node and retrieves the data over one subscription.
80 *
81 * @example
82 * <BR>
83 *
84 * ```javascript
85 * const unsub = await api.queryMulti(
86 * [
87 * // you can include the storage without any parameters
88 * api.query.balances.totalIssuance,
89 * // or you can pass parameters to the storage query
90 * [api.query.system.account, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']
91 * ],
92 * ([existential, [, { free }]]) => {
93 * console.log(`You have ${free.sub(existential)} more than the existential deposit`);
94 *
95 * unsub();
96 * }
97 * );
98 * ```
99 */
100 get queryMulti(): QueryableStorageMulti<ApiType>;
101 /**
102 * @description Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic `api.query` and `api.tx` sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
103 *
104 * RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (using known keys) and the submission of transactions.
105 *
106 * @example
107 * <BR>
108 *
109 * ```javascript
110 * api.rpc.chain.subscribeNewHeads((header) => {
111 * console.log('new header', header);
112 * });
113 * ```
114 */
115 get rpc(): DecoratedRpc<ApiType, RpcInterface>;
116 /**
117 * @description Contains the chain information for the current node.
118 */
119 get runtimeChain(): Text;
120 /**
121 * @description Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
122 */
123 get runtimeMetadata(): Metadata;
124 /**
125 * @description Contains the version information for the current runtime.
126 */
127 get runtimeVersion(): RuntimeVersion;
128 /**
129 * @description The underlying Rx API interface
130 */
131 get rx(): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query' | 'call'>;
132 /**
133 * @description Returns the underlying provider stats
134 */
135 get stats(): RpcCoreStats | undefined;
136 /**
137 * @description The type of this API instance, either 'rxjs' or 'promise'
138 */
139 get type(): ApiTypes;
140 /**
141 * @description Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
142 *
143 * @example
144 * <BR>
145 *
146 * ```javascript
147 * api.tx.balances
148 * .transferAllowDeath(<recipientId>, <balance>)
149 * .signAndSend(<keyPair>, ({status}) => {
150 * console.log('tx status', status.asFinalized.toHex());
151 * });
152 * ```
153 */
154 get tx(): SubmittableExtrinsics<ApiType>;
155 /**
156 * @description Finds the definition for a specific [[CallFunction]] based on the index supplied
157 */
158 findCall(callIndex: Uint8Array | string): CallFunction;
159 /**
160 * @description Finds the definition for a specific [[RegistryError]] based on the index supplied
161 */
162 findError(errorIndex: Uint8Array | string): RegistryError;
163}