/// import type EventEmitter from 'events'; import type { Duplex } from 'readable-stream'; import type { JsonRpcEngine, JsonRpcId, JsonRpcVersion, JsonRpcError, JsonRpcEngineNextCallback, JsonRpcEngineEndCallback } from 'json-rpc-engine'; export interface RpcInfo { id: JsonRpcId; jsonrpc: JsonRpcVersion; } export interface RpcRequestParams { method: string; params?: Record | any[]; chainId?: string; } export interface RpcResponseResult { error?: Error | JsonRpcError; result?: T; } export type RpcRequest = RpcInfo & RpcRequestParams; export type RpcResponse = RpcInfo & RpcResponseResult; export type RpcMethodMiddleware = (req: RpcRequest, res: RpcResponse, next: JsonRpcEngineNextCallback, end: JsonRpcEngineEndCallback, options?: Record) => void; export type RpcMethodMiddlewareWithEngine = (req: RpcRequest, res: RpcResponse, next: JsonRpcEngineNextCallback, end: JsonRpcEngineEndCallback, engine?: JsonRpcEngine) => void; export interface RpcConnection { events: EventEmitter; stream: Duplex; middleware: RpcMethodMiddleware; }