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:
2026-07-21 10:38:26 +02:00
co-authored by Claude Sonnet 5
parent a6dbe48457
commit ddaca5520e
2 changed files with 17 additions and 11 deletions
+8 -5
View File
@@ -33,8 +33,8 @@
<div id="admin-form" class="hidden">
<label>Fee address (dove finisce il 30% di ogni round)</label>
<input id="admin-fee-address" placeholder="plm1q...">
<label>Bet amount (sats, 1 PLM = 100000000 sats)</label>
<input id="admin-bet-amount" placeholder="es. 1000000000 per 10 PLM">
<label>Bet amount (PLM)</label>
<input id="admin-bet-amount" placeholder="es. 10 per 10 PLM">
<button onclick="adminSave()">Salva</button>
<div id="admin-status" style="margin-top:8px;font-size:0.9rem"></div>
</div>
@@ -65,11 +65,13 @@ function adminStatus(msg, ok) {
el.style.color = ok ? '#2a7a2a' : '#a02020';
}
const SATS_PER_PLM = 100000000;
async function adminLoad() {
try {
const data = await callAdmin('GET', '/admin/config');
document.getElementById('admin-fee-address').value = data.fee_address;
document.getElementById('admin-bet-amount').value = data.bet_amount_sats;
document.getElementById('admin-bet-amount').value = data.bet_amount_sats / SATS_PER_PLM;
document.getElementById('admin-form').classList.remove('hidden');
adminStatus('Configurazione caricata.', true);
} catch (e) {
@@ -79,9 +81,10 @@ async function adminLoad() {
async function adminSave() {
const feeAddress = document.getElementById('admin-fee-address').value;
const betAmount = parseInt(document.getElementById('admin-bet-amount').value, 10);
const betAmountPlm = parseFloat(document.getElementById('admin-bet-amount').value);
const betAmountSats = Math.round(betAmountPlm * SATS_PER_PLM);
try {
await callAdmin('PUT', '/admin/config', { fee_address: feeAddress, bet_amount_sats: betAmount });
await callAdmin('PUT', '/admin/config', { fee_address: feeAddress, bet_amount_sats: betAmountSats });
adminStatus('Salvato.', true);
} catch (e) {
adminStatus('Errore nel salvataggio: ' + e.message, false);