This commit is contained in:
2026-06-12 15:33:51 -04:00
parent 2213aab723
commit d2d2a4d596
5 changed files with 719 additions and 350 deletions

View File

@@ -12,8 +12,9 @@
function cry01_render_landing($association_slug, $access, $lookup = []) {
// Renders the main cry01 page: balance display + signal board + public lookup.
// $lookup may contain: lookup_error, lookup_address, lookup_balance
// populated when this page is rendered as the result of a lookup POST.
// $lookup may contain: lookup_error, lookup_address, lookup_balance,
// lookup_account_info — populated when this page is rendered as the
// result of a lookup POST.
$raw = @file_get_contents('addon/vs01/config.json');
$cfg = $raw ? json_decode($raw, true) : [];
$assoc = $cfg['associations'][$association_slug] ?? [];
@@ -94,19 +95,20 @@ function cry01_render_balance_display() {
// ----------------------------------------------------------------------------
function cry01_render_lookup_form($association_slug, $lookup = []) {
// Renders the public Ğ1 address balance lookup form.
// Renders the public Ğ1 address lookup form.
// Anyone can use this — no SASE, no wallet session, nothing stored.
// Paste an address, see its current balance, read directly from the
// Civic Infrastructure's own Duniter mirror node.
// Paste an address, see its current balance and account details, read
// directly from this node's own Duniter mirror.
$lookup_url = z_root() . '/cry01/' . cry01_h($association_slug) . '/lookup';
$error = $lookup['lookup_error'] ?? '';
$error = $lookup['lookup_error'] ?? '';
$entered_address = $lookup['lookup_address'] ?? '';
$balance = $lookup['lookup_balance'] ?? null;
$balance = $lookup['lookup_balance'] ?? null;
$account_info = $lookup['lookup_account_info'] ?? null;
$out = '<div class="cry01-lookup mb-4">';
$out .= '<h5 class="cry01-section-label">Ğ1 Address Lookup</h5>';
$out .= '<p class="text-muted small">Paste any Ğ1 wallet address to check its current balance — read directly from this node\'s Duniter mirror. Nothing is stored.</p>';
$out .= '<p class="text-muted small">Paste any Ğ1 wallet address to check its current balance and account details — read directly from this node\'s Duniter mirror. Nothing is stored.</p>';
$out .= '<form method="post" action="' . $lookup_url . '" class="cry01-lookup-form">';
$out .= cry01_csrf_token();
@@ -125,12 +127,50 @@ function cry01_render_lookup_form($association_slug, $lookup = []) {
$out .= '<span class="font-monospace small">' . cry01_h(substr($entered_address, 0, 16) . '...') . '</span><br>';
$out .= '<strong>' . cry01_h($balance) . '</strong>';
$out .= '</div>';
if ($account_info) {
$out .= cry01_render_account_info_table($account_info);
}
}
$out .= '</div>';
return $out;
}
function cry01_render_account_info_table($info) {
// Renders the full decoded AccountInfo struct in plain language.
// $info is the array returned by cry01_decode_account_info() /
// cry01_get_account_info(): nonce, consumers, providers, sufficients,
// free, reserved, frozen, flags — all base-10 decimal strings of raw
// on-chain units (free/reserved/frozen/flags are in centimes; nonce/
// consumers/providers/sufficients are plain counts).
//
// 'free' is already shown separately as the headline balance — this
// table covers the remaining fields. 'flags' is an internal bitfield
// (account feature flags) and is not meaningful to a layperson; it is
// omitted from display but available in $info for anyone who needs it.
$reserved = cry01_format_g1_amount($info['reserved'] ?? '0');
$frozen = cry01_format_g1_amount($info['frozen'] ?? '0');
$nonce = $info['nonce'] ?? '0';
$out = '<div class="cry01-account-info mt-2">';
$out .= '<table class="table table-sm cry01-account-info-table">';
$out .= '<tbody>';
$out .= '<tr><td class="text-muted">Transactions sent</td><td>' . cry01_h($nonce) . '</td></tr>';
if ($info['reserved'] !== '0') {
$out .= '<tr><td class="text-muted">Reserved</td><td>' . cry01_h($reserved) . '</td></tr>';
}
if ($info['frozen'] !== '0') {
$out .= '<tr><td class="text-muted">Frozen</td><td>' . cry01_h($frozen) . '</td></tr>';
}
$out .= '</tbody>';
$out .= '</table>';
$out .= '</div>';
return $out;
}
// ----------------------------------------------------------------------------
// SIGNAL BOARD
// ----------------------------------------------------------------------------