Browse Source

refactor: 💡 simplify hardhat config infuraApiKey & mnemonic

Daksh Miglani 4 years ago
parent
commit
9472e65626
1 changed files with 4 additions and 8 deletions
  1. 4 8
      hardhat.config.ts

+ 4 - 8
hardhat.config.ts

@@ -25,18 +25,14 @@ const chainIds = {
 };
 
 // Ensure that we have all the environment variables we need.
-let mnemonic: string;
-if (!process.env.MNEMONIC) {
+const mnemonic = process.env.MNEMONIC;
+if (!mnemonic) {
   throw new Error("Please set your MNEMONIC in a .env file");
-} else {
-  mnemonic = process.env.MNEMONIC;
 }
 
-let infuraApiKey: string;
-if (!process.env.INFURA_API_KEY) {
+const infuraApiKey = process.env.INFURA_API_KEY;
+if (!infuraApiKey) {
   throw new Error("Please set your INFURA_API_KEY in a .env file");
-} else {
-  infuraApiKey = process.env.INFURA_API_KEY;
 }
 
 function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig {