Add "Disconnect wallet" button (clears stuck WC session / switch wallets)
A stuck WalletConnect request or wrong-wallet choice could trap testers. New IAPWallet.disconnect() drops the WC session, forgets the chosen provider, and clears WC localStorage so the next connect re-offers the picker. Surfaced as a "Disconnect wallet" button on the Wallet pane. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -192,5 +192,12 @@ window.IAPWallet = (function () {
|
||||
const hash = await sendTx(data, null);
|
||||
return { hash, receipt: await waitTx(hash) };
|
||||
}
|
||||
return { connect, signIn, buy, activate, waitTx };
|
||||
// Drop the WalletConnect session + any stuck pending request, and forget the
|
||||
// chosen provider so the next connect re-offers the wallet picker.
|
||||
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) {}
|
||||
}
|
||||
return { connect, signIn, buy, activate, waitTx, disconnect };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user