From a2badabdbb90b7f54694de5e1db57b947f9f17b7 Mon Sep 17 00:00:00 2001 From: Aleksandr Kraiz Date: Mon, 20 Feb 2023 18:28:19 +0400 Subject: [PATCH] Better provider init --- package.json | 2 +- src/OrionUnit/index.ts | 4 +++- src/constants/chains.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5da92bc..cc0f935 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.17.15", + "version": "0.17.16", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/OrionUnit/index.ts b/src/OrionUnit/index.ts index 444bd6d..dafa1c7 100644 --- a/src/OrionUnit/index.ts +++ b/src/OrionUnit/index.ts @@ -76,7 +76,9 @@ export default class OrionUnit { // this.env = config.env; this.chainId = config.chainId; this.networkCode = chainInfo.code; - this.provider = new ethers.providers.StaticJsonRpcProvider(this.config.nodeJsonRpc); + const intNetwork = parseInt(this.chainId, 10); + if (Number.isNaN(intNetwork)) throw new Error('Invalid chainId (not a number)' + this.chainId); + this.provider = new ethers.providers.StaticJsonRpcProvider(this.config.nodeJsonRpc, intNetwork); this.orionBlockchain = new OrionBlockchain(this.config.services.orionBlockchain.http); this.orionAggregator = new OrionAggregator( diff --git a/src/constants/chains.ts b/src/constants/chains.ts index de3abfa..2c20741 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -3,6 +3,7 @@ import { SupportedChainId } from '../types'; export const developmentChains = [ SupportedChainId.BSC_TESTNET, SupportedChainId.ROPSTEN, + SupportedChainId.GOERLI, SupportedChainId.FANTOM_TESTNET, SupportedChainId.POLYGON_TESTNET, SupportedChainId.OKC_TESTNET,