From c289986440a719a47252e020157c1118fffa0e11 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 3 Jun 2024 14:28:29 +0200 Subject: [PATCH] log transaction/calls --- libs/remix-simulator/src/server.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libs/remix-simulator/src/server.ts b/libs/remix-simulator/src/server.ts index 3795541174..2984ce2fc1 100644 --- a/libs/remix-simulator/src/server.ts +++ b/libs/remix-simulator/src/server.ts @@ -37,20 +37,37 @@ export class Server { if (cliOptions.rpc) { app.use((req, res) => { + if (req && req.body && (req.body.method === 'eth_sendTransaction' || req.body.method === 'eth_call')) { + console.log('Receiving call/transaction:') + console.log(req.body.params) + } this.provider.sendAsync(req.body, (err, jsonResponse) => { if (err) { + console.error(err) return res.send(JSON.stringify({ error: err })) } + if (req && req.body && (req.body.method === 'eth_sendTransaction' || req.body.method === 'eth_call')) { + console.log(jsonResponse) + } res.send(jsonResponse) }) }) } else { wsApp.app.ws('/', (ws, req) => { ws.on('message', (msg) => { - this.provider.sendAsync(JSON.parse(msg.toString()), (err, jsonResponse) => { + const body = JSON.parse(msg.toString()) + if (body && (body.method === 'eth_sendTransaction' || body.method === 'eth_call')) { + console.log('Receiving call/transaction:') + console.log(body.params) + } + this.provider.sendAsync(body, (err, jsonResponse) => { if (err) { + console.error(err) return ws.send(JSON.stringify({ error: err })) } + if (body && (body.method === 'eth_sendTransaction' || body.method === 'eth_call')) { + console.log(jsonResponse) + } ws.send(JSON.stringify(jsonResponse)) }) })