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 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-08 08:05:58 -05:00
parent f0e42e47bb
commit 9cff0dc667
3 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -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);