-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhardhat.config.js
112 lines (106 loc) · 4.11 KB
/
hardhat.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
require('dotenv').config();
const argv = require('yargs/yargs')(process.argv.slice(2))
.env('')
.options({
// modules
coverage: { type: 'boolean', default: false },
report: { type: 'boolean', default: false },
// compilations
compiler: { type: 'string', default: '0.8.23' },
evmVersion: { type: 'string', default: 'paris' },
mode: { type: 'string', choices: [ 'production', 'development' ], default: 'production' },
runs: { type: 'number', default: 200 },
viaIr: { type: 'boolean', default: false },
revertStrings: { type: 'string', choices: [ 'default', 'strip' ], default: 'default' },
// chain
fork: { type: 'string', },
chainId: { type: 'number', default: 1337 },
hardfork: { type: 'string', default: 'merge' },
slow: { type: 'boolean', default: false },
// APIs
coinmarketcap: { type: 'string' },
etherscan: { type: 'string' },
// extra
verbose: { type: 'boolean', default: false },
})
.argv;
require('@nomiclabs/hardhat-waffle');
require('@nomiclabs/hardhat-ethers');
require('@openzeppelin/hardhat-upgrades');
require('solidity-coverage');
argv.etherscan && require('@nomiclabs/hardhat-etherscan');
argv.report && require('hardhat-gas-reporter');
argv.verbose && console.table([ 'coverage', 'report', 'compiler', 'evmVersion', 'mode', 'runs', 'viaIr', 'revertStrings', 'fork', 'chainId', 'hardfork', 'slow', 'coinmarketcap', 'etherscan' ].map(key => ({ key, value: argv[key] })));
const accounts = [
argv.mnemonic && { mnemonic: argv.mnemonic },
argv.privateKey && [argv.privateKey],
].find(Boolean);
const networkNames = [
// main
'mainnet', 'ropsten', 'rinkeby', 'goerli', 'kovan', 'sepolia',
// binance smart chain
'bsc', 'bscTestnet',
// huobi eco chain
'heco', 'hecoTestnet',
// fantom mainnet
'opera', 'ftmTestnet',
// optimism
'optimisticEthereum', 'optimisticKovan',
// polygon
'polygon', 'polygonMumbai', 'polygonAmoy',
// arbitrum
'arbitrumOne', 'arbitrumTestnet',
// avalanche
'avalanche', 'avalancheFujiTestnet',
// moonbeam
'moonbeam', 'moonriver', 'moonbaseAlpha',
// xdai
'xdai', 'sokol',
];
module.exports = {
solidity: {
compilers: [
{
version: argv.compiler,
settings: {
evmVersion: argv.evmVersion,
optimizer: {
enabled: argv.mode === 'production' || argv.report,
runs: argv.runs,
},
viaIR: argv.viaIr,
debug: {
revertStrings: argv.revertStrings,
},
},
},
],
},
networks: {
hardhat: {
chainId: argv.chainId,
// hardfork: argv.hardfork,
mining: argv.slow ? { auto: false, interval: [3000, 6000] } : undefined,
forking: argv.fork ? { url: argv.fork } : undefined,
},
...Object.fromEntries(networkNames.map(name => [name, { url: argv[`${name}Node`], accounts }]).filter(([, { url }]) => url)),
},
etherscan: {
apiKey: argv.etherscan,
customChains: [
{
network: "polygonAmoy",
chainId: 80002,
urls: {
apiURL: "https://api-amoy.polygonscan.com/api",
browserURL: "https://amoy.polygonscan.com/"
}
}
]
},
gasReporter: {
currency: 'USD',
coinmarketcap: argv.coinmarketcap,
},
};
require('debug')('compilation')(JSON.stringify(module.exports.solidity.compilers, null, 2))