Swap page: the RPC-syncing line (block N of at least 26,972) instead of unreadable reserves while the public Devnet 3 node is behind the pools

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-08 10:26:01 +00:00
parent caa0071efc
commit c64e809fdd

View file

@ -430,6 +430,7 @@ dt{color:var(--ash)}dd{margin:0;font-family:var(--f-mono);font-size:13px;overflo
lastQuote=null;$('amount-out').value=''; lastQuote=null;$('amount-out').value='';
if(!tin||!tout||tin.key===tout.key){say($('quote-line'),'Pick two different tokens.','');return;} if(!tin||!tout||tin.key===tout.key){say($('quote-line'),'Pick two different tokens.','');return;}
if(amt===null||amt===0n){say($('quote-line'),'Enter an amount for a quote. Slippage limit 1 percent, deadline 10 minutes.','');return;} if(amt===null||amt===0n){say($('quote-line'),'Enter an amount for a quote. Slippage limit 1 percent, deadline 10 minutes.','');return;}
if(rpcBehind){say($('quote-line'),'The public RPC is still syncing; quotes come when it reaches the pools.','bad');return;}
call(A.router,enc(S.getAmountsOut,['uint256','address[]'],[amt,path(tin,tout)])).then(function(r){ call(A.router,enc(S.getAmountsOut,['uint256','address[]'],[amt,path(tin,tout)])).then(function(r){
var w=words(r);var out=w[w.length-1];lastQuote={tin:tin,tout:tout,amt:amt,out:out,min:out*99n/100n}; var w=words(r);var out=w[w.length-1];lastQuote={tin:tin,tout:tout,amt:amt,out:out,min:out*99n/100n};
$('amount-out').value=fmt(out,6); $('amount-out').value=fmt(out,6);
@ -479,7 +480,15 @@ dt{color:var(--ash)}dd{margin:0;font-family:var(--f-mono);font-size:13px;overflo
setInterval(refreshProofs,10000); setInterval(refreshProofs,10000);
// ---- pools and the faucets ---- // ---- pools and the faucets ----
var DEPLOY_BLOCK=26972, rpcBehind=false;
function refreshPools(){ function refreshPools(){
rpc('eth_blockNumber',[]).then(function(n){
var h=parseInt(n,16);rpcBehind=h<DEPLOY_BLOCK;
if(rpcBehind){$('pools-body').innerHTML='<tr><td colspan="2">The public RPC is still syncing: block '+h.toLocaleString('en-GB')+' of at least '+DEPLOY_BLOCK.toLocaleString('en-GB')+'. Reserves, quotes and swaps appear when it reaches the pools.</td></tr>';return;}
return readPools();
}).catch(function(){$('pools-body').innerHTML='<tr><td colspan="2">The public RPC did not answer. Try again in a minute.</td></tr>';});
}
function readPools(){
Promise.all(POOLS.map(function(p){return call(A.router,enc(S.getReserves,['address','address'],[p.a,p.b])).then(function(r){var w=words(r);return fmt(w[0],2)+' '+p.sa+' / '+fmt(w[1],2)+' '+p.sb;}).catch(function(){return 'unreadable';});})).then(function(rows){ Promise.all(POOLS.map(function(p){return call(A.router,enc(S.getReserves,['address','address'],[p.a,p.b])).then(function(r){var w=words(r);return fmt(w[0],2)+' '+p.sa+' / '+fmt(w[1],2)+' '+p.sb;}).catch(function(){return 'unreadable';});})).then(function(rows){
$('pools-body').innerHTML=POOLS.map(function(p,i){return '<tr><td>'+p.name+'</td><td>'+rows[i]+'</td></tr>';}).join(''); $('pools-body').innerHTML=POOLS.map(function(p,i){return '<tr><td>'+p.name+'</td><td>'+rows[i]+'</td></tr>';}).join('');
}); });