@@ -18,7 +18,20 @@ usePlugin('@nomiclabs/buidler-waffle')
1818usePlugin ( 'buidler-gas-reporter' )
1919usePlugin ( 'solidity-coverage' )
2020
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+ ]
2235
2336function getAccountMnemonic ( ) {
2437 return process . env . MNEMONIC || ''
@@ -28,6 +41,20 @@ function getInfuraProviderURL(network: string) {
2841 return `https://${ network } .infura.io/v3/${ process . env . INFURA_KEY } `
2942}
3043
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+
3158// Env
3259
3360extendEnvironment ( ( bre ) => {
@@ -136,43 +163,19 @@ const config = {
136163 chainId : 1337 ,
137164 url : 'http://localhost:8545' ,
138165 } ,
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- } ,
166166 } ,
167167 etherscan : {
168168 url : 'https://api-kovan.etherscan.io/api' ,
169169 apiKey : process . env . ETHERSCAN_API_KEY ,
170170 } ,
171171 gasReporter : {
172- currency : 'USD' ,
173172 enabled : process . env . REPORT_GAS ? true : false ,
174- outputFile : './gas-report.txt' ,
173+ showTimeSpent : true ,
174+ currency : 'USD' ,
175+ outputFile : 'gas-report.log' ,
175176 } ,
176177}
177178
179+ setupNetworkProviders ( config )
180+
178181export default config
0 commit comments