forked from graphprotocol/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
170 lines (151 loc) · 3.68 KB
/
hardhat.config.ts
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import path from 'path'
import fs from 'fs'
import * as dotenv from 'dotenv'
import { execSync } from 'child_process'
import 'hardhat/types/runtime'
import { HardhatUserConfig } from 'hardhat/types'
dotenv.config()
// Plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan'
import '@nomiclabs/hardhat-waffle'
import 'hardhat-abi-exporter'
import 'hardhat-gas-reporter'
import 'hardhat-contract-sizer'
import 'hardhat-tracer'
import '@tenderly/hardhat-tenderly'
import '@openzeppelin/hardhat-upgrades'
import '@typechain/hardhat'
import 'solidity-coverage'
// Tasks
const SKIP_LOAD = process.env.SKIP_LOAD === 'true'
function loadTasks() {
require('./tasks/gre.ts')
;['contracts', 'misc', 'deployment', 'actions'].forEach((folder) => {
const tasksPath = path.join(__dirname, 'tasks', folder)
fs.readdirSync(tasksPath)
.filter((pth) => pth.includes('.ts'))
.forEach((task) => {
require(`${tasksPath}/${task}`)
})
})
}
if (fs.existsSync(path.join(__dirname, 'build', 'types'))) {
loadTasks()
} else if (!SKIP_LOAD) {
execSync('yarn build', { stdio: 'inherit' })
loadTasks()
}
// Networks
interface NetworkConfig {
network: string
chainId: number
url?: string
gas?: number | 'auto'
gasPrice?: number | 'auto'
}
const networkConfigs: NetworkConfig[] = [
{ network: 'mainnet', chainId: 1 },
{ network: 'rinkeby', chainId: 4 },
{ network: 'kovan', chainId: 42 },
]
function getAccountMnemonic() {
return process.env.MNEMONIC || ''
}
function getDefaultProviderURL(network: string) {
return `https://${network}.infura.io/v3/${process.env.INFURA_KEY}`
}
function setupNetworkProviders(hardhatConfig) {
for (const netConfig of networkConfigs) {
hardhatConfig.networks[netConfig.network] = {
chainId: netConfig.chainId,
url: netConfig.url ? netConfig.url : getDefaultProviderURL(netConfig.network),
gas: netConfig.gas || 'auto',
gasPrice: netConfig.gasPrice || 'auto',
accounts: {
mnemonic: getAccountMnemonic(),
},
}
}
}
// Config
const DEFAULT_TEST_MNEMONIC =
'myth like bonus scare over problem client lizard pioneer submit female collect'
const config: HardhatUserConfig = {
paths: {
sources: './contracts',
tests: './test',
artifacts: './build/contracts',
},
solidity: {
compilers: [
{
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
'*': {
'*': ['storageLayout'],
},
},
},
},
],
},
defaultNetwork: 'hardhat',
networks: {
hardhat: {
chainId: 1337,
loggingEnabled: false,
gas: 12000000,
gasPrice: 'auto',
initialBaseFeePerGas: 0,
blockGasLimit: 12000000,
accounts: {
mnemonic: DEFAULT_TEST_MNEMONIC,
},
mining: {
auto: true,
interval: 30000,
},
hardfork: 'london',
},
ganache: {
chainId: 1337,
url: 'http://localhost:8545',
gasPrice: 300000000000, // 300 gwei
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
showTimeSpent: true,
currency: 'USD',
outputFile: 'reports/gas-report.log',
},
typechain: {
outDir: 'build/types',
target: 'ethers-v5',
},
abiExporter: {
path: './build/abis',
clear: false,
flat: true,
},
tenderly: {
project: 'graph-network',
username: 'abarmat',
},
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
}
setupNetworkProviders(config)
export default config