forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mine.js
36 lines (31 loc) · 961 Bytes
/
mine.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
26
27
28
29
30
31
32
33
34
35
36
/*
This script advances Ganache network state. It runs as a sidecar pod alongside the devnet and
ensures that manual token transfers triggered through the web UI will be able to be confirmed.
*/
advanceBlock = () => {
return new Promise((resolve, reject) => {
web3.currentProvider.send({
jsonrpc: "2.0",
method: "evm_mine",
id: new Date().getTime()
}, (err, result) => {
if (err) {
return reject(err);
}
const newBlockHash = web3.eth.getBlock('latest').hash;
return resolve(newBlockHash)
});
});
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = function(callback) {
const fn = async () => {
while (true) {
console.log(await advanceBlock());
await sleep(1000);
}
}
fn().catch(reason => console.error(reason))
}