export type JsonRpcRequest = { jsonrpc?: '2.0' id?: number method: string params?: any[] // ... chainId?: number } export type JsonRpcResponse = { jsonrpc?: string id: number result: any error?: JsonRpcErrorPayload } export type JsonRpcErrorPayload = { code: number message?: string data?: any } // EIP1193Provider with reponse of R (default any), but in most cases R will be of type JsonRpcResponse. export interface EIP1193Provider { request(request: { method: string; params?: any[]; chainId?: number }): Promise } export type EIP1193ProviderFunc = (request: { method: string; params?: any[]; chainId?: number }) => Promise export interface JsonRpcSender { send(method: string, params?: any[], chainId?: number): Promise } export type JsonRpcSendFunc = (method: string, params?: any[], chainId?: number) => Promise export type JsonRpcResponseCallback = (error: JsonRpcErrorPayload | undefined, response?: JsonRpcResponse) => void export type JsonRpcSendAsyncFunc = (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => void export type JsonRpcMiddleware = (next: EIP1193ProviderFunc) => EIP1193ProviderFunc export interface JsonRpcMiddlewareHandler { requestHandler: JsonRpcMiddleware }