Files
viraladsource/public/assets/admin.js
T
Marty Bostick edaf98c8f6 ViralAdSource app (Marty approved 2026-11-16): free text ads that spread by reshares, each ad with its own family tree
Watershed look from the approved mockup (hero, topo pattern, icons). Network sign-in through the hub, hub membership, activity ping.
Reshare links per member per ad with branch/step tracking; family-tree dashboard (branch, step, reshares, views, clicks, sign-ups, Boosts).
Verified views earn ad credits for the branch's resharer (L3). L2 sign-up pipeline (hub-new, confirmed email, not self device/IP,
throwaway block, daily cap, fraud score) with keeper-signed reward vouchers and a pending-rewards ledger; payouts OFF (REWARD_PAYOUTS).
L1 Boosts through VASShop with signed orders naming the sponsor line and the resharer. Trust pack, chatbot, promo kit, PolHunter embed.
All numbers are PROPOSALS until Marty sets them. qa/e2e.mjs 59/59 on a local anvil chain, chatbot test 108/108.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:19:34 -06:00

24 lines
2.7 KiB
JavaScript

// Admin: status, the L2 sign-up checks (release / reject / recheck), the pending-rewards ledger, and (staging only) the test-member switch.
// The token stays in this tab only (sessionStorage).
(function () {
const $ = VAS.$, esc = VAS.esc;
let tok = ''; try { tok = sessionStorage.getItem('vas.admin') || ''; } catch (e) {}
const H = () => ({ 'x-admin-token': tok, 'Content-Type': 'application/json' });
const api = (p, body) => VAS.getJSON(p, body ? { method: 'POST', headers: H(), body: JSON.stringify(body) } : { headers: H() });
async function load() {
if (!tok) return;
const s = await api('/api/admin/status'); $('statusOut').textContent = JSON.stringify(s, null, 2); $('testBox').hidden = !s.testSwitch;
const su = await api('/api/admin/signups');
$('suRows').innerHTML = (su.signups || []).map(x => '<tr><td class="mono">' + esc(x.id) + '</td><td>' + esc(x.status) + '</td><td>' + esc(x.email) + (x.confirmLink ? '<br><a href="' + esc(x.confirmLink) + '">staging confirm link</a>' : '') + '</td><td>' + esc(x.resharer || '')
+ '</td><td style="font-size:12px">' + esc(JSON.stringify(x.checks || {})) + (x.fail.length ? '<br><b>fail:</b> ' + esc(x.fail.join(', ')) : '') + (x.hold.length ? '<br><b>hold:</b> ' + esc(x.hold.join(', ')) : '')
+ '</td><td><button class="btn sm" data-a="release" data-id="' + esc(x.id) + '">Release</button> <button class="btn sm" data-a="reject" data-id="' + esc(x.id) + '">Reject</button> <button class="btn sm" data-a="recheck" data-id="' + esc(x.id) + '">Recheck</button></td></tr>').join('') || '<tr><td colspan="6" class="muted">none</td></tr>';
const rw = await api('/api/admin/rewards');
$('rwRows').innerHTML = (rw.rewards || []).map(r => '<tr><td class="mono">' + esc(r.id) + '</td><td>' + esc(r.toName || r.to) + '</td><td>' + esc(r.kind) + '</td><td>' + esc(r.cents) + '</td><td>' + esc(r.status)
+ '</td><td class="mono" style="font-size:12px">' + (r.voucher ? 'signed, nonce ' + esc(String(r.voucher.nonce).slice(0, 10)) + '...' : esc(r.note || '')) + '</td></tr>').join('') || '<tr><td colspan="6" class="muted">none</td></tr>';
}
document.addEventListener('click', async e => { const b = e.target.closest('button[data-a]'); if (!b) return; const r = await api('/api/admin/signup', { id: b.dataset.id, action: b.dataset.a }); if (r.error) VAS.status(r.error, 'err'); load(); });
$('go').onclick = () => { tok = $('tok').value.trim(); try { sessionStorage.setItem('vas.admin', tok); } catch (x) {} load(); };
$('tGo').onclick = async () => { const r = await api('/api/admin/test-member', { address: $('tAddr').value.trim(), username: $('tName').value.trim() || undefined }); VAS.status(r.error || 'Marked as a test member.', r.error ? 'err' : 'ok'); };
load();
})();