-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathstart-ganache.js
25 lines (21 loc) · 996 Bytes
/
start-ganache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const {spawn} = require('child_process');
const config = require('./environments');
const environment = config.ENV.DEV.NAME;
const mnemonic = config[environment].mnemonic;
const ganache = spawn('npx', ['ganache-cli', '-p 7545', '-d', `-m ${mnemonic}`, '-l 9900000', '-e 1000', '-g 10000000']);
ganache.stdout.on('data', (data) => {
let trimmed = String(data).trim();
let regex = /eth_getFilterChanges|eth_getBlockByNumber|eth_blockNumber|net_version|eth_accounts|eth_getCode|eth_getTransactionReceipt|eth_estimateGas/gi;
let filtered = trimmed.replace(regex, '').trim();
regex = /eth_sendTransaction/gi;
filtered = filtered.replace(regex, '\neth_sendTransaction');
regex = /eth_call/gi;
filtered = filtered.replace(regex, '\neth_call');
if (filtered.length > 0) console.log(filtered);
});
ganache.stderr.on('data', (data) => {
console.log(`ERROR: ${data}`);
});
ganache.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});