Show and accept amounts in PLM in the test/admin UIs

Balance, withdrawal amount and bet_amount_sats are entered/displayed in
PLM in both static pages; conversion to sats happens client-side right
before the API call, since the backend contract stays sats-based.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5 committed 2026-07-21 10:38:26 +02:00
1 parent a6dbe48457
commit ddaca5520e
2 files changed
+17 -11

No files matched your search

+9 -6
View File
@@ -48,7 +48,7 @@
<div>Indirizzo di deposito / vincite:</div>
<div class="addr" id="dash-address"></div>
<div style="margin-top:12px">Saldo interno:</div>
<div class="balance"><span id="dash-balance">-</span> sats <button onclick="refreshMe()">Aggiorna</button></div>
<div class="balance"><span id="dash-balance">-</span> PLM <button onclick="refreshMe()">Aggiorna</button></div>
<hr>
<h3>Bet</h3>
@@ -58,8 +58,8 @@
<h3>Withdrawal</h3>
<label>Indirizzo esterno</label>
<input id="wd-address" placeholder="plm1q...">
<label>Importo (sats, 1 PLM = 100000000 sats)</label>
<input id="wd-amount" placeholder="es. 200000000 per 2 PLM">
<label>Importo (PLM)</label>
<input id="wd-amount" placeholder="es. 2 per 2 PLM">
<button onclick="withdraw()">Preleva</button>
</section>
@@ -123,10 +123,12 @@ function logout() {
document.getElementById('auth-section').classList.remove('hidden');
}
const SATS_PER_PLM = 100000000;
async function refreshMe() {
try {
const data = await call('GET', '/users/me');
document.getElementById('dash-balance').textContent = data.balance_sats;
document.getElementById('dash-balance').textContent = data.balance_sats / SATS_PER_PLM;
} catch (e) {}
}
@@ -137,8 +139,9 @@ async function placeBet() {
async function withdraw() {
const ext = document.getElementById('wd-address').value;
const amt = parseInt(document.getElementById('wd-amount').value, 10);
try { await call('POST', '/withdrawals', { external_address: ext, amount_sats: amt }); } catch (e) {}
const amtPlm = parseFloat(document.getElementById('wd-amount').value);
const amtSats = Math.round(amtPlm * SATS_PER_PLM);
try { await call('POST', '/withdrawals', { external_address: ext, amount_sats: amtSats }); } catch (e) {}
refreshMe();
}