Skip to content

Commit

Permalink
feat: ganache v7.9.2 patch
Browse files Browse the repository at this point in the history
  • Loading branch information
infloop committed Feb 7, 2024
1 parent d3d01c4 commit 909d3bc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions patch-ganache-7.9.2.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit 909d3bc

Please sign in to comment.