export type Json = boolean | number | string | null | { [property: string]: Json; } | Json[]; export type JRPCVersion = "2.0"; export type JRPCId = number | string | void; export type ConsoleLike = Pick; export interface JRPCBase { jsonrpc?: JRPCVersion; id?: JRPCId; } export interface JRPCResponse extends JRPCBase { result?: T; error?: any; } export interface JRPCRequest extends JRPCBase { method: string; params?: T; } export type JRPCEngineNextCallback = (cb?: (done: (error?: Error) => void) => void) => void; export type JRPCEngineEndCallback = (error?: Error) => void; export type JRPCEngineReturnHandler = (done: (error?: Error) => void) => void; interface IdMapValue { req: JRPCRequest; res: JRPCResponse; next: JRPCEngineNextCallback; end: JRPCEngineEndCallback; } export interface IdMap { [requestId: string]: IdMapValue; } export type JRPCMiddleware = (req: JRPCRequest, res: JRPCResponse, next: JRPCEngineNextCallback, end: JRPCEngineEndCallback) => void; export type AsyncJRPCEngineNextCallback = () => Promise; export type Maybe = T | Partial | null | undefined; export interface JRPCSuccess extends JRPCBase { result: Maybe; } /** * A data object, that must be either: * * - A JSON-serializable object. * - An object with a `cause` property that is an error-like value, and any * other properties that are JSON-serializable. */ export type DataWithOptionalCause = Json | { [key: string]: Json | unknown; cause?: unknown; }; /** * A data object, that must be either: * * - A valid DataWithOptionalCause value. * - undefined. */ export type OptionalDataWithOptionalCause = undefined | DataWithOptionalCause; export interface JRPCError { code: number; message: string; data?: DataWithOptionalCause; stack?: string; } export interface PendingJRPCResponse extends JRPCBase { result?: T; error?: Error | JRPCError; } export interface JRPCFailure extends JRPCBase { error: JRPCError; } export type AsyncJRPCMiddleware = (req: JRPCRequest, res: PendingJRPCResponse, next: AsyncJRPCEngineNextCallback) => Promise; export type ReturnHandlerCallback = (error: null | Error) => void; export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; export type BlockData = string | string[]; export type Block = Record; export type SendAsyncCallBack = (err: Error, providerRes: JRPCResponse) => void; export type SendCallBack = (err: any, providerRes: U) => void; export type Payload = Partial>; export interface RequestArguments { method: string; params?: T; } export interface ExtendedJsonRpcRequest extends JRPCRequest { skipCache?: boolean; } export {};