diff --git a/src/tools/rpc-proxy.ts b/src/tools/rpc-proxy.ts index 7805cd4..8655841 100644 --- a/src/tools/rpc-proxy.ts +++ b/src/tools/rpc-proxy.ts @@ -37,6 +37,7 @@ export function createRPCProxy(network: Network, targetRpcUrl: string, port: num } const txFile = path.resolve(settings.devnet.transactionsPath, `${txHash}.json`); fs.writeFileSync(txFile, JSON.stringify(tx, null, 2)); + console.debug(`RPC Req: store tx ${txHash}`); } } } catch (err) { @@ -45,6 +46,25 @@ export function createRPCProxy(network: Network, targetRpcUrl: string, port: num }); }); + proxy.on('proxyRes', function (proxyRes, _req, _res) { + const body: Buffer[] = []; + proxyRes.on('data', function (chunk) { + body.push(chunk); + }); + proxyRes.on('end', function () { + const res = Buffer.concat(body).toString(); + try { + const jsonRpcResponse = JSON.parse(res); + const error = jsonRpcResponse.error; + if (error) { + console.debug('RPC Response: ', jsonRpcResponse); + } + } catch (err) { + console.error('Error parsing JSON-RPC content:', err); + } + }); + }); + const server = http.createServer((req, res) => { proxy.web(req, res, {}, (err) => { if (err) {