From b0f08bc7e8bdb8550442fa2c02c76069c435e879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 30 Sep 2019 08:39:05 +0200 Subject: [PATCH] Handle Mainnet network notifications --- src/config/index.js | 2 +- src/logic/notifications/notificationTypes.js | 16 +++++++--------- src/logic/wallets/getWeb3.js | 4 ++-- src/logic/wallets/store/actions/fetchProvider.js | 6 ++++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 48feecc2..4c30f8c9 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -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) diff --git a/src/logic/notifications/notificationTypes.js b/src/logic/notifications/notificationTypes.js index 9d92ebbd..44222a3e 100644 --- a/src/logic/notifications/notificationTypes.js +++ b/src/logic/notifications/notificationTypes.js @@ -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 }, }, } diff --git a/src/logic/wallets/getWeb3.js b/src/logic/wallets/getWeb3.js index 12521e02..a849e047 100644 --- a/src/logic/wallets/getWeb3.js +++ b/src/logic/wallets/getWeb3.js @@ -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 diff --git a/src/logic/wallets/store/actions/fetchProvider.js b/src/logic/wallets/store/actions/fetchProvider.js index 49bc2a6c..5c010743 100644 --- a/src/logic/wallets/store/actions/fetchProvider.js +++ b/src/logic/wallets/store/actions/fetchProvider.js @@ -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: