Gas floor fix, chain guard, and dashboard footer

- wallet.js: fetch correct EIP-1559 fees from the network (Amoy/Polygon Bor
  enforce a ~25-30 gwei priority floor MetaMask's estimate misses) via new
  /api/gas; hard chain-guard before signing so a tx never lands on the wrong
  network; accept the wallet's usual networks in AppKit so its modal stops
  looping and drive add+switch ourselves.
- chain.js: suggestedFees() from eth_maxPriorityFeePerGas + base fee.
- Dashboard: move the Site links (Ad packages / Live ledger / The contract)
  out of the sidebar into a page footer; hide the sidebar scrollbar.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-08 10:49:34 -05:00
parent 8958a9d145
commit 7b131dad28
6 changed files with 70 additions and 15 deletions
+17 -1
View File
@@ -235,5 +235,21 @@ function init(opts) {
setInterval(tail, POLL_MS);
}
// Recommended EIP-1559 fees straight from the network. Polygon Amoy's Bor nodes
// enforce a ~25 gwei minimum priority fee, but wallets (notably MetaMask) apply
// a stale low estimate and get the raw tx rejected ("gas tip below minimum").
// We hand the wallet correct fees so the tx clears the floor: a priority tip at
// or above the network suggestion (floored at 30 gwei for headroom) and a
// maxFee that covers 2x base + tip so MetaMask never flags "max fee too low".
async function suggestedFees() {
let tip = 0n, base = 0n;
try { tip = BigInt(await rpc('eth_maxPriorityFeePerGas', [])); } catch (e) {}
try { const blk = await rpc('eth_getBlockByNumber', ['latest', false]); base = BigInt((blk && blk.baseFeePerGas) || '0x0'); } catch (e) {}
const MIN_TIP = 30000000000n; // 30 gwei — safely over Amoy's ~25 gwei floor
const priority = tip > MIN_TIP ? tip : MIN_TIP;
const maxFee = base * 2n + priority;
return { maxPriorityFeePerGas: '0x' + priority.toString(16), maxFeePerGas: '0x' + maxFee.toString(16) };
}
module.exports = { init, getConfig, reloadConfig, memberIdByAccount, memberCount, member,
product, productCount, quoteWei, creditBalance, catalog, recentEvents, totals, rpc, decodeLog };
product, productCount, quoteWei, creditBalance, catalog, recentEvents, totals, rpc, decodeLog, suggestedFees };