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 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) const getConfig = ensureOnce(configuration)

View File

@ -1,4 +1,7 @@
// @flow // @flow
import { getNetwork } from '~/config'
import { capitalize } from '~/utils/css'
export const SUCCESS = 'success' export const SUCCESS = 'success'
export const ERROR = 'error' export const ERROR = 'error'
export const WARNING = 'warning' export const WARNING = 'warning'
@ -65,8 +68,7 @@ export type Notifications = {
// Rinkeby version // Rinkeby version
RINKEBY_VERSION_MSG: Notification, RINKEBY_VERSION_MSG: Notification,
WRONG_NETWORK_RINKEBY_MSG: Notification, WRONG_NETWORK_MSG: Notification,
WRONG_NETWOEK_MAINNET_MSG: Notification,
} }
export const NOTIFICATIONS: Notifications = { export const NOTIFICATIONS: Notifications = {
@ -210,15 +212,11 @@ export const NOTIFICATIONS: Notifications = {
// Network // Network
RINKEBY_VERSION_MSG: { 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 }, options: { variant: INFO, persist: true, preventDuplicate: true },
}, },
WRONG_NETWORK_RINKEBY_MSG: { WRONG_NETWORK_MSG: {
message: 'Wrong network: Please use Rinkeby', message: `Wrong network: Please use ${capitalize(getNetwork())}`,
options: { variant: WARNING, persist: true, preventDuplicate: true },
},
WRONG_NETWOEK_MAINNET_MSG: {
message: 'Wrong network: Please use Mainnet',
options: { variant: WARNING, persist: true, preventDuplicate: true }, 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' import { getNetwork } from '~/config/index'
export const ETHEREUM_NETWORK = { export const ETHEREUM_NETWORK = {
MAIN: 'MAIN', MAINNET: 'MAINNET',
MORDEN: 'MORDEN', MORDEN: 'MORDEN',
ROPSTEN: 'ROPSTEN', ROPSTEN: 'ROPSTEN',
RINKEBY: 'RINKEBY', RINKEBY: 'RINKEBY',
@ -24,7 +24,7 @@ export const WALLET_PROVIDER = {
export const ETHEREUM_NETWORK_IDS = { export const ETHEREUM_NETWORK_IDS = {
// $FlowFixMe // $FlowFixMe
1: ETHEREUM_NETWORK.MAIN, 1: ETHEREUM_NETWORK.MAINNET,
// $FlowFixMe // $FlowFixMe
2: ETHEREUM_NETWORK.MORDEN, 2: ETHEREUM_NETWORK.MORDEN,
// $FlowFixMe // $FlowFixMe

View File

@ -1,6 +1,6 @@
// @flow // @flow
import type { Dispatch as ReduxDispatch } from 'redux' 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 { getNetwork } from '~/config'
import type { ProviderProps } from '~/logic/wallets/store/model/provider' import type { ProviderProps } from '~/logic/wallets/store/model/provider'
import { makeProvider } 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) showSnackbar(NOTIFICATIONS.WRONG_NETWORK_MSG, enqueueSnackbar, closeSnackbar)
return return
} }
showSnackbar(NOTIFICATIONS.RINKEBY_VERSION_MSG, enqueueSnackbar, closeSnackbar) if (ETHEREUM_NETWORK.RINKEBY === getNetwork()) {
showSnackbar(NOTIFICATIONS.RINKEBY_VERSION_MSG, enqueueSnackbar, closeSnackbar)
}
if (available) { if (available) {
// NOTE: // NOTE: