@@ -16,7 +16,7 @@ const { createProvider } = require("@nomiclabs/buidler/internal/core/providers/c
1616 * @param {BuidlerConfig } config
1717 * @return {BuidlerConfig } updated config
1818 */
19- function normalizeConfig ( config , args ) {
19+ function normalizeConfig ( config , args = { } ) {
2020 config . workingDir = config . paths . root ;
2121 config . contractsDir = config . paths . sources ;
2222 config . testDir = config . paths . tests ;
@@ -27,11 +27,15 @@ function normalizeConfig(config, args){
2727 return config ;
2828}
2929
30- function setupNetwork ( env , api , taskArgs , ui ) {
30+ function setupNetwork ( env , api , ui ) {
3131 let networkConfig = { } ;
3232
33- if ( taskArgs . network ) {
34- networkConfig = env . config . networks [ taskArgs . network ] ;
33+ let networkName = ( env . buidlerArguments . network !== 'buidlerevm' )
34+ ? env . buidlerArguments . network
35+ : api . defaultNetworkName ;
36+
37+ if ( networkName !== api . defaultNetworkName ) {
38+ networkConfig = env . config . networks [ networkName ] ;
3539
3640 const configPort = networkConfig . url . split ( ':' ) [ 2 ] ;
3741
@@ -48,13 +52,13 @@ function setupNetwork(env, api, taskArgs, ui){
4852 networkConfig . gas = api . gasLimit ;
4953 networkConfig . gasPrice = api . gasPrice ;
5054
51- const provider = createProvider ( api . defaultNetworkName , networkConfig ) ;
55+ const provider = createProvider ( networkName , networkConfig ) ;
5256
53- env . config . networks [ api . defaultNetworkName ] = networkConfig ;
54- env . config . defaultNetwork = api . defaultNetworkName ;
57+ env . config . networks [ networkName ] = networkConfig ;
58+ env . config . defaultNetwork = networkName ;
5559
5660 env . network = {
57- name : api . defaultNetworkName ,
61+ name : networkName ,
5862 config : networkConfig ,
5963 provider : provider ,
6064 }
0 commit comments