From 32661a1697b9378f3d6941ebc3a144943ab6a115 Mon Sep 17 00:00:00 2001 From: Kendall Date: Wed, 31 May 2023 16:49:36 +0800 Subject: [PATCH] Use network object when .env variables are complete in setupMetamask --- plugins/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/index.js b/plugins/index.js index aff771df4..11bbed1b4 100644 --- a/plugins/index.js +++ b/plugins/index.js @@ -270,6 +270,29 @@ module.exports = (on, config) => { if (process.env.NETWORK_NAME) { network = process.env.NETWORK_NAME; } + if ( + process.env.NETWORK_NAME && + process.env.RPC_URL && + process.env.CHAIN_ID && + process.env.SYMBOL + ) { + network = { + id: process.env.CHAIN_ID, + name: process.env.NETWORK_NAME, + nativeCurrency: { + symbol: process.env.SYMBOL, + }, + rpcUrls: { + public: { http: [process.env.RPC_URL] }, + default: { http: [process.env.RPC_URL] }, + }, + blockExplorers: { + etherscan: { url: process.env.BLOCK_EXPLORER }, + default: { url: process.env.BLOCK_EXPLORER }, + }, + testnet: process.env.IS_TESTNET, + }; + } if (process.env.PRIVATE_KEY) { secretWordsOrPrivateKey = process.env.PRIVATE_KEY; }