Browse Source

Transition from buidler to hardhat

Hadrien Croubois 4 năm trước cách đây
mục cha
commit
a0323d446c

+ 0 - 20
buidler.config.js

@@ -1,20 +0,0 @@
-const fs = require('fs');
-const path = require('path');
-
-usePlugin('solidity-coverage');
-usePlugin('@nomiclabs/buidler-truffle5');
-
-for (const f of fs.readdirSync(path.join(__dirname, 'buidler'))) {
-  require(path.join(__dirname, 'buidler', f));
-}
-
-module.exports = {
-  networks: {
-    buidlerevm: {
-      blockGasLimit: 10000000,
-    },
-  },
-  solc: {
-    version: '0.8.0',
-  },
-};

+ 28 - 0
hardhat.config.js

@@ -0,0 +1,28 @@
+const fs = require('fs');
+const path = require('path');
+
+require("@nomiclabs/hardhat-truffle5");
+require("@nomiclabs/hardhat-solhint");
+require("solidity-coverage");
+
+for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
+  require(path.join(__dirname, 'hardhat', f));
+}
+
+/**
+ * @type import('hardhat/config').HardhatUserConfig
+ */
+module.exports = {
+  solidity: "0.8.0",
+  settings: {
+    optimizer: {
+      enabled: false,
+      runs: 200,
+    },
+  },
+	networks: {
+    hardhat: {
+      blockGasLimit: 10000000,
+    },
+  },
+};

+ 0 - 0
buidler/env-contract.js → hardhat/env-contract.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 265 - 575
package-lock.json


+ 7 - 6
package.json

@@ -9,8 +9,8 @@
     "/test/behaviors"
   ],
   "scripts": {
-    "compile": "buidler compile",
-    "coverage": "buidler coverage",
+    "compile": "hardhat compile",
+    "coverage": "hardhat coverage",
     "docs": "oz-docs",
     "docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
     "prepare-docs": "scripts/prepare-docs.sh",
@@ -24,7 +24,7 @@
     "prepack": "scripts/prepack.sh",
     "release": "scripts/release/release.sh",
     "version": "scripts/release/version.sh",
-    "test": "buidler test"
+    "test": "hardhat test"
   },
   "repository": {
     "type": "git",
@@ -45,9 +45,9 @@
   },
   "homepage": "https://openzeppelin.com/contracts/",
   "devDependencies": {
-    "@nomiclabs/buidler": "^1.4.8",
-    "@nomiclabs/buidler-truffle5": "^1.3.4",
-    "@nomiclabs/buidler-web3": "^1.3.4",
+    "@nomiclabs/hardhat-solhint": "^2.0.0",
+    "@nomiclabs/hardhat-truffle5": "^2.0.0",
+    "@nomiclabs/hardhat-web3": "^2.0.0",
     "@openzeppelin/docs-utils": "^0.1.0",
     "@openzeppelin/gsn-helpers": "^0.2.3",
     "@openzeppelin/gsn-provider": "^0.1.10",
@@ -63,6 +63,7 @@
     "eth-sig-util": "^3.0.0",
     "ethereumjs-util": "^7.0.7",
     "ethereumjs-wallet": "^1.0.1",
+    "hardhat": "^2.0.6",
     "lodash.startcase": "^4.4.0",
     "lodash.zip": "^4.2.0",
     "micromatch": "^4.0.2",

+ 1 - 1
test/proxy/BeaconProxy.test.js

@@ -12,7 +12,7 @@ const BadBeaconNoImpl = artifacts.require('BadBeaconNoImpl');
 const BadBeaconNotContract = artifacts.require('BadBeaconNotContract');
 
 function toChecksumAddress (address) {
-  return ethereumjsUtil.toChecksumAddress('0x' + address.replace(/^0x/, '').padStart(40, '0'));
+  return ethereumjsUtil.toChecksumAddress('0x' + address.replace(/^0x/, '').padStart(40, '0').substr(-40));
 }
 
 const BEACON_LABEL = 'eip1967.proxy.beacon';

+ 1 - 1
test/proxy/TransparentUpgradeableProxy.behaviour.js

@@ -20,7 +20,7 @@ const IMPLEMENTATION_LABEL = 'eip1967.proxy.implementation';
 const ADMIN_LABEL = 'eip1967.proxy.admin';
 
 function toChecksumAddress (address) {
-  return ethereumjsUtil.toChecksumAddress('0x' + address.replace(/^0x/, '').padStart(40, '0'));
+  return ethereumjsUtil.toChecksumAddress('0x' + address.replace(/^0x/, '').padStart(40, '0').substr(-40));
 }
 
 module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createProxy, accounts) {

+ 5 - 1
test/proxy/UpgradeableProxy.behaviour.js

@@ -5,6 +5,10 @@ const { expect } = require('chai');
 
 const DummyImplementation = artifacts.require('DummyImplementation');
 
+function toChecksumAddress (address) {
+  return ethereumjsUtil.toChecksumAddress('0x' + address.replace(/^0x/, '').padStart(40, '0').substr(-40));
+}
+
 const IMPLEMENTATION_LABEL = 'eip1967.proxy.implementation';
 
 function toChecksumAddress (address) {
@@ -29,7 +33,7 @@ module.exports = function shouldBehaveLikeUpgradeableProxy (createProxy, proxyAd
   const assertProxyInitialization = function ({ value, balance }) {
     it('sets the implementation address', async function () {
       const slot = '0x' + new BN(ethereumjsUtil.keccak256(Buffer.from(IMPLEMENTATION_LABEL))).subn(1).toString(16);
-      const implementation = toChecksumAddress(await web3.eth.getStorageAt(this.proxy, slot));
+      const implementation = toChecksumAddress((await web3.eth.getStorageAt(this.proxy, slot)).substr(-40));
       expect(implementation).to.be.equal(this.implementation);
     });
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác