Wallet: EIP-6963 discovery; with more than one wallet installed the account picker and disconnect no longer assume window.ethereum (Phantom held it in Michael's Chrome, so every pick went to Phantom and was rejected): the named wallet list opens instead; cache tag bumped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-21 06:25:23 -05:00
parent 08bfa2afd7
commit 33f3b9d337
3 changed files with 14 additions and 4 deletions
+12 -2
View File
@@ -18,6 +18,16 @@ window.IAPWallet = (function () {
const APPKIT_URL = 'https://cdn.jsdelivr.net/npm/@reown/appkit-cdn@1.8.23/dist/appkit.js';
let modal = null, akPromise = null, provider = null;
// EIP-6963 discovery (2026-10-21, Michael's Chrome: Phantom held window.ethereum, so every "pick an account" prompt went
// to Phantom and failed). Every installed wallet announces itself here; with more than one, never assume the default
// slot is the wallet the member means: send them through the wallet list, where each one is named.
const announced = [];
try {
window.addEventListener('eip6963:announceProvider', e => { const d = e && e.detail; if (d && d.provider && !announced.some(x => x.provider === d.provider)) announced.push(d); });
window.dispatchEvent(new Event('eip6963:requestProvider'));
} catch (e) {}
// the default-slot wallet, only when it is the ONLY wallet installed (older wallets that never announce count as one)
const soleInjected = () => (window.ethereum && window.ethereum.request && announced.length <= 1) ? window.ethereum : null;
async function initAppKit(c) {
if (modal) return modal;
@@ -108,7 +118,7 @@ window.IAPWallet = (function () {
async function pickAccount() {
const c = await IAP.getConfig();
await initAppKit(c);
const inj = window.ethereum;
const inj = soleInjected(); // several wallets installed: go straight to the named wallet list below
if (inj && inj.request) {
try {
await inj.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] });
@@ -293,7 +303,7 @@ window.IAPWallet = (function () {
// (wallets without it just ignore the call), and the pick flag makes the next connect open the picker.
async function disconnect() {
try { localStorage.setItem(PICK_KEY, '1'); } catch (e) {}
const inj = window.ethereum;
const inj = (provider && provider.request && isInjected()) ? provider : soleInjected(); // revoke on the wallet actually in use
if (inj && inj.request) { try { await Promise.race([inj.request({ method: 'wallet_revokePermissions', params: [{ eth_accounts: {} }] }), new Promise(r => setTimeout(r, 1000))]); } catch (e) {} }
await dropSession();
}
+1 -1
View File
@@ -81,7 +81,7 @@
</div>
</div>
<script src="/assets/common.js?v=20261018p25"></script>
<script src="/assets/wallet.js?v=20261018a"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/cr-shell.js?v=20261018c"></script>
<script src="/assets/credits-screen.js?v=20261019pos"></script>
</body>
+1 -1
View File
@@ -1010,7 +1010,7 @@
<script src="/assets/common.js?v=20261018p25"></script>
<script src="/assets/cr-shell.js?v=20261018c"></script>
<script src="/assets/tools.js?v=20261011a"></script>
<script src="/assets/wallet.js?v=20261018a"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/promo.js?v=20261020bs3"></script>
<script src="/assets/my.js?v=20261020bs3"></script>
<script src="/assets/chat.js?v=20261016a"></script>