1 |
|
2 |
|
3 |
|
4 |
|
5 | export type JsonRpcObject = {
|
6 | id: number;
|
7 | jsonrpc: '2.0';
|
8 | };
|
9 |
|
10 | export type JsonRpcRequest = JsonRpcObject & {
|
11 | method: string;
|
12 | params: Array<any>;
|
13 | };
|
14 |
|
15 | export type JsonRpcResponseBase$Error = {
|
16 | code: number,
|
17 | message: string
|
18 | };
|
19 |
|
20 | type JsonRpcResponse$Single = {
|
21 | error?: JsonRpcResponseBase$Error;
|
22 | result?: any;
|
23 | };
|
24 |
|
25 | type JsonRpcResponse$Subscription = {
|
26 | method?: string;
|
27 | params: {
|
28 | error?: JsonRpcResponseBase$Error;
|
29 | result: any;
|
30 | subscription: number;
|
31 | }
|
32 | };
|
33 |
|
34 | export type JsonRpcResponseBase = JsonRpcResponse$Single & JsonRpcResponse$Subscription;
|
35 |
|
36 | export type JsonRpcResponse = JsonRpcObject & JsonRpcResponseBase;
|
37 |
|
38 | export type ProviderInterface$Callback = (error: Error | null, result: any) => void;
|
39 |
|
40 | export type ProviderInterface$Emitted = 'connected' | 'disconnected';
|
41 |
|
42 | export type ProviderInterface$EmitCb = (value?: any) => any;
|
43 |
|
44 | export interface ProviderInterface {
|
45 | isConnected (): boolean,
|
46 | on (type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void,
|
47 | send (method: string, params: Array<any>): Promise<any>,
|
48 | subscribe (type: string, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number>,
|
49 | unsubscribe (type: string, method: string, id: number): Promise<boolean>
|
50 | }
|