UNPKG

ox

Version:

Ethereum Standard Library

19 lines 773 B
import * as RpcResponse from '../RpcResponse.js'; /** @internal */ export function create(transport, options_root) { let id = 0; return { request: async (request, options = {}) => { // Fast path: if the caller already provided a fully-formed JSON-RPC // request (id + jsonrpc), forward it directly without re-allocating. const body = request.jsonrpc === '2.0' && typeof request.id === 'number' ? request : { id: id++, ...request, jsonrpc: '2.0' }; const data = await transport.request(body, options); return RpcResponse.parse(data, { raw: options.raw ?? options_root?.raw, }); }, }; } //# sourceMappingURL=rpcTransport.js.map