@@ -21,6 +21,7 @@ import { useNetwork } from 'store/network';
2121import { WALLET_TYPES } from 'lib/constants';
2222import { useWalletConnect } from 'lib/useWalletConnect';
2323import { MetamaskWallet } from 'lib/metamask';
24+import { expectedChainId } from 'lib/network';
2425import useLoginView from 'lib/useLoginView';
2526import { getAuthToken } from 'lib/authToken';
2627
@@ -94,6 +95,20 @@ export default function LoginSelector({
9495 'Device does not have an Ethereum provider available (is Metamask or Brave Wallet installed?)'
9596 );
9697 }
98+
99+ /**
100+ * Ensure wallet is connected to expected chain
101+ */
102+ if (window.ethereum.chainId !== expectedChainId() ) {
103+ console.log(`unexpected chain: ${window.ethereum.chainId}`);
104+ await window.ethereum.request({
105+ method: 'wallet_switchEthereumChain',
106+ params: [{ chainId: expectedChainId() }],
107+ });
108+ window.location.reload();
109+ return;
110+ }
111+
97112 setMetamask(true);
98113 setMetamaskSelected(true);
99114