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>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
// On-chain side (VASShop, ../contracts). Each job is inert until configured:
|
||||
// (a) orders: KEEPER_KEY (the keeper the contract trusts) signs EIP-712 Order(buyer, sku, qty, ref, line[], resharer, nonce, deadline).
|
||||
// line = the buyer's network sponsor line from the hub (wallets, nearest first, up to 20); resharer = the wallet of the member whose
|
||||
// reshare link the buyer came through (or zero). The contract pays the resharer's cut, the sponsor levels (pass-up over people
|
||||
// who never bought), the reward-pot slice and the company in the same transaction. A keeper signature is required for every buy.
|
||||
// reshare link the buyer came through (or zero). The contract pays the resharer's cut, the sponsor levels (places 1..5 of the
|
||||
// line; nobody needs a Boost to earn), the reward-pot slice and the company in the same transaction. A keeper signature is required
|
||||
// for every buy. Compression happens HERE (server.js /api/my/order): only network members with a linked wallet go in the line, so
|
||||
// a level passes up to the next eligible person; levels left when the line runs out, and the resharer cut with no resharer, go to
|
||||
// the company.
|
||||
// (b) rewards: the keeper signs Reward(to, usdCents, unlockAt, nonce, deadline) for an L2 sign-up reward that passed every check.
|
||||
// The voucher is kept in the pending-rewards ledger. relayReward() sends claimReward() from RELAY_KEY's wallet (gas only) and is
|
||||
// called ONLY when REWARD_PAYOUTS=1 (OFF until Marty confirms the amounts). The contract enforces the per-reward cap, the
|
||||
@@ -18,7 +21,7 @@ const store = require('./store');
|
||||
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||
const ZERO = '0x0000000000000000000000000000000000000000';
|
||||
const IFACE = new Interface([
|
||||
'event Purchase(uint256 indexed orderId, address indexed buyer, uint256 indexed sku, uint256 qty, uint256 ref, uint256 views, uint256 usdCents, uint256 weiPaid, address resharer, uint256 resharerPaid, uint256 potAdded, uint256 companyPaid)',
|
||||
'event Purchase(uint256 indexed orderId, address indexed buyer, uint256 indexed sku, uint256 qty, uint256 ref, uint256 boardDays, uint256 usdCents, uint256 weiPaid, address resharer, uint256 resharerPaid, uint256 potAdded, uint256 companyPaid)',
|
||||
'event Paid(uint256 indexed orderId, address indexed to, uint256 amount, uint8 kind, uint8 depth)',
|
||||
'event PaymentFailed(uint256 indexed orderId, address indexed to, uint256 amount, uint8 kind, uint8 depth)',
|
||||
'event PassedOver(uint256 indexed orderId, address indexed who, uint8 depth)',
|
||||
@@ -30,9 +33,9 @@ const CALLS = new Interface(['function quoteWei(uint256 sku, uint256 qty) view r
|
||||
'function claimReward(address to, uint256 usdCents, uint256 unlockAt, uint256 nonce, uint256 deadline, bytes sig) returns (uint256 weiPaid)',
|
||||
'function boostsBought(address) view returns (uint256)', 'function potBalance() view returns (uint256)', 'function potFunded() view returns (uint256)', 'function potPaid() view returns (uint256)',
|
||||
'function rewardsToday(address) view returns (uint256)', 'function rewardNonceUsed(uint256) view returns (bool)', 'function resharerBps() view returns (uint256)', 'function potBps() view returns (uint256)',
|
||||
'function levelBps() view returns (uint16[])', 'function rewardMaxCents() view returns (uint256)', 'function rewardDailyCap() view returns (uint256)', 'function potDailyMaxWei() view returns (uint256)',
|
||||
'function levelBps() view returns (uint16[])', 'function rewardMaxCents() view returns (uint256)', 'function rewardDailyCap() view returns (uint256)', 'function potDailyMaxCents() view returns (uint256)', 'function potCentsToday() view returns (uint256 paid, uint256 left)',
|
||||
'function owner() view returns (address)', 'function company() view returns (address)', 'function keeper() view returns (address)', 'function paused() view returns (bool)',
|
||||
'function totalOwed() view returns (uint256)', 'function orderCount() view returns (uint256)', 'function skus(uint256) view returns (uint64 usdCents, uint64 views, bool active)']);
|
||||
'function totalOwed() view returns (uint256)', 'function orderCount() view returns (uint256)', 'function skus(uint256) view returns (uint64 usdCents, uint64 boardDays, bool active)']);
|
||||
const TYPES = {
|
||||
Order: [{ name: 'buyer', type: 'address' }, { name: 'sku', type: 'uint256' }, { name: 'qty', type: 'uint256' }, { name: 'ref', type: 'uint256' }, { name: 'line', type: 'address[]' },
|
||||
{ name: 'resharer', type: 'address' }, { name: 'nonce', type: 'uint256' }, { name: 'deadline', type: 'uint256' }],
|
||||
@@ -96,7 +99,7 @@ function apply(ev) {
|
||||
const key = String(ev.txHash).toLowerCase() + ':' + ev.logIndex;
|
||||
if (P[key]) { st.dupes++; return false; }
|
||||
const a = ev.buyer.toLowerCase(); if (!store.member(a)) store.upsertMember(a, { via: 'wallet' });
|
||||
const rec = { at: Date.now(), blockAt: ev.blockAt || null, block: ev.block, orderId: ev.orderId, buyer: a, sku: ev.sku, qty: ev.qty, ref: ev.ref, views: ev.views,
|
||||
const rec = { at: Date.now(), blockAt: ev.blockAt || null, block: ev.block, orderId: ev.orderId, buyer: a, sku: ev.sku, qty: ev.qty, ref: ev.ref, days: ev.days,
|
||||
usdCents: ev.usdCents, weiPaid: ev.weiPaid, resharer: ev.resharer, resharerPaid: ev.resharerPaid, potAdded: ev.potAdded, companyPaid: ev.companyPaid };
|
||||
if (hooks.attach) { try { hooks.attach(rec); } catch (e) {} }
|
||||
P[key] = rec; store.save(); st.recorded++;
|
||||
@@ -110,7 +113,7 @@ function decode(l) {
|
||||
if (t0 === TOPIC) {
|
||||
const d = IFACE.parseLog({ topics: l.topics, data: l.data }).args; const r = String(d.resharer).toLowerCase();
|
||||
return { kind: 'purchase', txHash: l.transactionHash, logIndex: parseInt(l.logIndex, 16), block: parseInt(l.blockNumber, 16), orderId: Number(d.orderId), buyer: d.buyer, sku: Number(d.sku),
|
||||
qty: Number(d.qty), ref: d.ref.toString(), views: Number(d.views), usdCents: Number(d.usdCents), weiPaid: d.weiPaid.toString(), resharer: r === ZERO ? null : r,
|
||||
qty: Number(d.qty), ref: d.ref.toString(), days: Number(d.qty) ? Number(d.boardDays) / Number(d.qty) : null, usdCents: Number(d.usdCents), weiPaid: d.weiPaid.toString(), resharer: r === ZERO ? null : r,
|
||||
resharerPaid: d.resharerPaid.toString(), potAdded: d.potAdded.toString(), companyPaid: d.companyPaid.toString() };
|
||||
}
|
||||
if (t0 === RTOPIC) {
|
||||
@@ -119,7 +122,8 @@ function decode(l) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// the split of one order from its receipt: kind 0 company, 1..5 sponsor levels (with depth), 6 resharer; who was passed over
|
||||
// the split of one order from its receipt: kind 0 company, 1..5 sponsor levels (with depth), 6 resharer (`over` stays empty: the
|
||||
// contract has no pass-over since 2026-11-17, compression is done when the line is built)
|
||||
async function readSplit(tx, orderId) {
|
||||
const r = await rpc('eth_getTransactionReceipt', [tx]); if (!r || !Array.isArray(r.logs)) return null;
|
||||
const pays = [], over = [];
|
||||
@@ -187,8 +191,8 @@ async function liveRules() {
|
||||
if (!watching()) return null;
|
||||
if (rules && Date.now() - rules.at < 300000) return rules.v;
|
||||
try {
|
||||
const [r, p, l, mx, cap, pot] = await Promise.all(['resharerBps', 'potBps', 'levelBps', 'rewardMaxCents', 'rewardDailyCap', 'potBalance'].map(f => call(f).then(x => x[0])));
|
||||
const v = { resharerBps: Number(r), potBps: Number(p), levelBps: l.map(Number), rewardMaxCents: Number(mx), rewardDailyCap: Number(cap), potWei: pot.toString() };
|
||||
const [r, p, l, mx, cap, pot, pdc] = await Promise.all(['resharerBps', 'potBps', 'levelBps', 'rewardMaxCents', 'rewardDailyCap', 'potBalance', 'potDailyMaxCents'].map(f => call(f).then(x => x[0])));
|
||||
const v = { resharerBps: Number(r), potBps: Number(p), levelBps: l.map(Number), rewardMaxCents: Number(mx), rewardDailyCap: Number(cap), potWei: pot.toString(), potDailyCents: Number(pdc) };
|
||||
rules = { at: Date.now(), v }; return v;
|
||||
} catch (e) { return rules ? rules.v : null; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user