From ddaca5520e2ca5f73388707e639ab97b5feded26 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 21 Jul 2026 10:38:26 +0200 Subject: [PATCH] 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 --- app/static/admin.html | 13 ++++++++----- app/static/index.html | 15 +++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/static/admin.html b/app/static/admin.html index 305df2c..e692dfc 100644 --- a/app/static/admin.html +++ b/app/static/admin.html @@ -33,8 +33,8 @@ @@ -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); diff --git a/app/static/index.html b/app/static/index.html index 5e04ca1..a5924a5 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -48,7 +48,7 @@
Indirizzo di deposito / vincite:
Saldo interno:
-
- sats
+
- PLM

Bet

@@ -58,8 +58,8 @@

Withdrawal

- - + + @@ -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(); }