Fix SIWE chain-mismatch: switch wallet to Polygon 137 before sign-in and members-area unlock
This commit is contained in:
@@ -63,6 +63,7 @@ if(tid&&/^\d+$/.test(tid))document.querySelectorAll('a[href^="/tools"]').forEach
|
||||
const eth=await window.RMCWallet.pick();
|
||||
if(!eth){err.textContent='No wallet in this browser. On a phone, open this page inside your wallet app\'s browser — or use the Telegram Mini App.';btn.disabled=false;btn.textContent=UNLOCK_LABEL;return;}
|
||||
const accs=await eth.request({method:'eth_requestAccounts'});const account=accs[0];
|
||||
try{await window.RMCWallet.ensureChain(eth);}catch(ce){err.textContent='Switch your wallet to the Polygon network, then tap unlock again.';btn.disabled=false;btn.textContent=UNLOCK_LABEL;return;}
|
||||
const ch=await(await fetch('/api/public/msg-challenge',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({address:account})})).json();
|
||||
if(!ch.message)throw new Error(ch.error||'Could not start sign-in.');
|
||||
let hex='0x';for(const b2 of new TextEncoder().encode(ch.message))hex+=b2.toString(16).padStart(2,'0');
|
||||
|
||||
Reference in New Issue
Block a user