forked from web3/web3.js
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproviders.d.ts
69 lines (64 loc) · 1.94 KB
/
providers.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
interface JsonRPCRequest {
jsonrpc: string;
method: string;
params: any[];
id: number;
}
interface JsonRPCResponse {
jsonrpc: string;
id: number;
result?: any;
error?: string;
}
interface Callback<ResultType> {
(error: Error): void;
(error: null, val: ResultType): void;
}
export class Provider {
type: string;
send(payload: JsonRPCRequest, callback: Callback<JsonRPCResponse>): any;
genCall(method: string): string;
}
export class WebsocketProvider extends Provider {
responseCallbacks: object;
notificationCallbacks: [() => any];
connection: {
onclose(e: any): void;
onmessage(e: any): void;
onerror(e?: any): void;
};
addDefaultEvents: () => void;
on(type: string, callback: () => any): void;
removeListener(type: string, callback: () => any): void;
removeAllListeners(type: string): void;
reset(): void;
}
export class HttpProvider extends Provider {
responseCallbacks: undefined;
notificationCallbacks: undefined;
connection: undefined;
addDefaultEvents: undefined;
on(type: string, callback: () => any): undefined;
removeListener(type: string, callback: () => any): undefined;
removeAllListeners(type: string): undefined;
reset(): undefined;
}
export class IpcProvider extends Provider {
responseCallbacks: undefined;
notificationCallbacks: undefined;
connection: undefined;
addDefaultEvents: undefined;
on(type: string, callback: () => any): undefined;
removeListener(type: string, callback: () => any): undefined;
removeAllListeners(type: string): undefined;
reset(): undefined;
}
export default interface Providers {
WebsocketProvider: new (
host: string,
type?: string,
timeout?: number
) => WebsocketProvider;
HttpProvider: new (host: string, type?: string, timeout?: number) => HttpProvider;
IpcProvider: new (path: string, net: any, type?: string) => IpcProvider;
}