Skip to content

Commit

Permalink
Hide network selector, remove goerli support in production (#852)
Browse files Browse the repository at this point in the history
* Hide network selector in production

* Make goerli unsupported in production

* goerli unsupported (#854)

* update isSupportedChain

* update modal text

---------

Co-authored-by: Tyler Sorensen <[email protected]>
  • Loading branch information
adamgoth and tyler17 authored Feb 23, 2024
1 parent ca1e90b commit fba3fce
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
8 changes: 6 additions & 2 deletions modules/app/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const HeaderMenu = ({ onToggleTheme, mode, ...props }): JSX.Element => {
};

const Header = (): JSX.Element => {
const isProduction = process.env.NODE_ENV === 'production';

const router = useRouter();
const [showMobileMenu, setShowMobileMenu] = useState(false);
const bpi = useBreakpointIndex();
Expand Down Expand Up @@ -259,7 +261,7 @@ const Header = (): JSX.Element => {
</ExternalLink>
)}
{bpi > 3 && account && router.pathname.includes('polling') && <BallotStatus mr={3} />}
{bpi > 1 && (
{!isProduction && bpi > 1 && (
<Flex mr={3}>
<NetworkSelect />
</Flex>
Expand Down Expand Up @@ -300,6 +302,8 @@ const Header = (): JSX.Element => {
};

const MobileMenu = ({ hide, router, gas, onToggleTheme, mode, network }) => {
const isProduction = process.env.NODE_ENV === 'production';

useEffect(() => {
if (typeof window !== 'undefined') {
router.events.on('routeChangeComplete', hide);
Expand All @@ -321,7 +325,7 @@ const MobileMenu = ({ hide, router, gas, onToggleTheme, mode, network }) => {
</IconButton>
</InternalLink>
<Flex sx={{ alignItems: 'center', gap: 2 }}>
<NetworkSelect />
{!isProduction && <NetworkSelect />}
<Close sx={{ display: ['block'], '> svg': { size: [4] } }} onClick={hide} />
</Flex>
</Flex>
Expand Down
1 change: 1 addition & 0 deletions modules/app/components/layout/header/NetworkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const NetworkSelect = (): React.ReactElement => {
.filter(
k => ![SupportedChainId.GOERLIFORK].includes(CHAIN_INFO[k].chainId) && CHAIN_INFO[k].type === 'normal'
)
.filter(k => process.env.NODE_ENV !== 'production' || CHAIN_INFO[k].showInProduction)
.map(chainKey => (
<Flex
sx={walletButtonStyle}
Expand Down
2 changes: 1 addition & 1 deletion modules/web3/components/NetworkAlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const NetworkAlertModal = ({

<Text sx={{ mt: 3 }}>
Your wallet is connected to an unsupported network, please switch it to{' '}
{SupportedNetworks.MAINNET} or {SupportedNetworks.GOERLI} to continue.
{SupportedNetworks.MAINNET} to continue.
</Text>
{/* <Button onClick={() => handleSwitchNetwork(SupportedNetworks.MAINNET)}>Switch to mainnet</Button>
<Button onClick={() => handleSwitchNetwork(SupportedNetworks.GOERLI)}>Switch to goerli</Button> */}
Expand Down
18 changes: 12 additions & 6 deletions modules/web3/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const CHAIN_INFO: ChainInfo = {
rpcs: {
[NodeProviders.INFURA]: `https://mainnet.infura.io/v3/${config.INFURA_KEY}`,
[NodeProviders.ALCHEMY]: `https://eth-mainnet.g.alchemy.com/v2/${config.ALCHEMY_KEY}`
}
},
showInProduction: true
},
[SupportedChainId.GOERLI]: {
blockExplorerUrl: 'goerli.etherscan.io',
Expand All @@ -75,7 +76,8 @@ export const CHAIN_INFO: ChainInfo = {
rpcs: {
[NodeProviders.INFURA]: `https://goerli.infura.io/v3/${config.INFURA_KEY}`,
[NodeProviders.ALCHEMY]: `https://eth-goerli.alchemyapi.io/v2/${config.ALCHEMY_KEY}`
}
},
showInProduction: false
},
[SupportedChainId.GOERLIFORK]: {
blockExplorerUrl: 'goerli.etherscan.io',
Expand All @@ -88,7 +90,8 @@ export const CHAIN_INFO: ChainInfo = {
spockUrl: LOCAL_SPOCK_URL,
rpcs: {
[NodeProviders.LOCAL]: 'http://127.0.0.1:8545/'
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUMTESTNET]: {
blockExplorerUrl: 'goerli-rollup-explorer.arbitrum.io',
Expand All @@ -100,7 +103,8 @@ export const CHAIN_INFO: ChainInfo = {
defaultRpc: NodeProviders.ALCHEMY,
rpcs: {
[NodeProviders.ALCHEMY]: `https://arb-goerli.g.alchemy.com/v2/${config.ALCHEMY_ARBITRUM_TESTNET_KEY}`
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUMTESTNETFORK]: {
blockExplorerUrl: 'goerli-rollup-explorer.arbitrum.io',
Expand All @@ -113,7 +117,8 @@ export const CHAIN_INFO: ChainInfo = {
spockUrl: LOCAL_SPOCK_URL,
rpcs: {
[NodeProviders.LOCAL]: 'http://127.0.0.1:8546/'
}
},
showInProduction: false
},
[SupportedChainId.ARBITRUM]: {
blockExplorerUrl: 'arbiscan.io',
Expand All @@ -125,7 +130,8 @@ export const CHAIN_INFO: ChainInfo = {
defaultRpc: NodeProviders.ALCHEMY,
rpcs: {
[NodeProviders.ALCHEMY]: `https://arb-mainnet.g.alchemy.com/v2/${config.ALCHEMY_ARBITRUM_KEY}`
}
},
showInProduction: false
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/web3/helpers/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const networkNameToChainId = (networkName: string): number => {

export const isSupportedChain = (chainId?: number): boolean => {
if (!chainId) return false;
return CHAIN_INFO[chainId] && CHAIN_INFO[chainId].type === 'normal';
return CHAIN_INFO[chainId] && CHAIN_INFO[chainId].type === 'normal' && (process.env.NODE_ENV !== 'production' || CHAIN_INFO[chainId].showInProduction);
};

export const getGaslessNetwork = (network: SupportedNetworks): SupportedNetworks => {
Expand Down
1 change: 1 addition & 0 deletions modules/web3/types/chain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type SupportedChain = {
defaultRpc: string;
spockUrl?: string;
type: 'gasless' | 'normal';
showInProduction: boolean;
rpcs: {
[key: string]: string;
};
Expand Down

0 comments on commit fba3fce

Please sign in to comment.