UNPKG

solidity-cron

Version:

[![Build Status](https://travis-ci.com/Frontier-project/cron.svg?token=DJeMzxJJncp3nRaEUuxH&branch=master)](https://travis-ci.com/Frontier-project/cron) [![codecov](https://codecov.io/gh/Frontier-project/cron/branch/master/graph/badge.svg?token=BGbU5Q6IRV

27 lines (23 loc) 704 B
module.exports = { advanceBlock: function (web3) { return new Promise((resolve, reject) => { web3.currentProvider.sendAsync({ jsonrpc: '2.0', method: 'evm_mine', id: Date.now() }, (err, res) => { return err ? reject(err) : resolve(res) }) }) }, // Advances the block number so that the last mined block is `number`. advanceToBlock: async function (number, web3) { let advanceBlock = this.advanceBlock if (web3.eth.blockNumber > number) { throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`) } while (web3.eth.blockNumber < number) { await advanceBlock(web3) } } }