Wallet: dollar value at today's POL price (Marty, 2026-10-22, same as InstantAdPay; US dollars): /api/public/polusd serves the contract's package rate (Chainlink POL/USD) cached 5 min; 'Paid to this wallet' shows '≈ $x.xx today', each payout line its dollar value, and the footer gives the rate, its age and that it is today's value, not the payout-day value

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-22 08:25:05 -05:00
parent e2f79c79a5
commit eedbd7280f
3 changed files with 14 additions and 4 deletions
+7
View File
@@ -150,6 +150,7 @@ const videoTokens = persistedMap('video'); // email -> watch-to-earn video token
const faucetHits = new Map(); // address -> last faucet ts (rehearsal test-POL faucet rate limit)
const visitTokens = persistedMap('visit'); // email -> verified-visit token (dwell + captcha floor)
// walk the referral chain upward via sponsorRef (code/username/member id)
const polUsdC = { at: 0, v: 0 }; // /api/public/polusd cache (2026-10-22)
async function uplineSlides(email, depth = 3) {
const out = [];
let cur = await accounts.byEmail(email);
@@ -1174,6 +1175,12 @@ const server = http.createServer(async (req, res) => {
{ const zm = /^\/api\/zone\/click\/([a-f0-9]{12})$/.exec(p); if (zm && req.method === 'GET') { const target = await zones.click(zm[1]); res.writeHead(302, { Location: target || '/', 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer-when-downgrade' }); return res.end(); } }
// -- publisher program (2026-10-10): the public offer for site owners who carry zones, and its live "Network right now"
// strip (7-day totals from zones.js, cached a minute). App host only; the link and pages domains stay single-purpose.
// Today's POL price in US dollars for the member pages (Marty, 2026-10-22, same as InstantAdPay): the contract's own package
// rate (Chainlink POL/USD), cached 5 minutes here, so browsers never call an outside price service.
if (p === '/api/public/polusd' && req.method === 'GET') {
if (!(polUsdC.at && Date.now() - polUsdC.at < 300000 && polUsdC.v > 0)) { try { const cat = await chain.catalog(); const pk = (cat.products || cat).find(x => x.costWei); const v = pk ? (pk.priceCents / 100) / (Number(BigInt(pk.costWei)) / 1e18) : 0; if (v > 0) { polUsdC.v = v; polUsdC.at = Date.now(); } } catch (e) {} }
return json(res, 200, { usd: polUsdC.v || 0, at: polUsdC.at || Date.now() }, { 'Cache-Control': 'public, max-age=60' });
}
if (p === '/api/public/publishers' && req.method === 'GET') return json(res, 200, zones.publisherPublic(), { 'Cache-Control': 'public, max-age=60' });
if (p === '/publishers' && (req.method === 'GET' || req.method === 'HEAD') && !isPagesHost(req) && !isLinkHost(req)) return sendFile(res, path.join(PUBLIC_DIR, 'publishers.html'));
{ const wm = /^\/welcome\/([a-f0-9]{48})$/.exec(p); if (wm && (req.method === 'GET' || req.method === 'POST')) { // one-time tester sign-in link