1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 20:39:08 +01:00
metamask-extension/app/scripts/lib/select-chain-id.js
Erik Marks f748664638
Cleanup network enums (#8627)
* cleanup & consolidate network enums
2020-05-20 08:57:45 -07:00

21 lines
497 B
JavaScript

import {
MAINNET_CHAIN_ID,
ROPSTEN_CHAIN_ID,
RINKEBY_CHAIN_ID,
KOVAN_CHAIN_ID,
GOERLI_CHAIN_ID,
} from '../controllers/network/enums'
const standardNetworkId = {
'1': MAINNET_CHAIN_ID,
'3': ROPSTEN_CHAIN_ID,
'4': RINKEBY_CHAIN_ID,
'42': KOVAN_CHAIN_ID,
'5': GOERLI_CHAIN_ID,
}
export default function selectChainId (metamaskState) {
const { network, provider: { chainId } } = metamaskState
return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}`
}