Added explicity pify dep, deprecating web3.eth. (#1532)
* Added explicity pify dep, deprecating web3.eth. * Dropped promisify in favor of pify.
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
const { ethGetBalance } = require('./web3');
|
||||
|
||||
async function balanceDifference (account, promiseFunc) {
|
||||
const balanceBefore = web3.eth.getBalance(account);
|
||||
const balanceBefore = await ethGetBalance(account);
|
||||
await promiseFunc();
|
||||
const balanceAfter = web3.eth.getBalance(account);
|
||||
const balanceAfter = await ethGetBalance(account);
|
||||
return balanceAfter.minus(balanceBefore);
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const SolidityEvent = require('web3/lib/web3/event.js');
|
||||
const { ethGetTransactionReceipt } = require('./web3');
|
||||
|
||||
const BigNumber = web3.BigNumber;
|
||||
const should = require('chai')
|
||||
@ -23,7 +24,7 @@ async function inConstruction (contract, eventName, eventArgs = {}) {
|
||||
}
|
||||
|
||||
async function inTransaction (txHash, emitter, eventName, eventArgs = {}) {
|
||||
const receipt = await web3.eth.getTransactionReceipt(txHash);
|
||||
const receipt = await ethGetTransactionReceipt(txHash);
|
||||
const logs = decodeLogs(receipt.logs, emitter.events);
|
||||
|
||||
return inLogs(logs, eventName, eventArgs);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const { ethGetBlock } = require('./web3');
|
||||
const { promisify } = require('util');
|
||||
const pify = require('pify');
|
||||
|
||||
function advanceBlock () {
|
||||
return promisify(web3.currentProvider.sendAsync)({
|
||||
return pify(web3.currentProvider.sendAsync)({
|
||||
jsonrpc: '2.0',
|
||||
method: 'evm_mine',
|
||||
});
|
||||
@ -18,7 +18,7 @@ async function latest () {
|
||||
async function increase (duration) {
|
||||
if (duration < 0) throw Error(`Cannot increase time by a negative amount (${duration})`);
|
||||
|
||||
await promisify(web3.currentProvider.sendAsync)({
|
||||
await pify(web3.currentProvider.sendAsync)({
|
||||
jsonrpc: '2.0',
|
||||
method: 'evm_increaseTime',
|
||||
params: [duration],
|
||||
|
||||
@ -4,6 +4,7 @@ const ethAsync = pify(web3.eth);
|
||||
|
||||
module.exports = {
|
||||
ethGetBalance: ethAsync.getBalance,
|
||||
ethSendTransaction: ethAsync.sendTransaction,
|
||||
ethGetBlock: ethAsync.getBlock,
|
||||
ethGetTransactionReceipt: ethAsync.getTransactionReceipt,
|
||||
ethSendTransaction: ethAsync.sendTransaction,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user