From 7c2aab8f65451b32adeb6fd84efeb32c6c85bf97 Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 14 Nov 2026 07:38:06 -0600 Subject: [PATCH] Buyer names: an admin wallet alias (POST /api/admin/wallet-alias {wallet, username}, a MySQL document) for members who bought from a second wallet (bizventures, spot #3, Marty 2026-11-14); the sale toast shows a short wallet instead of 'A member' when no name is known; common.js?v=20261114a. Smoke 76/76 Co-Authored-By: Claude Opus 5.5 --- public/assets/common.js | 2 +- public/board.html | 2 +- public/contract.html | 2 +- public/how.html | 2 +- public/index.html | 2 +- public/join.html | 2 +- public/ledger.html | 2 +- public/my.html | 2 +- server.js | 12 +++++++++++- 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index 90d2000..97e1cc3 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -61,7 +61,7 @@ window.BL = (function () { const box = document.createElement('div'); box.className = 'bl-toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box); const show = it => { const top = it.pays.filter(p => !p.failed).sort((a, b) => (BigInt(b.wei) > BigInt(a.wei) ? 1 : -1))[0]; - const name = it.ownerName ? '@' + esc(it.ownerName) : 'A member'; + const name = it.ownerName ? '@' + esc(it.ownerName) : esc(String(it.owner || '').slice(0, 6) + '...' + String(it.owner || '').slice(-4)); // never a blank buyer (Marty 2026-11-14) const el = document.createElement('a'); el.className = 'bl-toast'; el.href = '/ledger'; el.innerHTML = '' + name + ' took spot #' + it.spotId + (top ? '
' + (it.pays.length > 1 ? it.pays.length + ' members paid, ' : '') + (top.name ? '@' + esc(top.name) : 'a member') + ' got ' + fmtPol(top.wei, 2) + ' POL' : '
paid on-chain, $5'); diff --git a/public/board.html b/public/board.html index 32afe30..2b8eec3 100644 --- a/public/board.html +++ b/public/board.html @@ -31,7 +31,7 @@

The line so far

- + diff --git a/public/contract.html b/public/contract.html index f718859..9a20ce4 100644 --- a/public/contract.html +++ b/public/contract.html @@ -35,7 +35,7 @@
  • Open any sale in the live ledger and look at its Logs: one SpotBought event, then one Paid event per payment.
  • - + diff --git a/public/how.html b/public/how.html index 0552586..f3e1638 100644 --- a/public/how.html +++ b/public/how.html @@ -39,7 +39,7 @@

    The momentum fund

    When no spot has sold for 4 hours, the fund buys one (at most 12 a day). It gifts the spot to an active member who owns a paid spot and has not had a gift in 7 days, members who referred someone recently first. If nobody qualifies, the fund keeps the spot and its line money goes back into the fund.

    The rest of the network

    Open board slots show network sites such as InstantAdPay and LinkSpin. On InstantAdPay, ad credits buy advertising, not income.

    - + diff --git a/public/index.html b/public/index.html index 7f1a39f..dd0ad96 100644 --- a/public/index.html +++ b/public/index.html @@ -52,7 +52,7 @@ - + diff --git a/public/join.html b/public/join.html index 4ed4e74..23af0f0 100644 --- a/public/join.html +++ b/public/join.html @@ -48,7 +48,7 @@ - + diff --git a/public/ledger.html b/public/ledger.html index 541b8df..7d8171e 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -30,7 +30,7 @@

    Spot sales

    Loading the ledger...

    - + diff --git a/public/my.html b/public/my.html index 64f00db..0d9f114 100644 --- a/public/my.html +++ b/public/my.html @@ -41,7 +41,7 @@ - + diff --git a/server.js b/server.js index e0f6cfd..d1120ba 100644 --- a/server.js +++ b/server.js @@ -97,7 +97,11 @@ async function netMember(q) { if (m) netCache.set('a:' + m.address, { at: Date.now(), m }); return m; } -const nameOf = async addr => { const m = await netMember({ a: addr }); return m && m.address === addr.toLowerCase() ? m.username : null; }; +// extra wallets a member bought with (Marty 2026-11-14: bizventures bought spot #3 from a second wallet the network does not know): +// wallet -> network username, set by the admin; wallet-aliases.json is a MySQL document (docstore) +const ALIAS_F = () => path.join(C.dataDir, 'wallet-aliases.json'); +function aliases() { try { return JSON.parse(fs.readFileSync(ALIAS_F(), 'utf8')); } catch (e) { return {}; } } +const nameOf = async addr => { const al = aliases()[String(addr || '').toLowerCase()]; if (al) return al.username; const m = await netMember({ a: addr }); return m && m.address === addr.toLowerCase() ? m.username : null; }; // ---- LinkSpin Banner Spins for My Spots (Marty 2026-11-13: pull a Banner Spin in with a couple of clicks) ---- // Signed with NETWORK_SSO_SECRET: X-Net-Ts + X-Net-Sig = hex HMAC-SHA256('net.v1.' + ts + newline + raw body). LinkSpin answers // for the account holding the signed-in wallet only. @@ -465,6 +469,12 @@ const server = http.createServer(async (req, res) => { } // returning-member results: personal links opened, and how many of those visitors went on to buy (matched by the wallet that // signed in on the same browser is not tracked; this counts link opens and new members since the first open) + if (p === '/api/admin/wallet-alias' && req.method === 'POST') { // {wallet, username} adds; {wallet, remove: true} drops + const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' }); + const b = await readBody(req); const w = String(b.wallet || '').toLowerCase(); if (!/^0x[0-9a-f]{40}$/.test(w)) return json(res, 400, { error: 'wallet' }); + const al = aliases(); if (b.remove) delete al[w]; else { const un = String(b.username || '').trim(); if (!/^[A-Za-z0-9_.-]{2,40}$/.test(un)) return json(res, 400, { error: 'username' }); al[w] = { username: un, at: Date.now(), note: String(b.note || '').slice(0, 200) }; } + fs.writeFileSync(ALIAS_F(), JSON.stringify(al)); return json(res, 200, { ok: true, aliases: al }); + } if (p === '/api/admin/welcome-stats' && req.method === 'GET') { const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' }); let v = {}; try { v = JSON.parse(fs.readFileSync(path.join(C.dataDir, 'welcome-visits.json'), 'utf8')); } catch (e) {}