فهرست منبع

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

* Added explicity pify dep, deprecating web3.eth.

* Dropped promisify in favor of pify.
Nicolás Venturo 6 سال پیش
والد
کامیت
b7d56d5471
6فایلهای تغییر یافته به همراه71 افزوده شده و 10 حذف شده
  1. 59 3
      package-lock.json
  2. 1 0
      package.json
  3. 4 2
      test/helpers/balanceDifference.js
  4. 2 1
      test/helpers/expectEvent.js
  5. 3 3
      test/helpers/time.js
  6. 2 1
      test/helpers/web3.js

+ 59 - 3
package-lock.json

@@ -2403,6 +2403,14 @@
         "pify": "^2.0.0",
         "pinkie-promise": "^2.0.0",
         "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": {
@@ -2870,6 +2878,14 @@
             "parse-json": "^2.2.0",
             "pify": "^2.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": {
@@ -2879,6 +2895,14 @@
           "dev": true,
           "requires": {
             "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": {
@@ -4748,6 +4772,14 @@
         "object-assign": "^4.0.1",
         "pify": "^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": {
@@ -5937,6 +5969,14 @@
         "pify": "^2.0.0",
         "pinkie-promise": "^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": {
@@ -6966,6 +7006,14 @@
         "graceful-fs": "^4.1.2",
         "pify": "^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": {
@@ -6987,9 +7035,9 @@
       "dev": true
     },
     "pify": {
-      "version": "2.3.0",
-      "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
-      "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
+      "version": "4.0.1",
+      "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
+      "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
       "dev": true
     },
     "pinkie": {
@@ -8927,6 +8975,14 @@
         "strip-bom": "^2.0.0",
         "strip-bom-stream": "^2.0.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": {

+ 1 - 0
package.json

@@ -51,6 +51,7 @@
     "ethereumjs-util": "^6.0.0",
     "ethjs-abi": "^0.2.1",
     "ganache-cli": "6.1.8",
+    "pify": "^4.0.1",
     "solidity-coverage": "^0.5.4",
     "solium": "^1.1.8",
     "truffle": "^4.1.13",

+ 4 - 2
test/helpers/balanceDifference.js

@@ -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);
 }
 

+ 2 - 1
test/helpers/expectEvent.js

@@ -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);

+ 3 - 3
test/helpers/time.js

@@ -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],

+ 2 - 1
test/helpers/web3.js

@@ -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,
 };