Unverified Commit b7d56d54 by Nicolás Venturo Committed by GitHub

Added explicity pify dep, deprecating web3.eth. (#1532)

* Added explicity pify dep, deprecating web3.eth.

* Dropped promisify in favor of pify.
parent 41c540fb
...@@ -2403,6 +2403,14 @@ ...@@ -2403,6 +2403,14 @@
"pify": "^2.0.0", "pify": "^2.0.0",
"pinkie-promise": "^2.0.0", "pinkie-promise": "^2.0.0",
"rimraf": "^2.2.8" "rimraf": "^2.2.8"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"delayed-stream": { "delayed-stream": {
...@@ -2870,6 +2878,14 @@ ...@@ -2870,6 +2878,14 @@
"parse-json": "^2.2.0", "parse-json": "^2.2.0",
"pify": "^2.0.0", "pify": "^2.0.0",
"strip-bom": "^3.0.0" "strip-bom": "^3.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"path-type": { "path-type": {
...@@ -2879,6 +2895,14 @@ ...@@ -2879,6 +2895,14 @@
"dev": true, "dev": true,
"requires": { "requires": {
"pify": "^2.0.0" "pify": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"read-pkg": { "read-pkg": {
...@@ -4748,6 +4772,14 @@ ...@@ -4748,6 +4772,14 @@
"object-assign": "^4.0.1", "object-assign": "^4.0.1",
"pify": "^2.0.0", "pify": "^2.0.0",
"pinkie-promise": "^2.0.0" "pinkie-promise": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"graceful-fs": { "graceful-fs": {
...@@ -5937,6 +5969,14 @@ ...@@ -5937,6 +5969,14 @@
"pify": "^2.0.0", "pify": "^2.0.0",
"pinkie-promise": "^2.0.0", "pinkie-promise": "^2.0.0",
"strip-bom": "^2.0.0" "strip-bom": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"loader-utils": { "loader-utils": {
...@@ -6966,6 +7006,14 @@ ...@@ -6966,6 +7006,14 @@
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"pify": "^2.0.0", "pify": "^2.0.0",
"pinkie-promise": "^2.0.0" "pinkie-promise": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"pathval": { "pathval": {
...@@ -6987,9 +7035,9 @@ ...@@ -6987,9 +7035,9 @@
"dev": true "dev": true
}, },
"pify": { "pify": {
"version": "2.3.0", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true "dev": true
}, },
"pinkie": { "pinkie": {
...@@ -8927,6 +8975,14 @@ ...@@ -8927,6 +8975,14 @@
"strip-bom": "^2.0.0", "strip-bom": "^2.0.0",
"strip-bom-stream": "^2.0.0", "strip-bom-stream": "^2.0.0",
"vinyl": "^1.1.0" "vinyl": "^1.1.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
} }
}, },
"web3": { "web3": {
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
"ethereumjs-util": "^6.0.0", "ethereumjs-util": "^6.0.0",
"ethjs-abi": "^0.2.1", "ethjs-abi": "^0.2.1",
"ganache-cli": "6.1.8", "ganache-cli": "6.1.8",
"pify": "^4.0.1",
"solidity-coverage": "^0.5.4", "solidity-coverage": "^0.5.4",
"solium": "^1.1.8", "solium": "^1.1.8",
"truffle": "^4.1.13", "truffle": "^4.1.13",
......
const { ethGetBalance } = require('./web3');
async function balanceDifference (account, promiseFunc) { async function balanceDifference (account, promiseFunc) {
const balanceBefore = web3.eth.getBalance(account); const balanceBefore = await ethGetBalance(account);
await promiseFunc(); await promiseFunc();
const balanceAfter = web3.eth.getBalance(account); const balanceAfter = await ethGetBalance(account);
return balanceAfter.minus(balanceBefore); return balanceAfter.minus(balanceBefore);
} }
......
const SolidityEvent = require('web3/lib/web3/event.js'); const SolidityEvent = require('web3/lib/web3/event.js');
const { ethGetTransactionReceipt } = require('./web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
const should = require('chai') const should = require('chai')
...@@ -23,7 +24,7 @@ async function inConstruction (contract, eventName, eventArgs = {}) { ...@@ -23,7 +24,7 @@ async function inConstruction (contract, eventName, eventArgs = {}) {
} }
async function inTransaction (txHash, emitter, 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); const logs = decodeLogs(receipt.logs, emitter.events);
return inLogs(logs, eventName, eventArgs); return inLogs(logs, eventName, eventArgs);
......
const { ethGetBlock } = require('./web3'); const { ethGetBlock } = require('./web3');
const { promisify } = require('util'); const pify = require('pify');
function advanceBlock () { function advanceBlock () {
return promisify(web3.currentProvider.sendAsync)({ return pify(web3.currentProvider.sendAsync)({
jsonrpc: '2.0', jsonrpc: '2.0',
method: 'evm_mine', method: 'evm_mine',
}); });
...@@ -18,7 +18,7 @@ async function latest () { ...@@ -18,7 +18,7 @@ async function latest () {
async function increase (duration) { async function increase (duration) {
if (duration < 0) throw Error(`Cannot increase time by a negative amount (${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', jsonrpc: '2.0',
method: 'evm_increaseTime', method: 'evm_increaseTime',
params: [duration], params: [duration],
......
...@@ -4,6 +4,7 @@ const ethAsync = pify(web3.eth); ...@@ -4,6 +4,7 @@ const ethAsync = pify(web3.eth);
module.exports = { module.exports = {
ethGetBalance: ethAsync.getBalance, ethGetBalance: ethAsync.getBalance,
ethSendTransaction: ethAsync.sendTransaction,
ethGetBlock: ethAsync.getBlock, ethGetBlock: ethAsync.getBlock,
ethGetTransactionReceipt: ethAsync.getTransactionReceipt,
ethSendTransaction: ethAsync.sendTransaction,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment