UNPKG

4.25 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 { QueryableConsts } from '@polkadot/api-base/types/consts';
5import type { DecoratedErrors } from '@polkadot/api-base/types/errors';
6import type { DecoratedEvents } from '@polkadot/api-base/types/events';
7import type { QueryableStorage } from '@polkadot/api-base/types/storage';
8import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
9import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
10import type { Call, Extrinsic, Hash } from '@polkadot/types/interfaces';
11import type { CallFunction, DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, RegistryError, SignatureOptions, Signer } from '@polkadot/types/types';
12import type { BN } from '@polkadot/util';
13import type { HexString } from '@polkadot/util/types';
14import type { ApiBase } from '../base';
15import type { SubmittableExtrinsic } from '../types/submittable';
16import type { AllDerives } from '../util/decorate';
17export * from '@polkadot/api-base/types';
18export * from '@polkadot/api/types/consts';
19export * from '@polkadot/api/types/errors';
20export * from '@polkadot/api/types/events';
21export * from '@polkadot/api/types/storage';
22export * from '@polkadot/api/types/submittable';
23export { Signer, SignerResult } from '@polkadot/types/types';
24export { ApiBase } from '../base';
25export interface ApiInterfaceRx extends ApiInterfaceBase {
26 derive: AllDerives<'rxjs'>;
27}
28export interface ApiOptions extends RegisteredTypes {
29 /**
30 * @description Add custom derives to be injected
31 */
32 derives?: DeriveCustom;
33 /**
34 * @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)
35 */
36 initWasm?: boolean;
37 /**
38 * @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
39 * if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
40 */
41 metadata?: Record<string, HexString>;
42 /**
43 * @description Transport Provider from rpc-provider. If not specified, it will default to
44 * connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
45 */
46 provider?: ProviderInterface;
47 /**
48 * @description A type registry to use along with this instance
49 */
50 registry?: Registry;
51 /**
52 * @description User-defined RPC methods
53 */
54 rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
55 /**
56 * @description Any chain-specific signed extensions that are now well-known
57 */
58 signedExtensions?: ExtDef;
59 /**
60 * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
61 */
62 signer?: Signer;
63 /**
64 * @description The source object to use for runtime information (only used when cloning)
65 */
66 source?: ApiBase<any>;
67 /**
68 * @description Throws an error when the initial connection fails (same as isReadyOrError)
69 */
70 throwOnConnect?: boolean;
71 /**
72 * @description Throws an error when some types are unknown (useful with throwOnConnect)
73 */
74 throwOnUnknown?: boolean;
75}
76export declare type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready' | 'decorated';
77export interface SignerOptions extends SignatureOptions {
78 blockNumber: BN;
79 genesisHash: Hash;
80}
81export interface ApiDecoration<ApiType extends ApiTypes> {
82 consts: QueryableConsts<ApiType>;
83 errors: DecoratedErrors<ApiType>;
84 events: DecoratedEvents<ApiType>;
85 query: QueryableStorage<ApiType>;
86 registry: Registry;
87 rx: {
88 query: QueryableStorage<'rxjs'>;
89 };
90 tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
91 findCall(callIndex: Uint8Array | string): CallFunction;
92 findError(errorIndex: Uint8Array | string): RegistryError;
93 queryMulti: QueryableStorageMulti<ApiType>;
94}