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:
@@ -1425,6 +1425,11 @@
|
|||||||
+ (copied ? ' is copied' : '') + '. On the faucet, choose <b>Polygon Amoy</b>, paste your address, and request POL. Then come back and buy.';
|
+ (copied ? ' is copied' : '') + '. On the faucet, choose <b>Polygon Amoy</b>, paste your address, and request POL. Then come back and buy.';
|
||||||
IAP.status('Faucet opened in a new tab. Choose Polygon Amoy, paste your address, and request test POL.', 'ok');
|
IAP.status('Faucet opened in a new tab. Choose Polygon Amoy, paste your address, and request test POL.', 'ok');
|
||||||
}));
|
}));
|
||||||
|
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');
|
||||||
|
}));
|
||||||
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
|
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
|
||||||
const me = await (await fetch('/api/me')).json();
|
const me = await (await fetch('/api/me')).json();
|
||||||
IAP.status('Confirm the free activation in your wallet…');
|
IAP.status('Confirm the free activation in your wallet…');
|
||||||
|
|||||||
@@ -192,5 +192,12 @@ window.IAPWallet = (function () {
|
|||||||
const hash = await sendTx(data, null);
|
const hash = await sendTx(data, null);
|
||||||
return { hash, receipt: await waitTx(hash) };
|
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 };
|
||||||
})();
|
})();
|
||||||
|
|||||||
+1
-1
@@ -439,7 +439,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script src="/assets/common.js?v=20260908c"></script>
|
<script src="/assets/common.js?v=20260908c"></script>
|
||||||
<script src="/assets/wallet.js?v=20260908f"></script>
|
<script src="/assets/wallet.js?v=20260908g"></script>
|
||||||
<script src="/assets/home.js?v=20260906m"></script>
|
<script src="/assets/home.js?v=20260906m"></script>
|
||||||
<script src="/assets/chat.js?v=20260906m"></script>
|
<script src="/assets/chat.js?v=20260906m"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+8
-2
@@ -645,6 +645,12 @@
|
|||||||
<p><button class="btn" id="faucetBtn" type="button">Get free test POL</button>
|
<p><button class="btn" id="faucetBtn" type="button">Get free test POL</button>
|
||||||
<span class="small muted" id="faucetInfo"></span></p>
|
<span class="small muted" id="faucetInfo"></span></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Wallet connection</h3>
|
||||||
|
<p class="muted small">Connected the wrong wallet, or stuck on a transaction prompt? Disconnect to clear the session, then reconnect or pick a different wallet.</p>
|
||||||
|
<p><button class="btn sec small" id="wcDisconnect" type="button">Disconnect wallet</button>
|
||||||
|
<span class="small muted" id="wcDisconnectInfo"></span></p>
|
||||||
|
</div>
|
||||||
<div class="grid c2">
|
<div class="grid c2">
|
||||||
<div class="card"><h3>Your account</h3>
|
<div class="card"><h3>Your account</h3>
|
||||||
<p id="posLine" class="muted small">…</p></div>
|
<p id="posLine" class="muted small">…</p></div>
|
||||||
@@ -690,8 +696,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20260908c"></script>
|
<script src="/assets/common.js?v=20260908c"></script>
|
||||||
<script src="/assets/wallet.js?v=20260908f"></script>
|
<script src="/assets/wallet.js?v=20260908g"></script>
|
||||||
<script src="/assets/my.js?v=20260908i"></script>
|
<script src="/assets/my.js?v=20260908j"></script>
|
||||||
<script src="/assets/chat.js?v=20260907l"></script>
|
<script src="/assets/chat.js?v=20260907l"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user