Mobile wallet deep links on the join page: no injected wallet -> offer Open-in-MetaMask/Trust buttons that reopen this URL (ref included) inside the wallet's dApp browser

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-19 10:12:55 -05:00
parent d620555209
commit 506db9de81
2 changed files with 19 additions and 1 deletions
+12 -1
View File
@@ -81,7 +81,7 @@
async function connect(){
try{
eth=await window.RMCWallet.pick();
if(!eth){ log('No wallet selected or detected. Install/unlock MetaMask, Trust, or SafePal and try again.','err'); return; }
if(!eth){ showWalletHelp(); log('No wallet detected in this browser. On a phone, use the "Open in your wallet" buttons above — on a computer, install/unlock MetaMask and refresh.','err'); return; }
attachWalletEvents();
log('Requesting wallet connection…');
var accs=await req('eth_requestAccounts'); account=accs[0];
@@ -143,6 +143,17 @@
}catch(e){}
}
// Mobile browsers have no injected wallet — offer deep links that reopen
// THIS page (query string included, so ?ref= survives) inside the wallet
// app's own browser, where window.ethereum exists.
function showWalletHelp(){
var box=$('walletHelp'); if(!box) return;
var here=location.host+location.pathname+location.search;
var mm=$('mmDeep'); if(mm) mm.href='https://metamask.app.link/dapp/'+here;
var tw=$('twDeep'); if(tw) tw.href='https://link.trustwallet.com/open_url?url='+encodeURIComponent(location.href);
box.style.display='block';
}
function attachWalletEvents(){
if(!eth||!eth.on||eth.__rmcBound) return; eth.__rmcBound=true;
eth.on('accountsChanged',function(accs){ account=(accs&&accs[0])||null; if(!account){ $('connected').style.display='none'; $('connectBtn').style.display=''; } else { $('wallet').textContent=account.slice(0,6)+'…'+account.slice(-4); refreshBalance(); } });