fetch min_amount from server instead of hardcoding 50000

This commit is contained in:
2026-07-05 19:18:38 -04:00
parent dbc00b6012
commit f0d4104834
2 changed files with 207 additions and 2 deletions

View File

@@ -311,7 +311,7 @@ footer a{color:var(--accent);text-decoration:none}
<div class="panel">
<h2>How ranking works</h2>
<p class="lead">Bid-based ranking: higher contributions rank higher.</p>
<div style="display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px"><span style="color:var(--muted)">Listing threshold</span><b class="mono">50,000 sats</b></div>
<div style="display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px"><span style="color:var(--muted)">Listing threshold</span><b class="mono"><span id="thr-min">50,000</span> sats</b></div>
<div style="display:flex;justify-content:space-between;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px"><span style="color:var(--muted)">Plugin integration</span><b>automatic</b></div>
<div style="display:flex;justify-content:space-between;padding:8px 0;font-size:13px"><span style="color:var(--muted)">Early-adopter guarantee</span><b>12 months</b></div>
</div>
@@ -358,6 +358,7 @@ footer a{color:var(--accent);text-decoration:none}
<script>
let allServers = [];
let withTor = true, q = "";
let minAmount = 50000;
const fmt = n => (n != null ? Number(n).toLocaleString('en-US') : '—');
@@ -440,6 +441,20 @@ async function fetchData() {
}
}
async function fetchMinAmount() {
const chain = getChain();
try {
const r = await fetch('/min_amount/' + chain);
const val = parseInt(await r.text(), 10);
if (isNaN(val)) throw new Error('invalid');
minAmount = val;
document.getElementById('thr-min').textContent = fmt(val);
} catch (err) {
minAmount = 50000;
document.getElementById('thr-min').textContent = '50,000';
}
}
document.getElementById('onion').addEventListener('change', e => {
withTor = e.target.checked;
fetchData();
@@ -456,6 +471,7 @@ document.getElementById('chainSeg').addEventListener('click', e => {
[...e.currentTarget.children].forEach(x => x.setAttribute('aria-pressed', 'false'));
b.setAttribute('aria-pressed', 'true');
fetchData();
fetchMinAmount();
});
document.getElementById('submit').addEventListener('click', async () => {
@@ -495,7 +511,7 @@ document.getElementById('submit').addEventListener('click', async () => {
}
document.getElementById('iv-status').className = 'ok-line';
document.getElementById('iv-status').textContent = '✓ Server added: ' + (result.url || url) + '. Pay the invoice to complete.';
document.getElementById('iv-min').textContent = (result.min_amount || '50,000') + ' sats';
document.getElementById('iv-min').textContent = fmt(result.min_amount != null ? result.min_amount : minAmount) + ' sats';
document.getElementById('iv-chain').textContent = result.chain || chain;
document.getElementById('iv-addr').textContent = result.address || '—';
document.getElementById('iv-balance').textContent = result.balance != null ? fmt(result.balance) : '—';
@@ -536,6 +552,7 @@ document.getElementById('url').addEventListener('keydown', e => {
const blob = new Blob([JSON.stringify(allServers, null, 2)], { type: 'application/json' });
document.getElementById('download').href = URL.createObjectURL(blob);
fetchData();
fetchMinAmount();
})();
</script>
</body>