1.1.0 • Published 3 years ago
rpc-json-types v1.1.0
rpc-json-types
JSON-RPC Types
API
// ---------- Typings ----------------------------------------------- //
interface JsonRpcRequest<T = any> {
id: number;
jsonrpc: string;
method: string;
params: T;
}
interface JsonRpcResult<T = any> {
id: number;
jsonrpc: string;
result: T;
}
interface JsonRpcError {
id: number;
jsonrpc: string;
error: ErrorResponse;
}
interface ErrorResponse {
code: number;
message: string;
}
type JsonRpcResponse<T = any> = JsonRpcResult<T> | JsonRpcError;
type JsonRpcPayload<P = any, R = any> = JsonRpcRequest<P> | JsonRpcResponse<R>;