From 909d3bca58448dbabd76db663008352d56a07b76 Mon Sep 17 00:00:00 2001 From: infloop Date: Wed, 7 Feb 2024 23:38:58 +0500 Subject: [PATCH] feat: ganache v7.9.2 patch --- patch-ganache-7.9.2.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 patch-ganache-7.9.2.js diff --git a/patch-ganache-7.9.2.js b/patch-ganache-7.9.2.js new file mode 100644 index 00000000..d9dfcdeb --- /dev/null +++ b/patch-ganache-7.9.2.js @@ -0,0 +1,22 @@ +/** + * Ganache v7.9.2 patch for JSON.stringify issue + * This fixes reading a lot of events events from debug_traceTransaction + */ +const fs = require('fs'); + +const searchString = '{const s=(0,a.makeResponse)(t.id,e);return"debug_traceTransaction"===t.method&&"object"==typeof e&&Array.isArray(e.structLogs)&&e.structLogs.length>this.BUFFERIFY_THRESHOLD?(0,u.bufferify)(s,""):JSON.stringify(s)}'; + +const replacementString = '{const r=(0,a.makeResponse)(t.id,e);if("debug_traceTransaction"===t.method&&"object"==typeof e&&Array.isArray(e.structLogs)&&e.structLogs.length>this.BUFFERIFY_THRESHOLD)return(0,u.bufferify)(r,"");try{return JSON.stringify(r)}catch(e){return(0,u.bufferify)(r,"")}}'; + +const filename = './node_modules/ganache/dist/node/1.js'; +fs.readFile(filename, 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + const result = data.replace(searchString, replacementString); + + fs.writeFile(filename, result, 'utf8', function (err) { + if (err) return console.log(err); + }); +}); +