1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/app/scripts/lib/select-chain-id.js
Whymarrh Whitby 92971d3c87
Migrate codebase to use ESM (#7730)
* Update eslint-plugin-import version

* Convert JS files to use ESM

* Update ESLint rules to check imports

* Fix test:unit:global command env

* Cleanup mock-dev script
2020-01-09 00:04:58 -03:30

23 lines
491 B
JavaScript

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