UNPKG

1.62 kBTypeScriptView Raw
1import type { SignerPayloadRawBase } from '@polkadot/types/types';
2import type { ApiOptions, ApiTypes, DecorateMethod, Signer } from '../types';
3import { Getters } from './Getters';
4interface KeyringSigner {
5 sign(message: Uint8Array): Uint8Array;
6}
7interface SignerRawOptions {
8 signer?: Signer;
9}
10export declare abstract class ApiBase<ApiType extends ApiTypes> extends Getters<ApiType> {
11 /**
12 * @description Create an instance of the class
13 *
14 * @param options Options object to create API instance or a Provider instance
15 *
16 * @example
17 * <BR>
18 *
19 * ```javascript
20 * import Api from '@polkadot/api/promise';
21 *
22 * const api = new Api().isReady();
23 *
24 * api.rpc.subscribeNewHeads((header) => {
25 * console.log(`new block #${header.number.toNumber()}`);
26 * });
27 * ```
28 */
29 constructor(options: ApiOptions | undefined, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>);
30 /**
31 * @description Connect from the underlying provider, halting all network traffic
32 */
33 connect(): Promise<void>;
34 /**
35 * @description Disconnect from the underlying provider, halting all network traffic
36 */
37 disconnect(): Promise<void>;
38 /**
39 * @description Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
40 */
41 setSigner(signer: Signer): void;
42 /**
43 * @description Signs a raw signer payload, string or Uint8Array
44 */
45 sign(address: KeyringSigner | string, data: SignerPayloadRawBase, { signer }?: SignerRawOptions): Promise<string>;
46}
47export {};