Skip to content

Commit 09eb608

Browse files
authored
Merge pull request #18 from CommitPool/migration_buidler_hardhat
Migration buidler hardhat
2 parents 3be3f7e + 552441c commit 09eb608

18 files changed

+9990
-15786
lines changed

.mocharc.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"delay": true,
3-
"extension": ["ts"],
2+
"extension": ["ts"],
43
"recursive": "test",
5-
"require": ["@nomiclabs/buidler/register"],
4+
"require": ["ts-node/register/files"],
65
"timeout": 20000
76
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Currently Ganache and Node 14 are not playing well together. To get started:
1313
3. ```npm run-script build```
1414
4. ```npm test``` (to verify the build)
1515

16+
Note: [Hardhat guide](https://hardhat.org/guides/vscode-tests.html) on running test in VSCode
17+
1618
#### Deploying to local node
1719
Buidler
1820

buidler.config.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

contracts/SinglePlayerCommit.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity 0.6.10;
33
pragma experimental ABIEncoderV2;
44

5-
import { console } from "@nomiclabs/buidler/console.sol";
5+
import { console } from "hardhat/console.sol";
66
import "@openzeppelin/contracts/access/Ownable.sol";
77
// import "@openzeppelin/contracts/math/SafeMath.sol";
88
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

hardhat.config.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { config as dotenvConfig } from "dotenv";
2+
import { resolve } from "path";
3+
dotenvConfig({ path: resolve(__dirname, "./.env") });
4+
5+
import { HardhatUserConfig } from "hardhat/config";
6+
import { NetworkUserConfig } from "hardhat/types";
7+
import "./tasks/accounts";
8+
import "./tasks/clean";
9+
10+
import "@nomiclabs/hardhat-waffle";
11+
// import "@nomiclabs/hardhat-ethers";
12+
import "hardhat-typechain";
13+
import "solidity-coverage";
14+
15+
const chainIds = {
16+
ganache: 1337,
17+
goerli: 5,
18+
hardhat: 31337,
19+
kovan: 42,
20+
mainnet: 1,
21+
rinkeby: 4,
22+
ropsten: 3,
23+
};
24+
25+
// Ensure that we have all the environment variables we need.
26+
let mnemonic: string;
27+
if (!process.env.MNEMONIC) {
28+
throw new Error("Please set your MNEMONIC in a .env file");
29+
} else {
30+
mnemonic = process.env.MNEMONIC;
31+
}
32+
33+
let infuraApiKey: string;
34+
if (!process.env.INFURA_API_KEY) {
35+
throw new Error("Please set your INFURA_API_KEY in a .env file");
36+
} else {
37+
infuraApiKey = process.env.INFURA_API_KEY;
38+
}
39+
40+
function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig {
41+
const url: string = "https://" + network + ".infura.io/v3/" + infuraApiKey;
42+
return {
43+
accounts: {
44+
count: 10,
45+
initialIndex: 0,
46+
mnemonic,
47+
path: "m/44'/60'/0'/0",
48+
},
49+
chainId: chainIds[network],
50+
url,
51+
};
52+
}
53+
54+
const config: HardhatUserConfig = {
55+
defaultNetwork: "hardhat",
56+
networks: {
57+
hardhat: {
58+
chainId: chainIds.hardhat,
59+
},
60+
goerli: createTestnetConfig("goerli"),
61+
kovan: createTestnetConfig("kovan"),
62+
rinkeby: createTestnetConfig("rinkeby"),
63+
ropsten: createTestnetConfig("ropsten"),
64+
},
65+
paths: {
66+
artifacts: "./artifacts",
67+
cache: "./cache",
68+
sources: "./contracts",
69+
tests: "./test",
70+
},
71+
solidity: {
72+
version: "0.6.10",
73+
settings: {
74+
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
75+
optimizer: {
76+
enabled: true,
77+
runs: 200,
78+
},
79+
},
80+
},
81+
typechain: {
82+
outDir: "typechain",
83+
target: "ethers-v5",
84+
},
85+
};
86+
87+
export default config;

0 commit comments

Comments
 (0)