Browse Source

fix: 'url' bug in buidler.config.ts

Paul Razvan Berg 4 years ago
parent
commit
c7b53e2808
1 changed files with 14 additions and 13 deletions
  1. 14 13
      buidler.config.ts

+ 14 - 13
buidler.config.ts

@@ -11,15 +11,11 @@ import "./tasks/typechain";
 usePlugin("@nomiclabs/buidler-waffle");
 usePlugin("solidity-coverage");
 
-interface HDAccountsConfigExtended extends HDAccountsConfig {
-  url: string;
-}
-
 /**
  * @dev You must have a `.env` file. Follow the example in `.env.example`.
  * @param {string} network The name of the testnet
  */
-function createHDAccountConfig(network: string): HDAccountsConfigExtended {
+function createBuidlerConfig(network?: string): { accounts: HDAccountsConfig; url: string | undefined } {
   if (!process.env.MNEMONIC) {
     console.log("Please set your MNEMONIC in a .env file");
     process.exit(1);
@@ -31,16 +27,20 @@ function createHDAccountConfig(network: string): HDAccountsConfigExtended {
   }
 
   return {
-    initialIndex: 0,
-    mnemonic: process.env.MNEMONIC,
-    path: "m/44'/60'/0'/0",
-    url: `https://${network}.infura.io/v3/${process.env.INFURA_API_KEY}`,
+    accounts: {
+      count: 10,
+      initialIndex: 0,
+      mnemonic: process.env.MNEMONIC,
+      path: "m/44'/60'/0'/0",
+    },
+    url: network ? `https://${network}.infura.io/v3/${process.env.INFURA_API_KEY}` : undefined,
   };
 }
 
 const config: BuidlerConfig = {
   defaultNetwork: "buidlerevm",
   mocha: {
+    /* Without this property set, the "setTimeout" from the Greeter.js file wouldn't work. */
     delay: true,
   },
   networks: {
@@ -48,22 +48,23 @@ const config: BuidlerConfig = {
       chainId: 31337,
     },
     coverage: {
+      ...createBuidlerConfig(),
       url: "http://127.0.0.1:8555",
     },
     goerli: {
-      ...createHDAccountConfig("goerli"),
+      ...createBuidlerConfig("goerli"),
       chainId: 5,
     },
     kovan: {
-      ...createHDAccountConfig("kovan"),
+      ...createBuidlerConfig("kovan"),
       chainId: 42,
     },
     rinkeby: {
-      ...createHDAccountConfig("rinkeby"),
+      ...createBuidlerConfig("rinkeby"),
       chainId: 4,
     },
     ropsten: {
-      ...createHDAccountConfig("ropsten"),
+      ...createBuidlerConfig("ropsten"),
       chainId: 3,
     },
   },