-
Notifications
You must be signed in to change notification settings - Fork 3
/
hardhat.config.js
62 lines (54 loc) · 1.37 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
const {
has,
prop
} = require('ramda')
const {
ENDPOINT_ENV_VAR_KEY,
ETHERSCAN_ENV_VAR_KEY
} = require('./lib/constants')
const { assoc } = require('ramda')
require('hardhat-erc1820')
require('@nomiclabs/hardhat-waffle')
require('@nomiclabs/hardhat-etherscan')
require('@openzeppelin/hardhat-upgrades')
const SUPPORTED_NETWORKS = [
'rinkeby',
'ropsten',
'ambrosTestnet',
'ethMainnet',
'bscMainnet',
'goerli',
'prater',
'sepolia',
]
const getEnvVarOrThow = _name => {
if (has(_name, process.env))
return prop(_name, process.env)
else
throw new Error(`No '${_name}' env-var found - please provision one!`)
}
const getAllSupportedNetworks = _ =>
SUPPORTED_NETWORKS.reduce((_acc, _network) =>
assoc(_network, { url: getEnvVarOrThow(ENDPOINT_ENV_VAR_KEY) }, _acc), {}
)
const addLocalNetwork = _allSupportedNetworks =>
assoc('localhost', { url: 'http://localhost:8545' }, _allSupportedNetworks)
const addHardHatNetwork = _allSupportedNetworks =>
assoc('hardhat', { hardfork: 'istanbul' }, _allSupportedNetworks)
const getAllNetworks = _ =>
addLocalNetwork(addHardHatNetwork(getAllSupportedNetworks()))
module.exports = {
networks: getAllNetworks(),
solidity: {
version: '0.8.2',
settings: {
optimizer: {
runs: 200,
enabled: true,
}
}
},
etherscan: {
apiKey: process.env[ETHERSCAN_ENV_VAR_KEY]
},
}