WalletConnect: make the chain optional (fixes Trust hang on Amoy)

Requiring Amoy (80002) in the session namespaces made Trust Wallet hang on
"redirecting" — testnet wallets that don't natively list Amoy can't satisfy a
required-chain proposal. Switched to optionalChains so the session establishes;
the chain is switched/added after connect.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-08 08:44:21 -05:00
parent 653a5e333a
commit dcfc5ca86e
3 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -76,8 +76,11 @@ window.IAPWallet = (function () {
const EP = await loadWcSdk();
const chainId = Number(c.chainId);
if (!wcProvider) {
// optionalChains (not required): testnet wallets like Trust hang or reject
// a session that REQUIRES a chain they don't natively list (Amoy 80002).
// Optional lets the session establish; we switch/add the chain after.
wcProvider = await EP.init({
projectId, chains: [chainId], optionalChains: [chainId], showQrModal: true,
projectId, optionalChains: [chainId], showQrModal: true,
rpcMap: { [chainId]: c.rpc },
metadata: { name: c.siteName || 'InstantAdPay', description: c.tagline || 'Advertise and earn, paid on-chain.',
url: location.origin, icons: [location.origin + '/logo-icon.png'] }