UNPKG

5.07 kBTypeScriptView Raw
1/// <reference types="bn.js" />
2import type { ApiTypes, DeriveCustom, QueryableStorageMulti } from '@polkadot/api-base/types';
3import type { ApiInterfaceRx as ApiInterfaceBase } from '@polkadot/api-base/types/api';
4import type { QueryableCalls } from '@polkadot/api-base/types/calls';
5import type { QueryableConsts } from '@polkadot/api-base/types/consts';
6import type { DecoratedErrors } from '@polkadot/api-base/types/errors';
7import type { DecoratedEvents } from '@polkadot/api-base/types/events';
8import type { QueryableStorage } from '@polkadot/api-base/types/storage';
9import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
10import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
11import type { Call, Extrinsic, Hash, RuntimeVersionPartial } from '@polkadot/types/interfaces';
12import type { CallFunction, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, RegisteredTypes, Registry, RegistryError, SignatureOptions, Signer } from '@polkadot/types/types';
13import type { BN } from '@polkadot/util';
14import type { HexString } from '@polkadot/util/types';
15import type { ApiBase } from '../base/index.js';
16import type { SubmittableExtrinsic } from '../types/submittable.js';
17import type { AllDerives } from '../util/decorate.js';
18export type { Signer, SignerResult } from '@polkadot/types/types';
19export { ApiBase } from '../base/index.js';
20export * from '@polkadot/api/types/calls';
21export * from '@polkadot/api/types/consts';
22export * from '@polkadot/api/types/errors';
23export * from '@polkadot/api/types/events';
24export * from '@polkadot/api/types/storage';
25export * from '@polkadot/api/types/submittable';
26export * from '@polkadot/api-base/types';
27export interface ApiInterfaceRx extends ApiInterfaceBase {
28 derive: AllDerives<'rxjs'>;
29}
30export interface ApiOptions extends RegisteredTypes {
31 /**
32 * @description Add custom derives to be injected
33 */
34 derives?: DeriveCustom;
35 /**
36 * @description Control the initialization of the wasm libraries. When not specified, it defaults to `true`, initializing the wasm libraries, set to `false` to not initialize wasm. (No sr25519 support)
37 */
38 initWasm?: boolean;
39 /**
40 * @description Controls the checking of storage values once they have been contructed. When not specified this defaults to `true`. Set to `false` to forgo any checking on storage results.
41 */
42 isPedantic?: boolean;
43 /**
44 * @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
45 * if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
46 */
47 metadata?: Record<string, HexString>;
48 /**
49 * @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
50 */
51 noInitWarn?: boolean;
52 /**
53 * @description Transport Provider from rpc-provider. If not specified, it will default to
54 * connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
55 */
56 provider?: ProviderInterface;
57 /**
58 * @description A type registry to use along with this instance
59 */
60 registry?: Registry;
61 /**
62 * @description User-defined RPC methods
63 */
64 rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
65 /**
66 * @description Overrides for state_call usage (this will be removed in some future version)
67 */
68 runtime?: DefinitionsCall;
69 /**
70 * @description Any chain-specific signed extensions that are now well-known
71 */
72 signedExtensions?: ExtDef;
73 /**
74 * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
75 */
76 signer?: Signer;
77 /**
78 * @description The source object to use for runtime information (only used when cloning)
79 */
80 source?: ApiBase<any>;
81 /**
82 * @description Throws an error when the initial connection fails (same as isReadyOrError)
83 */
84 throwOnConnect?: boolean;
85 /**
86 * @description Throws an error when some types are unknown (useful with throwOnConnect)
87 */
88 throwOnUnknown?: boolean;
89}
90export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready' | 'decorated';
91export interface SignerOptions extends SignatureOptions {
92 blockNumber: BN;
93 genesisHash: Hash;
94}
95export interface ApiDecoration<ApiType extends ApiTypes> {
96 call: QueryableCalls<ApiType>;
97 consts: QueryableConsts<ApiType>;
98 errors: DecoratedErrors<ApiType>;
99 events: DecoratedEvents<ApiType>;
100 query: QueryableStorage<ApiType>;
101 registry: Registry;
102 runtimeVersion: RuntimeVersionPartial;
103 rx: {
104 call: QueryableCalls<'rxjs'>;
105 query: QueryableStorage<'rxjs'>;
106 };
107 tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
108 findCall(callIndex: Uint8Array | string): CallFunction;
109 findError(errorIndex: Uint8Array | string): RegistryError;
110 queryMulti: QueryableStorageMulti<ApiType>;
111}