add ethereumnetworks type
This commit is contained in:
parent
4eb5a6b12f
commit
a6600c703d
|
@ -9,15 +9,17 @@ import { provider as Provider } from 'web3-core'
|
|||
import { ProviderProps } from './store/model/provider'
|
||||
|
||||
export const ETHEREUM_NETWORK = {
|
||||
MAINNET: 'MAINNET',
|
||||
MORDEN: 'MORDEN',
|
||||
ROPSTEN: 'ROPSTEN',
|
||||
RINKEBY: 'RINKEBY',
|
||||
GOERLI: 'GOERLI',
|
||||
KOVAN: 'KOVAN',
|
||||
UNKNOWN: 'UNKNOWN',
|
||||
MAINNET: 'MAINNET' as const,
|
||||
MORDEN: 'MORDEN' as const,
|
||||
ROPSTEN: 'ROPSTEN' as const,
|
||||
RINKEBY: 'RINKEBY' as const,
|
||||
GOERLI: 'GOERLI' as const,
|
||||
KOVAN: 'KOVAN' as const,
|
||||
UNKNOWN: 'UNKNOWN' as const,
|
||||
}
|
||||
|
||||
export type EthereumNetworks = typeof ETHEREUM_NETWORK[keyof typeof ETHEREUM_NETWORK]
|
||||
|
||||
export const WALLET_PROVIDER = {
|
||||
SAFE: 'SAFE',
|
||||
METAMASK: 'METAMASK',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createSelector } from 'reselect'
|
||||
|
||||
import { ETHEREUM_NETWORK, ETHEREUM_NETWORK_IDS } from 'src/logic/wallets/getWeb3'
|
||||
import { ETHEREUM_NETWORK, ETHEREUM_NETWORK_IDS, EthereumNetworks } from 'src/logic/wallets/getWeb3'
|
||||
import { PROVIDER_REDUCER_ID, ProviderState } from 'src/logic/wallets/store/reducer/provider'
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
|
@ -16,10 +16,13 @@ export const providerNameSelector = createSelector(providerSelector, (provider:
|
|||
return name ? name.toLowerCase() : undefined
|
||||
})
|
||||
|
||||
export const networkSelector = createSelector(providerSelector, (provider: ProviderState): string => {
|
||||
const networkId = provider.get('network')
|
||||
return ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
||||
})
|
||||
export const networkSelector = createSelector(
|
||||
providerSelector,
|
||||
(provider: ProviderState): EthereumNetworks => {
|
||||
const networkId = provider.get('network')
|
||||
return ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
||||
},
|
||||
)
|
||||
|
||||
export const loadedSelector = createSelector(providerSelector, (provider: ProviderState): boolean =>
|
||||
provider.get('loaded'),
|
||||
|
|
Loading…
Reference in New Issue