Initial push

This commit is contained in:
2026-06-12 10:53:33 -04:00
parent de8dee46fa
commit 8a9f850fc2
3 changed files with 409 additions and 41 deletions

View File

@@ -10,8 +10,10 @@
// ASSOCIATION LANDING
// ----------------------------------------------------------------------------
function cry01_render_landing($association_slug, $access) {
// Renders the main cry01 page: balance display + signal board.
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.
$raw = @file_get_contents('addon/vs01/config.json');
$cfg = $raw ? json_decode($raw, true) : [];
$assoc = $cfg['associations'][$association_slug] ?? [];
@@ -32,6 +34,7 @@ function cry01_render_landing($association_slug, $access) {
$out .= '</p>';
$out .= cry01_render_balance_display();
$out .= cry01_render_lookup_form($association_slug, $lookup);
$out .= cry01_render_signal_board($association_slug, $access);
if ($access === 'participant') {
@@ -55,7 +58,7 @@ function cry01_render_landing($association_slug, $access) {
}
// ----------------------------------------------------------------------------
// BALANCE DISPLAY
// BALANCE DISPLAY (operator/cached)
// ----------------------------------------------------------------------------
function cry01_render_balance_display() {
@@ -86,6 +89,48 @@ function cry01_render_balance_display() {
return $out;
}
// ----------------------------------------------------------------------------
// PUBLIC BALANCE LOOKUP
// ----------------------------------------------------------------------------
function cry01_render_lookup_form($association_slug, $lookup = []) {
// Renders the public Ğ1 address balance 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.
$lookup_url = z_root() . '/cry01/' . cry01_h($association_slug) . '/lookup';
$error = $lookup['lookup_error'] ?? '';
$entered_address = $lookup['lookup_address'] ?? '';
$balance = $lookup['lookup_balance'] ?? 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 .= '<form method="post" action="' . $lookup_url . '" class="cry01-lookup-form">';
$out .= cry01_csrf_token();
$out .= '<div class="input-group">';
$out .= '<input type="text" class="form-control font-monospace" name="g1_lookup_address"
placeholder="g1..." maxlength="64"
value="' . cry01_h($entered_address) . '">';
$out .= '<button type="submit" class="btn btn-outline-primary">Check Balance</button>';
$out .= '</div>';
$out .= '</form>';
if ($error) {
$out .= '<div class="alert alert-danger mt-2">' . cry01_h($error) . '</div>';
} elseif ($balance !== null) {
$out .= '<div class="alert alert-success mt-2">';
$out .= '<span class="font-monospace small">' . cry01_h(substr($entered_address, 0, 16) . '...') . '</span><br>';
$out .= '<strong>' . cry01_h($balance) . '</strong>';
$out .= '</div>';
}
$out .= '</div>';
return $out;
}
// ----------------------------------------------------------------------------
// SIGNAL BOARD
// ----------------------------------------------------------------------------