From 9cff0dc667dd523b59e736088973a4ca982110a7 Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 8 Sep 2026 08:05:58 -0500 Subject: [PATCH] WalletConnect: gate to public chains (137/Amoy), not the private rehearsal External wallets reject a WalletConnect session for the private rehearsal chain (31337) with "user rejected", since they don't recognize custom chains. Only offer WalletConnect on chains wallets know (Polygon mainnet / Amoy); it lights up automatically when the site points at a public chain. Rehearsal keeps the injected/dApp-browser path. Co-Authored-By: Claude Opus 4.8 --- public/assets/wallet.js | 7 ++++++- public/index.html | 2 +- public/my.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/assets/wallet.js b/public/assets/wallet.js index dac589b..f9dddd8 100644 --- a/public/assets/wallet.js +++ b/public/assets/wallet.js @@ -91,7 +91,12 @@ window.IAPWallet = (function () { const list = providerList(); let cfg = null; try { cfg = await IAP.getConfig(); } catch (e) {} - const wcOn = !!(cfg && String(cfg.walletConnectProjectId || '').trim()); + // WalletConnect only works on chains external wallets recognize (Polygon + // mainnet 137 / Amoy testnet 80002). On the private rehearsal chain (31337) + // wallets reject the session ("user rejected"), so we keep to the injected + // path there and light WC up automatically once we're on a public chain. + const WC_CHAINS = [137, 80002]; + const wcOn = !!(cfg && String(cfg.walletConnectProjectId || '').trim() && WC_CHAINS.includes(Number(cfg.chainId))); if (wcOn) list.push({ info: { name: 'WalletConnect — scan a QR or open your wallet app', __wc: true } }); if (!list.length) throw new Error('No wallet found. Open this page in your wallet app (Trust, MetaMask, SafePal, Phantom, OKX, TokenPocket) or install a wallet extension.'); const pick = list.length === 1 ? list[0] : await pickModal(list); diff --git a/public/index.html b/public/index.html index b96fdee..e866d20 100644 --- a/public/index.html +++ b/public/index.html @@ -439,7 +439,7 @@ - + diff --git a/public/my.html b/public/my.html index be2752e..d47fddd 100644 --- a/public/my.html +++ b/public/my.html @@ -690,7 +690,7 @@ - +