forked from spiko-tech/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
97 lines (91 loc) · 2.83 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
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.24' },
evmVersion: { type: 'string', default: 'cancun' },
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
chainId: { type: 'number', default: 1337 },
hardfork: { type: 'string', default: 'cancun' },
slow: { type: 'boolean', default: false },
// APIs
coinmarketcap: { type: 'string' },
etherscan: { type: 'string' },
});
require("@nomicfoundation/hardhat-toolbox");
require('@nomicfoundation/hardhat-ethers');
require('@openzeppelin/hardhat-upgrades');
require('solidity-coverage');
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', '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: Object.fromEntries(networkNames.map(name => [name, argv.etherscan])),
},
gasReporter: {
enabled: argv.report,
showMethodSig: true,
currency: 'USD',
coinmarketcap: argv.coinmarketcap,
},
};
require('debug')('compilation')(JSON.stringify(module.exports.solidity.compilers, null, 2))