@@ -18,7 +18,20 @@ usePlugin('@nomiclabs/buidler-waffle')
18
18
usePlugin ( 'buidler-gas-reporter' )
19
19
usePlugin ( 'solidity-coverage' )
20
20
21
- // Helpers
21
+ // Networks
22
+
23
+ interface NetworkConfig {
24
+ network : string
25
+ chainId : number
26
+ gas ?: number | 'auto'
27
+ gasPrice ?: number | 'auto'
28
+ }
29
+
30
+ const networkConfigs : NetworkConfig [ ] = [
31
+ { network : 'mainnet' , chainId : 1 } ,
32
+ { network : 'rinkeby' , chainId : 4 } ,
33
+ { network : 'kovan' , chainId : 42 } ,
34
+ ]
22
35
23
36
function getAccountMnemonic ( ) {
24
37
return process . env . MNEMONIC || ''
@@ -28,6 +41,20 @@ function getInfuraProviderURL(network: string) {
28
41
return `https://${ network } .infura.io/v3/${ process . env . INFURA_KEY } `
29
42
}
30
43
44
+ function setupNetworkProviders ( buidlerConfig ) {
45
+ for ( const netConfig of networkConfigs ) {
46
+ buidlerConfig . networks [ netConfig . network ] = {
47
+ chainId : netConfig . chainId ,
48
+ url : getInfuraProviderURL ( netConfig . network ) ,
49
+ gas : netConfig . gasPrice || 'auto' ,
50
+ gasPrice : netConfig . gasPrice || 'auto' ,
51
+ accounts : {
52
+ mnemonic : getAccountMnemonic ( ) ,
53
+ } ,
54
+ }
55
+ }
56
+ }
57
+
31
58
// Env
32
59
33
60
extendEnvironment ( ( bre ) => {
@@ -136,43 +163,19 @@ const config = {
136
163
chainId : 1337 ,
137
164
url : 'http://localhost:8545' ,
138
165
} ,
139
- kovan : {
140
- chainId : 42 ,
141
- url : getInfuraProviderURL ( 'kovan' ) ,
142
- gas : 'auto' ,
143
- gasPrice : 'auto' ,
144
- accounts : {
145
- mnemonic : getAccountMnemonic ( ) ,
146
- } ,
147
- } ,
148
- rinkeby : {
149
- chainId : 4 ,
150
- url : getInfuraProviderURL ( 'rinkeby' ) ,
151
- gas : 'auto' ,
152
- gasPrice : 'auto' ,
153
- accounts : {
154
- mnemonic : getAccountMnemonic ( ) ,
155
- } ,
156
- } ,
157
- mainnet : {
158
- chainId : 1 ,
159
- url : getInfuraProviderURL ( 'mainnet' ) ,
160
- gas : 'auto' ,
161
- gasPrice : 'auto' ,
162
- accounts : {
163
- mnemonic : getAccountMnemonic ( ) ,
164
- } ,
165
- } ,
166
166
} ,
167
167
etherscan : {
168
168
url : 'https://api-kovan.etherscan.io/api' ,
169
169
apiKey : process . env . ETHERSCAN_API_KEY ,
170
170
} ,
171
171
gasReporter : {
172
- currency : 'USD' ,
173
172
enabled : process . env . REPORT_GAS ? true : false ,
174
- outputFile : './gas-report.txt' ,
173
+ showTimeSpent : true ,
174
+ currency : 'USD' ,
175
+ outputFile : 'gas-report.log' ,
175
176
} ,
176
177
}
177
178
179
+ setupNetworkProviders ( config )
180
+
178
181
export default config
0 commit comments