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:
+12
-1
@@ -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(); } });
|
||||
|
||||
Reference in New Issue
Block a user