Handle Mainnet network notifications

This commit is contained in:
Germán Martínez 2019-09-30 08:39:05 +02:00
parent 32e8e201cf
commit b0f08bc7e8
4 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ const configuration = () => {
return process.env.REACT_APP_NETWORK === 'mainnet' ? mainnetDevConfig : devConfig
}
export const getNetwork = () => (process.env.REACT_APP_NETWORK === 'mainnet' ? ETHEREUM_NETWORK.MAIN : ETHEREUM_NETWORK.RINKEBY)
export const getNetwork = () => (process.env.REACT_APP_NETWORK === 'mainnet' ? ETHEREUM_NETWORK.MAINNET : ETHEREUM_NETWORK.RINKEBY)
const getConfig = ensureOnce(configuration)

View File

@ -1,4 +1,7 @@
// @flow
import { getNetwork } from '~/config'
import { capitalize } from '~/utils/css'
export const SUCCESS = 'success'
export const ERROR = 'error'
export const WARNING = 'warning'
@ -65,8 +68,7 @@ export type Notifications = {
// Rinkeby version
RINKEBY_VERSION_MSG: Notification,
WRONG_NETWORK_RINKEBY_MSG: Notification,
WRONG_NETWOEK_MAINNET_MSG: Notification,
WRONG_NETWORK_MSG: Notification,
}
export const NOTIFICATIONS: Notifications = {
@ -210,15 +212,11 @@ export const NOTIFICATIONS: Notifications = {
// Network
RINKEBY_VERSION_MSG: {
message: "Rinkeby Version: Don't send mainnet assets to this Safe",
message: "Rinkeby Version: Don't send Mainnet assets to this Safe",
options: { variant: INFO, persist: true, preventDuplicate: true },
},
WRONG_NETWORK_RINKEBY_MSG: {
message: 'Wrong network: Please use Rinkeby',
options: { variant: WARNING, persist: true, preventDuplicate: true },
},
WRONG_NETWOEK_MAINNET_MSG: {
message: 'Wrong network: Please use Mainnet',
WRONG_NETWORK_MSG: {
message: `Wrong network: Please use ${capitalize(getNetwork())}`,
options: { variant: WARNING, persist: true, preventDuplicate: true },
},
}

View File

@ -5,7 +5,7 @@ import type { ProviderProps } from '~/logic/wallets/store/model/provider'
import { getNetwork } from '~/config/index'
export const ETHEREUM_NETWORK = {
MAIN: 'MAIN',
MAINNET: 'MAINNET',
MORDEN: 'MORDEN',
ROPSTEN: 'ROPSTEN',
RINKEBY: 'RINKEBY',
@ -24,7 +24,7 @@ export const WALLET_PROVIDER = {
export const ETHEREUM_NETWORK_IDS = {
// $FlowFixMe
1: ETHEREUM_NETWORK.MAIN,
1: ETHEREUM_NETWORK.MAINNET,
// $FlowFixMe
2: ETHEREUM_NETWORK.MORDEN,
// $FlowFixMe

View File

@ -1,6 +1,6 @@
// @flow
import type { Dispatch as ReduxDispatch } from 'redux'
import { ETHEREUM_NETWORK_IDS } from '~/logic/wallets/getWeb3'
import { ETHEREUM_NETWORK_IDS, ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
import { getNetwork } from '~/config'
import type { ProviderProps } from '~/logic/wallets/store/model/provider'
import { makeProvider } from '~/logic/wallets/store/model/provider'
@ -39,7 +39,9 @@ const handleProviderNotification = (
showSnackbar(NOTIFICATIONS.WRONG_NETWORK_MSG, enqueueSnackbar, closeSnackbar)
return
}
showSnackbar(NOTIFICATIONS.RINKEBY_VERSION_MSG, enqueueSnackbar, closeSnackbar)
if (ETHEREUM_NETWORK.RINKEBY === getNetwork()) {
showSnackbar(NOTIFICATIONS.RINKEBY_VERSION_MSG, enqueueSnackbar, closeSnackbar)
}
if (available) {
// NOTE: