Files
martbost 608ec6547b Approved launch numbers; members earn for free; Boost = a 7-day board spot (placement only)
- config: 5 sponsor levels x 10% (company 20%), approved numbers labelled as such, POT_DAILY_CENTS display (2500).
- Eligibility: a network member with a linked wallet earns a level or the resharer cut, Boost or not. /api/my/order drops line
  members with no wallet (compression); empty levels and the no-resharer cut go to the company.
- shop.js: VASShop ABI after the contract fix (Purchase.boardDays, skus().boardDays, potDailyMaxCents, potCentsToday); purchase days
  from the chain. wire.js keeps the on-chain days.
- Copy: removed "sponsor levels pay people who have bought a Boost / passed over / none qualified" and the proposal labels; Boost page,
  chatbot, contract page (split fixed forever, pot daily cap) say a Boost buys placement only. Assets ?v=2.
- qa/e2e.mjs: deploys the new VASShop (5 x 10%, pot cap 2500, SKU 7 days); a no-wallet hub member between buyer and sponsor is
  skipped and both sponsors get exactly 10% without a Boost. 61/61. Chatbot QA 108/108.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 05:19:56 -06:00

30 lines
2.2 KiB
JavaScript

// Boost page: the split (live from the contract, else the approved launch numbers), the live POL price, and the Buy button.
(async function () {
const $ = VAS.$;
VAS.wire('other').catch(() => {});
const c = await VAS.getConfig().catch(() => ({})); const sp = c.split || {}; const b = c.boost || {};
const rows = [['Resharer whose branch sold it', VAS.pct(sp.resharerBps)], ['Reward pot (pays sign-up rewards only)', VAS.pct(sp.potBps)]]
.concat((sp.levelBps || []).map((x, i) => ['Sponsor level ' + (i + 1), VAS.pct(x)]));
const used = (sp.resharerBps || 0) + (sp.potBps || 0) + (sp.levelBps || []).reduce((t, x) => t + x, 0);
rows.push(['Company (the rest, plus any level with nobody eligible in your line, and the resharer cut when there is no resharer)', VAS.pct(10000 - used)]);
$('splitRows').innerHTML = rows.map(r => '<tr><td>' + r[0] + '</td><td class="n">' + r[1] + '</td></tr>').join('') + (sp.live ? '' : '<tr><td colspan="2" class="muted">Launch numbers. The contract is not live yet.</td></tr>');
const live = !!(c.shop && c.shop.live);
const qty = () => Number($('qty').value) || 1;
async function price() {
if (!live) { $('quote').textContent = 'Boosts open when the contract goes live.'; $('buy').disabled = true; return; }
const q = await VASBuy.quote(qty()).catch(() => ({ error: 'x' }));
$('quote').textContent = q.error ? 'price unavailable right now' : '$' + (b.usd * qty()) + ', about ' + VASBuy.fmtPol(q.wei, 2) + ' POL at today\'s price';
}
price(); $('qty').onchange = price;
$('buy').onclick = async () => {
$('buy').disabled = true;
try {
const me = await VAS.getJSON('/api/me'); if (!me.signedIn) { location.href = '/my'; return; }
const before = ((await VAS.getJSON('/api/my')).boosts || []).length;
const r = await VASBuy.run({ qty: qty(), done: async () => (((await VAS.getJSON('/api/my')).boosts || []).length > before) });
VAS.status((r.recorded ? 'Your Boost is live: your ad is at the top of the reshare board.' : 'Paid and confirmed. Your Boost shows within a few minutes.') + (r.link ? ' Transaction: ' + r.link : ''), 'ok');
} catch (e) { VAS.status(String(e && e.message || e).slice(0, 400), 'err'); }
finally { $('buy').disabled = !live; }
};
})();