diff --git a/src/components/nav/ConnectButton.tsx b/src/components/nav/ConnectButton.tsx index 1f813eb..934dd4b 100644 --- a/src/components/nav/ConnectButton.tsx +++ b/src/components/nav/ConnectButton.tsx @@ -6,6 +6,7 @@ import { Identicon } from 'src/components/Identicon' import { SolidButton } from 'src/components/buttons/SolidButton' import { BalancesSummary } from 'src/components/nav/BalancesSummary' import { NetworkModal } from 'src/components/nav/NetworkModal' +import { cleanupStaleWalletSessions } from 'src/config/wallets' import ClipboardDark from 'src/images/icons/clipboard-plus-dark.svg' import Clipboard from 'src/images/icons/clipboard-plus.svg' import CubeDark from 'src/images/icons/cube-dark.svg' @@ -24,6 +25,11 @@ export function ConnectButton() { const { openConnectModal } = useConnectModal() const { disconnect } = useDisconnect() + const onClickConnect = () => { + cleanupStaleWalletSessions() + openConnectModal?.() + } + const onClickCopy = async () => { if (!address) return await tryClipboardSet(address) @@ -91,7 +97,7 @@ export function ConnectButton() { styles="sm:mr-3" /> } - onClick={openConnectModal} + onClick={onClickConnect} >
Connect
diff --git a/src/components/nav/NetworkModal.tsx b/src/components/nav/NetworkModal.tsx index b4f9ae3..daf45c3 100644 --- a/src/components/nav/NetworkModal.tsx +++ b/src/components/nav/NetworkModal.tsx @@ -1,5 +1,6 @@ import { toast } from 'react-toastify' import { ChainMetadata, allChains, chainIdToChain } from 'src/config/chains' +import { cleanupStaleWalletSessions } from 'src/config/wallets' import { reset as accountReset } from 'src/features/accounts/accountSlice' import { reset as blockReset } from 'src/features/blocks/blockSlice' import { resetTokenPrices } from 'src/features/chart/tokenPriceSlice' @@ -25,6 +26,7 @@ export function NetworkModal({ isOpen, close }: Props) { try { if (!switchNetworkAsync) throw new Error('switchNetworkAsync undefined') logger.debug('Resetting and switching to network', c.name) + cleanupStaleWalletSessions() await switchNetworkAsync(c.chainId) dispatch(blockReset()) dispatch(accountReset()) @@ -38,9 +40,9 @@ export function NetworkModal({ isOpen, close }: Props) { return ( -
-
-
+
+
+
Connected to:
@@ -49,7 +51,7 @@ export function NetworkModal({ isOpen, close }: Props) {
-
+
Block Number:
@@ -58,7 +60,7 @@ export function NetworkModal({ isOpen, close }: Props) {
-
+
Node Rpc Url:
@@ -69,7 +71,7 @@ export function NetworkModal({ isOpen, close }: Props) {
-
+
{allChains.map((c) => (