From 3712752102df87b0492d5173bd1757a8be06e2cc Mon Sep 17 00:00:00 2001 From: zemse Date: Wed, 27 May 2020 23:37:02 +0530 Subject: [PATCH] add providerETH and source url from config #21 --- src/global.ts | 15 +++++++++------ src/types/global.d.ts | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/global.ts b/src/global.ts index 37749f0..458664a 100644 --- a/src/global.ts +++ b/src/global.ts @@ -17,12 +17,6 @@ global.consoleLog = (...input) => { } }; -const providerEsn: ethers.providers.JsonRpcProvider = new ethers.providers.JsonRpcProvider( - process.env.ESN_URL -); - -global.providerEsn = providerEsn; - global.peerList = new PeerList(); // TODO use minimist package in this case @@ -50,6 +44,15 @@ global.config = { : null, }; +// loading providers +global.providerEsn = new ethers.providers.JsonRpcProvider( + global.config.ESN_URL.toString() +); +global.providerETH = new ethers.providers.JsonRpcProvider( + global.config.ETH_URL.toString() +); + +// loading wallet if ( typeof global.config.KEYSTORE_PATH === 'string' && typeof global.config.KEYSTORE_PASSWORD_PATH === 'string' diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 91df02d..2f7b370 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -13,6 +13,7 @@ declare global { interface Global { consoleLog: (...input: any) => void; providerEsn: ethers.providers.JsonRpcProvider; + providerETH: ethers.providers.JsonRpcProvider; config: { ETH_URL: URLMask; ESN_URL: URLMask;