VBB purchases live + weekly prize payouts (Marty 2026-11-14: "why does it say 'coming soon' on all the stuff in it? Shouldn't it all be live already?")
Buying (VBBShop 0x36F6...07D7): Packages page has live Buy buttons for the 10 and 40 credit packs (USD price + live POL from quoteWei, SafePal or any other crypto wallet, one-time, never a subscription, where the payment goes); My Banners has "Add the banner look ($2)" on each waiting or in-loop banner (SKU 3, ref = banner id) and a 40-character teaser editor once it has the look. POST /api/my/order builds the member's buy() call on the server (fresh keeper voucher when the hub knows their sponsor, else no sponsor); the page checks the connected wallet is the member's VBB account (explains how to switch if not), checks the balance, sends with Polygon's fee floor (/api/gas), waits on /api/tx, nudges the watcher (/api/my/paid) and polls until the credits or the look arrive. Public: /api/quote, /api/gas, /api/tx/<hash>; /api/config has shop {live, contract} + explorer. The banner look on the loop: double border + star, hover teaser (always shown on touch screens; default = the link's site). Only Tokens still says coming soon. wallet.js gains sendTx/waitTx/balance (DLB flow).
Weekly prize payouts (prize.js): each Central-time week's pot = 10% of its VBBShop sales (usdCents of Purchase events by block time), $20 floor (company top-up shown to admin), $50 cap internal, half per board, 50/30/20. Every Monday the app prepares last week's plan (winners, wallets, USD; POL quoted live from the Chainlink feed the contract uses). /admin "Approve and pay" (two clicks): refuses unless PRIZE_KEY is the contract's prizeWallet(), the feed is fresh and the wallet holds the POL + gas (says how much more to send); then once per week (docstore.claim in MySQL + plan status), consecutive nonces, each hash saved as sent, stops at the first unclear send (never auto-retried), receipts watched. Ties: earlier to reach the count wins (leaderboards use the same rule). A winner that cannot be paid (the prize or company wallet) is skipped and the rest move up; an unfilled place stays in the prize wallet. /leaders shows past winners with transaction links. Posts nothing anywhere. Compose passes PRIZE_KEY.
Tests: smoke 192/192 (stand-in chain answers quoteWei + receipts: quote, order calldata + voucher, look purchase, teaser, prizes API, UI Buy buttons). New qa/chain.mjs on a local anvil with the real VBBShop + mock feed: buy -> Purchase -> credits, voucher binds sponsor, 30/10/60 split, overpay refunded, banner look; prize prepare -> short refusal -> pay 6 transfers exact POL -> paid once: 29/29. common.js?v=3, vbb.css?v=4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
(async function () {
|
||||
VBB.renderNav('/leaders'); VBB.renderFooter();
|
||||
const $ = VBB.$, esc = VBB.esc;
|
||||
// weekly prize pot (Marty 2026-11-13): grows with sales from a floor; displayed only, no payout code yet
|
||||
// weekly prize pot (Marty 2026-11-13): grows with sales from a floor; paid each Monday after an admin approves it (prize.js)
|
||||
const c = await VBB.getConfig().catch(() => ({}));
|
||||
const pz = c.prizes || {}; const place = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th'];
|
||||
const plist = (title, arr) => '<div><h3>' + title + '</h3><ul class="pk-list">' + arr.map((v, i) => '<li>' + place[i] + ': $' + VBB.n(v) + ' in POL</li>').join('') + '</ul></div>';
|
||||
@@ -20,4 +20,16 @@
|
||||
: '<p class="muted">Nobody yet this week. Share your link from <a href="/my">My Banners</a> and take the top spot.</p>';
|
||||
$('lbVisitors').innerHTML = table(d.visitors, 'visitors');
|
||||
$('lbSources').innerHTML = table(d.sources, 'sources');
|
||||
// past weeks: winners and their payment transactions
|
||||
const pr = await VBB.getJSON('/api/prizes').catch(() => ({}));
|
||||
if (pr.past && pr.past.length) {
|
||||
const bn = { visitors: 'Most visitors sent', sources: 'Most traffic sources' };
|
||||
$('past').innerHTML = pr.past.map(w => {
|
||||
const day = new Date(w.week + 'T12:00:00Z').toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric', timeZone: 'UTC' });
|
||||
const rows = w.winners.map(x => '<tr><td>' + esc(bn[x.board] || x.board) + '</td><td><span class="rank">' + x.place + '</span></td><td>' + esc(x.name) + '</td><td class="n">$' + VBB.n(x.usd) + '</td><td class="n">' + esc(x.pol) + ' POL</td><td>'
|
||||
+ (pr.explorer ? '<a target="_blank" rel="noopener" href="' + esc(pr.explorer + '/tx/' + x.tx) + '">' + (x.confirmed ? 'Paid' : 'Sent') + '</a>' : esc(x.tx.slice(0, 10))) + '</td></tr>').join('');
|
||||
return '<div class="wk"><h3>Week of ' + esc(day) + '</h3><p class="muted small">Prize pot $' + VBB.n(w.potUsd) + (w.priceUsd ? ', POL at $' + Number(w.priceUsd).toFixed(4) : '') + '</p><div class="scroll"><table class="t"><tr><th>Board</th><th>#</th><th>Member</th><th class="n">USD</th><th class="n">POL</th><th>Transaction</th></tr>' + rows + '</table></div></div>';
|
||||
}).join('');
|
||||
$('pastCard').hidden = false;
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user