From ad5c5721aac3fbccdbce43d8573888c29d04a272 Mon Sep 17 00:00:00 2001 From: martbost Date: Fri, 28 Aug 2026 04:03:18 -0500 Subject: [PATCH] Wallet-connect resilience: contract costs are immutable constants, so bake verified wei fallbacks for when the wallet's internal RPC fails (MetaMask iOS 'Load failed'); friendlier retry message on network hiccups join-now.js entry price + my.js upgrade table. Reported by Neville's team overnight 8/28. Co-Authored-By: Claude Fable 5 --- public/join-now.js | 22 ++++++++++++++++++---- public/my.js | 15 +++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/public/join-now.js b/public/join-now.js index c8666d3..b594983 100644 --- a/public/join-now.js +++ b/public/join-now.js @@ -24,10 +24,17 @@ fetch('/api/public/config').then(function(r){return r.json()}).then(function(c){ async function req(method,params){ if(!eth) throw new Error('No wallet found'); return await eth.request({method:method,params:params||[]}); } async function ethCall(data){ return await req('eth_call',[{to:CONTRACT,data:data},'latest']); } + // Immutable contract constant (getAllCosts premium[0], verified on-chain). + // Fallback when the WALLET's internal RPC hiccups (MetaMask iOS surfaces + // that as "Load failed") — prices can never change, so baking it is safe. + var REG_PREM_WEI=343406593406593400832n; async function loadCosts(){ - var r=await ethCall(SEL_GETCOSTS); var d=r.slice(2), w=[]; - for(var i=0;iConnect wallet once more and it usually goes right through.','err'); + }else{ + log('Connect failed: '+m,'err'); + } + } } // Inside a wallet's in-app browser the wallet is often ALREADY connected — // recognize it silently on load (eth_accounts never prompts) instead of diff --git a/public/my.js b/public/my.js index 0ad4918..e5e7eee 100644 --- a/public/my.js +++ b/public/my.js @@ -229,11 +229,18 @@ try{await upEth.request({method:'wallet_switchEthereumChain',params:[{chainId:UPG.POLYGON}]});} catch(e){if(e&&e.code===4902){await upEth.request({method:'wallet_addEthereumChain',params:[{chainId:UPG.POLYGON,chainName:'Polygon Mainnet',nativeCurrency:{name:'POL',symbol:'POL',decimals:18},rpcUrls:['https://polygon-rpc.com'],blockExplorerUrls:['https://polygonscan.com']}]});}else{throw e;}} } - // exact cost from the contract (BigInt) + // exact cost from the contract (BigInt). Costs are immutable constants, + // so if the WALLET's internal RPC hiccups (MetaMask iOS: "Load failed") + // we fall back to the verified baked table instead of failing the flow. upgLog('Reading the exact upgrade cost from the contract…'); - const r=await upEth.request({method:'eth_call',params:[{to:UPG.CONTRACT,data:UPG.SEL_GETCOSTS},'latest']}); - const words=[];for(let i=2;i