Abstract class to handle JSON-RPC 2.0 calls, used by rpc-request and rpc-stream.
yarn add @erebos/rpc-baseimport BaseRPC from '@erebos/rpc-base'
class MyRPC extends BaseRPC {
request(...params: any): Promise<any> {
// ...
}
}type RPCID = string | number | nullinterface RPCRequest<T = any> {
jsonrpc: '2.0'
method: string
id?: RPCID
params?: T
}interface RPCErrorObject<T = any> {
code: number;
message?: ?string;
data?: T;
}interface RPCResponse<T = any, E = any> {
jsonrpc: '2.0';
id: RPCID;
result?: T;
error?: RPCErrorObject<E>;
}Arguments
canSubscribe: boolean = false: whether subscription calls (using a stateful connection) are supported by the implementation or not.
Returns boolean
Returns string: an unique ID for RPC calls.
Arguments
method: stringparams?: P
Returns Promise<T = any>
MIT