2020-10-05 22:46:12 +03:00
|
|
|
import { Network, Networkish } from "@ethersproject/networks";
|
2020-03-12 21:14:50 +03:00
|
|
|
import { Event } from "./base-provider";
|
|
|
|
import { JsonRpcProvider } from "./json-rpc-provider";
|
|
|
|
export declare type InflightRequest = {
|
|
|
|
callback: (error: Error, result: any) => void;
|
|
|
|
payload: string;
|
|
|
|
};
|
|
|
|
export declare type Subscription = {
|
|
|
|
tag: string;
|
|
|
|
processFunc: (payload: any) => void;
|
|
|
|
};
|
2022-03-09 10:56:08 +03:00
|
|
|
export interface WebSocketLike {
|
2022-08-18 21:48:39 +03:00
|
|
|
onopen: ((...args: Array<any>) => any) | null;
|
|
|
|
onmessage: ((...args: Array<any>) => any) | null;
|
|
|
|
onerror: ((...args: Array<any>) => any) | null;
|
2022-03-09 10:56:08 +03:00
|
|
|
readyState: number;
|
|
|
|
send(payload: any): void;
|
|
|
|
close(code?: number, reason?: string): void;
|
|
|
|
}
|
2020-03-12 21:14:50 +03:00
|
|
|
export declare class WebSocketProvider extends JsonRpcProvider {
|
|
|
|
readonly _websocket: any;
|
|
|
|
readonly _requests: {
|
|
|
|
[name: string]: InflightRequest;
|
|
|
|
};
|
2020-10-05 22:46:12 +03:00
|
|
|
readonly _detectNetwork: Promise<Network>;
|
2020-03-12 21:14:50 +03:00
|
|
|
readonly _subIds: {
|
|
|
|
[tag: string]: Promise<string>;
|
|
|
|
};
|
|
|
|
readonly _subs: {
|
|
|
|
[name: string]: Subscription;
|
|
|
|
};
|
|
|
|
_wsReady: boolean;
|
2022-03-09 10:56:08 +03:00
|
|
|
constructor(url: string | WebSocketLike, network?: Networkish);
|
|
|
|
get websocket(): WebSocketLike;
|
2020-10-05 22:46:12 +03:00
|
|
|
detectNetwork(): Promise<Network>;
|
2020-03-22 21:57:17 +03:00
|
|
|
get pollingInterval(): number;
|
2020-03-12 21:14:50 +03:00
|
|
|
resetEventsBlock(blockNumber: number): void;
|
2020-03-22 21:57:17 +03:00
|
|
|
set pollingInterval(value: number);
|
2020-03-12 21:14:50 +03:00
|
|
|
poll(): Promise<void>;
|
2020-03-22 21:57:17 +03:00
|
|
|
set polling(value: boolean);
|
2020-03-12 21:14:50 +03:00
|
|
|
send(method: string, params?: Array<any>): Promise<any>;
|
|
|
|
static defaultUrl(): string;
|
|
|
|
_subscribe(tag: string, param: Array<any>, processFunc: (result: any) => void): Promise<void>;
|
|
|
|
_startEvent(event: Event): void;
|
|
|
|
_stopEvent(event: Event): void;
|
2020-07-13 15:03:56 +03:00
|
|
|
destroy(): Promise<void>;
|
2020-03-12 21:14:50 +03:00
|
|
|
}
|
2021-01-19 13:22:54 +03:00
|
|
|
//# sourceMappingURL=websocket-provider.d.ts.map
|