UNPKG

1.31 kBTypeScriptView Raw
1/// <reference types="node" />
2import { EventEmitter } from "events";
3export interface RequestArguments {
4 readonly method: string;
5 readonly params?: readonly unknown[] | object;
6}
7export interface ProviderRpcError extends Error {
8 code: number;
9 data?: unknown;
10}
11export interface ProviderMessage {
12 readonly type: string;
13 readonly data: unknown;
14}
15export interface EthSubscription extends ProviderMessage {
16 readonly type: "eth_subscription";
17 readonly data: {
18 readonly subscription: string;
19 readonly result: unknown;
20 };
21}
22export interface ProviderConnectInfo {
23 readonly chainId: string;
24}
25export interface EIP1193Provider extends EventEmitter {
26 request(args: RequestArguments): Promise<unknown>;
27}
28export interface JsonRpcRequest {
29 jsonrpc: string;
30 method: string;
31 params: any[];
32 id: number;
33}
34export interface JsonRpcResponse {
35 jsonrpc: string;
36 id: number;
37 result?: any;
38 error?: {
39 code: number;
40 message: string;
41 data?: any;
42 };
43}
44export 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//# sourceMappingURL=provider.d.ts.map
\No newline at end of file