From 89d636df825732e393c3c036091ff54189532ff6 Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 8 Sep 2026 09:26:34 -0500 Subject: [PATCH] Disconnect wallet: clear all WC state + reload so the picker truly reappears MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clearing localStorage alone wasn't enough — WalletConnect keeps the last wallet and session in memory, so it auto-reconnected the same wallet. Broadened the storage purge and reload the page after disconnect, guaranteeing a clean pick. Co-Authored-By: Claude Opus 4.8 --- public/assets/my.js | 6 ++++-- public/assets/wallet.js | 4 +++- public/index.html | 2 +- public/my.html | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/assets/my.js b/public/assets/my.js index b7e594d..c366963 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -1427,8 +1427,10 @@ })); if ($('wcDisconnect')) $('wcDisconnect').addEventListener('click', busy($('wcDisconnect'), async () => { try { await IAPWallet.disconnect(); } catch (e) {} - $('wcDisconnectInfo').textContent = 'Disconnected. Tap Connect or Get test POL to pick a wallet again.'; - IAP.status('Wallet disconnected. You can connect a different wallet now.', 'ok'); + $('wcDisconnectInfo').textContent = 'Disconnected. Reloading so you can pick a different wallet…'; + IAP.status('Wallet disconnected. Reloading…', 'ok'); + // reload to drop any in-memory WalletConnect state so the picker reappears + setTimeout(() => location.reload(), 700); })); $('activateBtn').addEventListener('click', busy($('activateBtn'), async () => { const me = await (await fetch('/api/me')).json(); diff --git a/public/assets/wallet.js b/public/assets/wallet.js index f93e2ff..446398a 100644 --- a/public/assets/wallet.js +++ b/public/assets/wallet.js @@ -197,7 +197,9 @@ window.IAPWallet = (function () { async function disconnect() { try { if (wcProvider && wcProvider.disconnect) await wcProvider.disconnect(); } catch (e) {} wcProvider = null; CHOSEN = null; wcSdkPromise = null; - try { Object.keys(localStorage).forEach(k => { if (/^wc@2|walletconnect|w3m|wcm_/i.test(k)) localStorage.removeItem(k); }); } catch (e) {} + // WalletConnect caches the last-used wallet + session in localStorage; clear + // it all so the next connect re-opens the picker instead of auto-reconnecting. + try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|ethereum_provider/i.test(k)) localStorage.removeItem(k); }); } catch (e) {} } return { connect, signIn, buy, activate, waitTx, disconnect }; })(); diff --git a/public/index.html b/public/index.html index 7918f16..2bf08b7 100644 --- a/public/index.html +++ b/public/index.html @@ -439,7 +439,7 @@ - + diff --git a/public/my.html b/public/my.html index 98fcdf7..42a876e 100644 --- a/public/my.html +++ b/public/my.html @@ -696,8 +696,8 @@ - - + +