Disconnect wallet: clear all WC state + reload so the picker truly reappears
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user