From aab2be1fbd5b054e8d8612c517501bdaf35c0472 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Fri, 25 Feb 2022 10:56:28 +0000 Subject: [PATCH] only allow QA network selection in development mode --- nym-wallet/config.ts | 1 + nym-wallet/src/components/NetworkSelector.tsx | 26 ++++++++++--------- nym-wallet/src/context/main.tsx | 4 +-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/nym-wallet/config.ts b/nym-wallet/config.ts index 0ae023cf84..bb9077f4ae 100644 --- a/nym-wallet/config.ts +++ b/nym-wallet/config.ts @@ -1,3 +1,4 @@ export const config = { ADMIN_ADDRESS: process.env.ADMIN_ADDRESS, + IS_DEV_MODE: process.env.NODE_ENV === 'development', } diff --git a/nym-wallet/src/components/NetworkSelector.tsx b/nym-wallet/src/components/NetworkSelector.tsx index 73e105ffa1..5c7df70a1b 100644 --- a/nym-wallet/src/components/NetworkSelector.tsx +++ b/nym-wallet/src/components/NetworkSelector.tsx @@ -1,7 +1,7 @@ import React, { useState, useContext } from 'react' import { Button, List, ListItem, ListItemIcon, ListItemText, ListSubheader, Popover } from '@mui/material' import { ArrowDropDown, CheckSharp } from '@mui/icons-material' -import { ClientContext } from '../context/main' +import { ClientContext, IS_DEV_MODE } from '../context/main' import { Network } from 'src/types' const networks: { networkName: Network; name: string }[] = [ @@ -46,17 +46,19 @@ export const NetworkSelector = () => { > Network selection - {networks.map(({ name, networkName }) => ( - { - handleClose() - switchNetwork(networkName) - }} - /> - ))} + {networks + .filter((network) => !(!IS_DEV_MODE && network.networkName === 'QA')) + .map(({ name, networkName }) => ( + { + handleClose() + switchNetwork(networkName) + }} + /> + ))} diff --git a/nym-wallet/src/context/main.tsx b/nym-wallet/src/context/main.tsx index 9c18ffb4ed..be6d803bc9 100644 --- a/nym-wallet/src/context/main.tsx +++ b/nym-wallet/src/context/main.tsx @@ -6,7 +6,7 @@ import { getMixnodeBondDetails, selectNetwork, signInWithMnemonic, signOut } fro import { currencyMap } from '../utils' import { useHistory } from 'react-router-dom' -export const { ADMIN_ADDRESS } = config +export const { ADMIN_ADDRESS, IS_DEV_MODE } = config export const urls = (network?: Network) => network === 'MAINNET' @@ -70,7 +70,7 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode setIsLoading(true) await signInWithMnemonic(mnemonic || '') await getBondDetails() - setNetwork('QA') + setNetwork('MAINNET') history.push('/balance') } catch (e) { setIsLoading(false)