Refactor getNetId function

This commit is contained in:
PoaMan 2020-11-16 16:01:16 +03:00
parent 889fa30e7c
commit 5e34b51b30
1 changed files with 2 additions and 3 deletions

View File

@ -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()
}