UNPKG

1.53 kBTypeScriptView Raw
1import { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
2import './polyfill';
3/**
4 * The HTTP Provider allows sending requests using HTTP. it does not support subscriptions
5 * so you won´t be able to listen to events such as new blocks or balance changes.
6 * It is usually preferrable using the [[WsProvider]].
7 *
8 * @example
9 * import createApi from '@polkadot/api';
10 * import WsProvider from '@polkadot/api-provider/ws';
11 *
12 * const provider = new WsProvider('http://127.0.0.1:9933');
13 * const api = createApi(provider);
14 *
15 * @see [[WsProvider]]
16 */
17export default class HttpProvider implements ProviderInterface {
18 private coder;
19 private endpoint;
20 private l;
21 constructor(endpoint: string);
22 /**
23 * Whether the node is connected or not.
24 * @return {boolean} true if connected
25 */
26 isConnected(): boolean;
27 /**
28 * Events are not supported with the HttpProvider, see [[WsProvider]].
29 */
30 on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void;
31 send(method: string, params: Array<any>): Promise<any>;
32 /**
33 * Subscriptions are not supported with the HttpProvider, see [[WsProvider]].
34 */
35 subscribe(types: string, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number>;
36 /**
37 * Subscriptions are not supported with the HttpProvider, see [[WsProvider]].
38 */
39 unsubscribe(type: string, method: string, id: number): Promise<boolean>;
40}