From 5e34b51b30dec8f4e6575053bec4f7a195fb491e Mon Sep 17 00:00:00 2001 From: PoaMan <33550681+poaman@users.noreply.github.com> Date: Mon, 16 Nov 2020 16:01:16 +0300 Subject: [PATCH] Refactor getNetId function --- src/utils/getWeb3.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/getWeb3.js b/src/utils/getWeb3.js index 1b6407d..2425a0f 100644 --- a/src/utils/getWeb3.js +++ b/src/utils/getWeb3.js @@ -18,9 +18,8 @@ async function getAccounts(web3) { async function getNetId(web3) { let netId if (window.ethereum) { - netId = web3.utils.isHex(window.ethereum.chainId) - ? web3.utils.hexToNumber(window.ethereum.chainId) - : window.ethereum.chainId + const { chainId } = window.ethereum + netId = web3.utils.isHex(chainId) ? web3.utils.hexToNumber(chainId) : chainId } else { netId = await web3.eth.net.getId() }