-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
59 lines (51 loc) · 1.32 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
const {
has,
assoc,
} = require('ramda')
const {
ENDPOINT_ENV_VAR_KEY,
ETHERSCAN_ENV_VAR_KEY
} = require('./lib/constants')
require('hardhat-erc1820')
require('hardhat-storage-layout')
require('@nomiclabs/hardhat-waffle')
require('@nomiclabs/hardhat-etherscan')
require('@openzeppelin/hardhat-upgrades')
require('dotenv').config()
const SUPPORTED_NETWORKS = [
'rinkeby',
'ropsten',
'ambrosTestnet',
'sepolia',
]
const checkEnvironmentVariableExists = _name => {
if (!has(_name, process.env))
throw new Error(`✘ Environment variable '${_name}' does not exist! Please provide it!`)
else
return _name
}
const getEnvironmentVariable = _name =>
process.env[checkEnvironmentVariableExists(_name)]
const getAllSupportedNetworks = _ =>
SUPPORTED_NETWORKS.reduce((_acc, _network) =>
assoc(_network, { url: getEnvironmentVariable(ENDPOINT_ENV_VAR_KEY) }, _acc), {}
)
const addLocalNetwork = _allSupportedNetworks =>
assoc('localhost', { url: 'http://localhost:8545' }, _allSupportedNetworks)
const getAllNetworks = _ =>
addLocalNetwork(getAllSupportedNetworks())
module.exports = {
networks: getAllNetworks(),
solidity: {
version: '0.8.2',
settings: {
optimizer: {
runs: 200,
enabled: true,
}
}
},
etherscan: {
apiKey: process.env[ETHERSCAN_ENV_VAR_KEY]
},
}