1 |
|
2 | import { EventEmitter } from "events";
|
3 | export interface RequestArguments {
|
4 | readonly method: string;
|
5 | readonly params?: readonly unknown[] | object;
|
6 | }
|
7 | export interface ProviderRpcError extends Error {
|
8 | code: number;
|
9 | data?: unknown;
|
10 | }
|
11 | export interface ProviderMessage {
|
12 | readonly type: string;
|
13 | readonly data: unknown;
|
14 | }
|
15 | export interface EthSubscription extends ProviderMessage {
|
16 | readonly type: "eth_subscription";
|
17 | readonly data: {
|
18 | readonly subscription: string;
|
19 | readonly result: unknown;
|
20 | };
|
21 | }
|
22 | export interface ProviderConnectInfo {
|
23 | readonly chainId: string;
|
24 | }
|
25 | export interface EIP1193Provider extends EventEmitter {
|
26 | request(args: RequestArguments): Promise<unknown>;
|
27 | }
|
28 | export interface JsonRpcRequest {
|
29 | jsonrpc: string;
|
30 | method: string;
|
31 | params: any[];
|
32 | id: number;
|
33 | }
|
34 | export interface JsonRpcResponse {
|
35 | jsonrpc: string;
|
36 | id: number;
|
37 | result?: any;
|
38 | error?: {
|
39 | code: number;
|
40 | message: string;
|
41 | data?: any;
|
42 | };
|
43 | }
|
44 | export interface EthereumProvider extends EIP1193Provider {
|
45 | send(method: string, params?: any[]): Promise<any>;
|
46 | sendAsync(payload: JsonRpcRequest, callback: (error: any, response: JsonRpcResponse) => void): void;
|
47 | }
|
48 |
|
\ | No newline at end of file |