Эх сурвалжийг харах

fix: json rpc url for avalanche and bsc

Paul Razvan Berg 3 жил өмнө
parent
commit
753ebcc6dd
1 өөрчлөгдсөн 14 нэмэгдсэн , 4 устгасан
  1. 14 4
      hardhat.config.ts

+ 14 - 4
hardhat.config.ts

@@ -37,16 +37,26 @@ const chainIds = {
   rinkeby: 4,
   rinkeby: 4,
 };
 };
 
 
-function getChainConfig(network: keyof typeof chainIds): NetworkUserConfig {
-  const url: string = "https://" + network + ".infura.io/v3/" + infuraApiKey;
+function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
+  let jsonRpcUrl: string;
+  switch (chain) {
+    case "avalanche":
+      jsonRpcUrl = "https://api.avax.network/ext/bc/C/rpc";
+      break;
+    case "bsc":
+      jsonRpcUrl = "https://bsc-dataseed1.binance.org";
+      break;
+    default:
+      jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
+  }
   return {
   return {
     accounts: {
     accounts: {
       count: 10,
       count: 10,
       mnemonic,
       mnemonic,
       path: "m/44'/60'/0'/0",
       path: "m/44'/60'/0'/0",
     },
     },
-    chainId: chainIds[network],
-    url,
+    chainId: chainIds[chain],
+    url: jsonRpcUrl,
   };
   };
 }
 }