Skip to content

Commit

Permalink
Hide testnets on non-dev env unless localStorage.TESTNET=true (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Sep 1, 2023
1 parent 7891193 commit 232951e
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions v2/ui/containers/Connector/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true });
const walletConnect = walletConnectModule({
version: 2,
projectId: `${process.env.NEXT_PUBLIC_WC_PROJECT_ID}`,
requiredChains: [],
});
const ledger = ledgerModule();
// The trezor module have a bug, we can enable it when this has been merged and released: https://github.com/blocknative/web3-onboard/pull/1165
Expand All @@ -33,6 +32,9 @@ const torus = torusModule();
const brave = () => customBrave;
const trust = trustModule();

const isDev = process.env.NODE_ENV !== 'production';
const isTestnetEnabled = isDev || window?.localStorage?.TESTNET === 'true';

// Here we hardcode rpc urls... Not very good if infura is down. BUT I think these are just used as default before the wallets is connected.
// And our app is not using default from onboard, so it should be fine.
const supportedChains = [
Expand All @@ -52,23 +54,28 @@ const supportedChains = [
rpcUrl: getInfuraRpcURL(NetworkIdByName['mainnet-ovm']),
publicRpcUrl: 'https://mainnet.optimism.io',
},
// goerli
{
id: getChainIdHex(NetworkIdByName.goerli),
token: 'ETH',
label: 'Goerli',
rpcUrl: getInfuraRpcURL(NetworkIdByName.goerli),
publicRpcUrl: 'https://ethereum-goerli.publicnode.com',
},
// goerli Ovm
{
id: getChainIdHex(NetworkIdByName['goerli-ovm']),
token: 'ETH',
label: 'Optimism Goerli',
rpcUrl: getInfuraRpcURL(NetworkIdByName['goerli-ovm']),
publicRpcUrl: 'https://goerli.optimism.io',
},
];
].concat(
isTestnetEnabled
? [
// goerli
{
id: getChainIdHex(NetworkIdByName.goerli),
token: 'ETH',
label: 'Goerli',
rpcUrl: getInfuraRpcURL(NetworkIdByName.goerli),
publicRpcUrl: 'https://ethereum-goerli.publicnode.com',
},
// goerli Ovm
{
id: getChainIdHex(NetworkIdByName['goerli-ovm']),
token: 'ETH',
label: 'Optimism Goerli',
rpcUrl: getInfuraRpcURL(NetworkIdByName['goerli-ovm']),
publicRpcUrl: 'https://goerli.optimism.io',
},
]
: []
);

export const isSupportedWalletChain = (networkId: number) => {
return !!supportedChains.find((chain) => chain.id === `0x${networkId.toString(16)}`);
Expand Down

1 comment on commit 232951e

@vercel
Copy link

@vercel vercel bot commented on 232951e Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

v2-storybook – ./v2/ui

v2-storybook-git-master-synthetixio.vercel.app
v2-storybook-synthetixio.vercel.app
staking-storybook.vercel.app

Please sign in to comment.