Add dormant public direct-join fallback (/join-now) + post-join redirect
/join-now: public self-enroll page gated behind config.dappFallbackPublic (default off -> redirects to /start, invisible until needed). Auto-assigns the current rotation sponsor via /api/public/current-sponsor, registers the user's own wallet, then redirects to /my/<newId> so new members land on their live position instead of guessing their ID. HTML lives in private/, served only via the flagged route. Reuses the proven contract engine. Admin /direct-join now also shows a 'View position ->' link to /my/<newId> after a successful join. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -78,7 +78,7 @@
|
||||
function receiptEventId(rc,topic0){
|
||||
var id=null; (rc.logs||[]).forEach(function(l){ if(l.address&&l.address.toLowerCase()===CONTRACT&&l.topics&&l.topics[0]===topic0) id=parseInt(l.topics[1],16); }); return id;
|
||||
}
|
||||
function showResult(big,sub){ var el=$('result'); if(!el) return; $('resultId').textContent=big; $('resultSub').textContent=sub; el.style.display='block'; try{el.scrollIntoView({behavior:'smooth',block:'center'});}catch(e){} }
|
||||
function showResult(big,sub,linkId){ var el=$('result'); if(!el) return; $('resultId').textContent=big; $('resultSub').textContent=sub; var lk=$('resultLink'); if(lk){ if(linkId){ lk.href='/my/'+linkId; lk.style.display='inline-flex'; } else lk.style.display='none'; } el.style.display='block'; try{el.scrollIntoView({behavior:'smooth',block:'center'});}catch(e){} }
|
||||
|
||||
async function connect(){
|
||||
if(!eth){ log('No wallet detected. Open this page in a browser with MetaMask (extension or the MetaMask in-app browser).','err'); return; }
|
||||
@@ -123,7 +123,7 @@
|
||||
if(rc.status==='0x0'){ log('⚠️ Reverted on-chain — no position created; your POL was returned (minus gas). Re-check the sponsor ID and amount.','err'); return; }
|
||||
refreshBalance();
|
||||
var newId=receiptEventId(rc,T_REGISTERED);
|
||||
if(newId){ showResult('#'+newId,'Your new position under sponsor #'+sponsor+' is live. Save this ID.'); log('🎉 Confirmed — your new position is <strong>#'+newId+'</strong>.','ok'); }
|
||||
if(newId){ showResult('#'+newId,'Your new position under sponsor #'+sponsor+' is live. Save this ID.',newId); log('🎉 Confirmed — your new position is <strong>#'+newId+'</strong>.','ok'); }
|
||||
else log('Confirmed on-chain, but could not read the ID from the receipt — check the tx on Polygonscan.','ok');
|
||||
}catch(e){ log('Register failed / rejected: '+(e.message||e),'err'); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user