UNPKG

4.81 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';
16import type { SubmittableExtrinsic } from '../types/submittable';
17import type { AllDerives } from '../util/decorate';
18export * from '@polkadot/api-base/types';
19export * from '@polkadot/api/types/calls';
20export * from '@polkadot/api/types/consts';
21export * from '@polkadot/api/types/errors';
22export * from '@polkadot/api/types/events';
23export * from '@polkadot/api/types/storage';
24export * from '@polkadot/api/types/submittable';
25export type { Signer, SignerResult } from '@polkadot/types/types';
26export { ApiBase } from '../base';
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 pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
41 * if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
42 */
43 metadata?: Record<string, HexString>;
44 /**
45 * @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
46 */
47 noInitWarn?: boolean;
48 /**
49 * @description Transport Provider from rpc-provider. If not specified, it will default to
50 * connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
51 */
52 provider?: ProviderInterface;
53 /**
54 * @description A type registry to use along with this instance
55 */
56 registry?: Registry;
57 /**
58 * @description User-defined RPC methods
59 */
60 rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
61 /**
62 * @description Overrides for state_call usage (this will be removed in some future version)
63 */
64 runtime?: DefinitionsCall;
65 /**
66 * @description Any chain-specific signed extensions that are now well-known
67 */
68 signedExtensions?: ExtDef;
69 /**
70 * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
71 */
72 signer?: Signer;
73 /**
74 * @description The source object to use for runtime information (only used when cloning)
75 */
76 source?: ApiBase<any>;
77 /**
78 * @description Throws an error when the initial connection fails (same as isReadyOrError)
79 */
80 throwOnConnect?: boolean;
81 /**
82 * @description Throws an error when some types are unknown (useful with throwOnConnect)
83 */
84 throwOnUnknown?: boolean;
85}
86export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready' | 'decorated';
87export interface SignerOptions extends SignatureOptions {
88 blockNumber: BN;
89 genesisHash: Hash;
90}
91export interface ApiDecoration<ApiType extends ApiTypes> {
92 call: QueryableCalls<ApiType>;
93 consts: QueryableConsts<ApiType>;
94 errors: DecoratedErrors<ApiType>;
95 events: DecoratedEvents<ApiType>;
96 query: QueryableStorage<ApiType>;
97 registry: Registry;
98 runtimeVersion: RuntimeVersionPartial;
99 rx: {
100 call: QueryableCalls<'rxjs'>;
101 query: QueryableStorage<'rxjs'>;
102 };
103 tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
104 findCall(callIndex: Uint8Array | string): CallFunction;
105 findError(errorIndex: Uint8Array | string): RegistryError;
106 queryMulti: QueryableStorageMulti<ApiType>;
107}