2020-01-09 04:34:58 +01:00
|
|
|
import {
|
2019-09-10 02:31:34 +02:00
|
|
|
MAINNET_CHAIN_ID,
|
|
|
|
ROPSTEN_CHAIN_ID,
|
|
|
|
RINKEBY_CHAIN_ID,
|
|
|
|
KOVAN_CHAIN_ID,
|
|
|
|
GOERLI_CHAIN_ID,
|
2020-01-09 04:34:58 +01:00
|
|
|
} from './enums'
|
2019-09-10 02:31:34 +02:00
|
|
|
|
|
|
|
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) {
|
2019-11-22 23:25:44 +01:00
|
|
|
const { network, provider: { chainId } } = metamaskState
|
|
|
|
return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}`
|
2019-09-10 02:31:34 +02:00
|
|
|
}
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export default selectChainId
|