Trust pack (Marty 2026-11-14): contract proof, live ledger, proof toasts, Telegram sale cards, legal pages, network footer.

- proof.js: /api/ledger (each VBBShop purchase with its split read from the receipt's Paid/PaymentFailed events, else the contract's fixed 30/10/60 math; weekly prize transfers with their transactions), /api/contract (owner, prize wallet, company, keeper, paused, orders, balance and owed, read live and cached 5 min; Sourcify exact match, Polygonscan pending).
- Telegram (CTB Rewards bot, payments topic, TG_TOKEN/TG_CHAT/TG_PAY_TOPIC same as Downline Banners): one photo card per purchase (prebuilt VBB proof image rotated, buyer, sponsor/prize/company split in POL, this week's purchases + prize pot, Polygonscan + ledger links) and one line per confirmed prize payout. Hooks: shop.setHook (newly credited purchases only) and prize.setHook (confirmed transfers); once per tx via an in-process guard plus docstore.claim; nothing older than 2 hours.
- Pages /contract, /ledger, /terms, /disclaimer (Earnings Disclaimer), /privacy (TrustClickz, real mechanics: advertising not income, same-transaction split, prize wallet holds the 10% until Monday, no refunds on-chain, one-time purchases, crypto risk, data incl. hashed visit checks and the network hub); sitemap.
- Footer: Terms, Earnings Disclaimer, Privacy, Contract, Ledger, Support, company line, 'Part of the network' from the hub (netsites.js, /api/network-sites, fallback list), VBB marked current. Toasts add purchases and prize payouts.
- tools/proof-art.mjs renders public/art/proof/vbb-proof-{pink,blue,yellow}.png. common.js?v=5, vbb.css?v=6.
chain.mjs 49/49 (real contract on anvil + stand-in Telegram: exact split, 2 cards, no repost on rescans, 6 prize lines). smoke 241/241.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-14 10:38:40 -06:00
parent d049c529ac
commit 2fe3d9e4c0
27 changed files with 685 additions and 27 deletions
+47 -1
View File
@@ -5,6 +5,8 @@
// prizes: last week's leaderboards (seeded visits) -> prepare -> refuse while the prize wallet is short (says how much) ->
// fund it -> approve and pay -> exact POL per winner at the feed price, ties to the earlier, the prize wallet itself
// skipped -> a second approval refused -> /api/prizes lists the winners with their transactions.
// trust pack (2026-11-14): /api/ledger (each purchase with its real split from the receipt, prize payouts), /api/contract (live
// facts), the pages, and a stand-in Telegram API: one photo card per purchase, one line per prize payout, never twice.
// node qa/chain.mjs (needs anvil: ~/.foundry/bin/anvil(.exe), and forge build output in ../contracts/out)
import { spawn } from 'node:child_process';
import fs from 'node:fs';
@@ -38,6 +40,11 @@ function ctWeek(ts) { const p = Object.fromEntries(fmt.formatToParts(new Date(ts
const THIS_WEEK = ctWeek(Date.now()); const LAST_WEEK = new Date(Date.parse(THIS_WEEK + 'T12:00:00Z') - 7 * 86400000).toISOString().slice(0, 10);
const LW_AT = Date.parse(LAST_WEEK + 'T18:00:00Z'); // Monday noon CT of last week
// ---- stand-in Telegram Bot API (never the real group): records every call ----
const TPORT = PORT + 2; const tgCalls = [];
require('node:http').createServer(async (q, r) => { let b = ''; for await (const c of q) b += c; let j = {}; try { j = JSON.parse(b || '{}'); } catch (e) {}
tgCalls.push({ method: q.url.split('/').pop(), token: q.url.split('/')[1], body: j }); r.setHeader('Content-Type', 'application/json'); r.end(JSON.stringify({ ok: true, result: { message_id: tgCalls.length } })); }).listen(TPORT, '127.0.0.1').unref();
// ---- stand-in hub: M's network sponsor is S ----
const people = new Map(); // wallet -> { id, username, sponsorWallet }
const HUB_SECRET = 'c'.repeat(40);
@@ -83,7 +90,8 @@ async function main() {
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', LINK_PROBE: '0', NETWORK_LOOKUP_URL: '',
CHAIN_ID: '31337', CONTRACT_ADDRESS: SHOP, CHAIN_RPC: RPC, KEEPER_KEY: K[1], SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '300',
PRIZE_KEY: P.privateKey, PRIZE_WALLET: P.address, PRIZE_RECEIPT_MS: '300', EXPLORER: 'https://explorer.invalid',
HUB_URL: 'http://127.0.0.1:' + HPORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_ENABLED: '0' });
HUB_URL: 'http://127.0.0.1:' + HPORT, HUB_SECRET, HUB_SITE: 'vbb', HUB_ENABLED: '0',
TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TPORT });
const log = fs.openSync(path.join(OUT, 'chain-server.log'), 'w');
const srv = spawn(process.execPath, ['server.js'], { cwd: APP, env, stdio: ['ignore', log, log] }); procs.push(srv);
for (let i = 0; i < 80; i++) { try { if ((await fetch(BASE + '/health')).ok) break; } catch (e) {} await sleep(150); }
@@ -127,6 +135,38 @@ async function main() {
ok(look, 'the watcher gives that banner the look');
const spl = await call('/api/splash'); ok([...spl.loop, ...spl.queue].some(t => t.id === bid && t.look && t.teaser === 'example-member.com'), 'the loop shows it with the border + teaser');
console.log('1b. trust pack: ledger, contract, pages, Telegram cards');
const share = w => ({ sp: w * 3000n / 10000n, pz: w * 1000n / 10000n, co: w - w * 3000n / 10000n - w * 1000n / 10000n });
let led; for (let i = 0; i < 40; i++) { led = await call('/api/ledger?n=50'); const x = (led.items || []).find(y => y.tx === tx.hash.toLowerCase()); if (x && x.pays && x.pays.length === 3 && x.pays[0].role === 'sponsor') break; await sleep(200); }
const it1 = (led.items || []).find(x => x.tx === tx.hash.toLowerCase()); const sh = share(wei);
ok(it1 && it1.kind === 'purchase' && it1.what === '10 post credits' && it1.usdCents === 300, 'ledger lists the pack purchase', it1);
const pz = it1 && Object.fromEntries(it1.pays.map(x => [x.role, x]));
ok(pz && pz.sponsor && pz.sponsor.to === S && BigInt(pz.sponsor.wei) === sh.sp && BigInt(pz.prize.wei) === sh.pz && BigInt(pz.company.wei) === sh.co && pz.prize.to === P.address.toLowerCase(),
'ledger split from the receipt: 30% to the sponsor, 10% prize wallet, 60% company (exact wei)', it1 && it1.pays);
ok(led.totals && led.totals.purchases === 3 && BigInt(led.totals.sponsorWei) === BigInt(led.totals.weiPaid) * 3000n / 10000n, 'ledger totals: 3 purchases (seeded + 2), sponsor POL = 30% of both sponsored purchases', led.totals);
ok((led.items || []).some(x => x.kind === 'purchase' && x.what === 'the banner look'), 'ledger names the banner look purchase', led.items && led.items.map(x => x.what));
const cf = await call('/api/contract');
ok(cf.live === true && cf.owner === deployer.address.toLowerCase() && cf.prizeWallet === P.address.toLowerCase() && cf.company === company.toLowerCase() && cf.keeper === keeper.address.toLowerCase()
&& cf.paused === false && cf.orderCount === 2 && cf.balanceWei === '0' && cf.split.sponsorPct === 30 && cf.split.prizePct === 10 && cf.split.companyPct === 60 && cf.verified.sourcify === true,
'/api/contract reads the live facts (owner, prize wallet, company, keeper, 2 orders, holds 0)', cf);
for (const pg of ['/contract', '/ledger', '/terms', '/disclaimer', '/privacy']) { const r2 = await fetch(BASE + pg); const h = await r2.text();
ok(r2.status === 200 && h.includes('common.js?v=5') && !h.includes('—'), pg + ' serves (no em dashes)'); }
const legal = (await (await fetch(BASE + '/terms')).text()) + (await (await fetch(BASE + '/disclaimer')).text()) + (await (await fetch(BASE + '/privacy')).text());
ok(legal.includes('TrustClickz, 615 Green Valley Drive, Moody, AL 35004') && /ever billed again/.test(legal) && /final once confirmed/.test(legal) && /not an investment/.test(legal) && /network hub/.test(legal) && !/\$50|cap/i.test(legal.replace(/capture|capital|escape/gi, '')),
'legal pages: TrustClickz, one-time purchases, no refunds on-chain, not an investment, the hub, no prize cap');
const ns = await call('/api/network-sites'); const nl = Object.keys(ns).filter(k => /^\d+$/.test(k)).map(k => ns[k]);
ok(nl.length === 6 && nl.map(x => x.name).join(',') === 'InstantAdPay,LinkSpin,Downline Banners,Viral Banner Blitz,Stack POL,Earners Corner', '/api/network-sites: the six network sites (fallback list when the hub has none)', nl.map(x => x.name));
let photos = []; for (let i = 0; i < 40; i++) { photos = tgCalls.filter(c => c.method === 'sendPhoto'); if (photos.length >= 2) break; await sleep(200); }
const c1 = photos.find(c => String(c.body.caption).includes(tx.hash.toLowerCase()));
ok(photos.length === 2 && photos.every(c => c.token === 'botstandin-token' && c.body.chat_id === '-100123' && c.body.message_thread_id === 632242 && c.body.parse_mode === 'HTML' && /\/art\/proof\/vbb-proof-(pink|blue|yellow)\.png$/.test(c.body.photo)),
'one Telegram photo card per purchase (2), to the payments topic, with a proof image', photos.map(c => [c.token, c.body.chat_id, c.body.message_thread_id, c.body.photo]));
ok(photos.length === 2 && photos[0].body.photo !== photos[1].body.photo, 'the card image rotates between posts');
ok(c1 && /@buyerm bought 10 post credits · \$3\.00 \(12\.0000 POL\)/.test(c1.body.caption) && c1.body.caption.includes('Sponsor 30%: 3.6000 POL → @sponsors') && c1.body.caption.includes('Weekly prize pot 10%: 1.2000 POL')
&& c1.body.caption.includes('Viral Banner Blitz: 7.2000 POL') && /This week: \d+ purchases?, \$[\d.]+ · prize pot \$[\d.]+/.test(c1.body.caption) && c1.body.caption.includes('https://explorer.invalid/tx/' + tx.hash.toLowerCase()) && !c1.body.caption.includes('—'),
'card caption: buyer, sponsor + prize + company split in POL, this week\'s stats, verify link', c1 && c1.body.caption);
await call('/api/my/paid', {}); await sleep(1500); // more watcher scans
ok(tgCalls.filter(c => c.method === 'sendPhoto').length === 2, 'rescans never post the same purchase twice');
console.log('2. weekly prize payout (last week: ' + LAST_WEEK + ')');
let ap, plan; for (let i = 0; i < 40; i++) { ap = await adm('/api/admin/prizes'); plan = (ap.weeks || []).find(w => w.week === LAST_WEEK); if (plan) break; await sleep(250); }
ok(plan && plan.status === 'prepared', 'the app prepared last week by itself', ap.weeks && ap.weeks.map(w => w.week + ':' + w.status));
@@ -152,7 +192,13 @@ async function main() {
let r = await adm('/api/admin/prizes/prepare', { week: LAST_WEEK }); ok(r.status === 'paid', 'preparing a paid week again changes nothing', r.status);
const pub = await call('/api/prizes'); const lw = (pub.past || [])[0];
ok(lw && lw.week === LAST_WEEK && lw.winners.length === 6 && lw.winners.every(x => x.tx && x.confirmed && x.pol) && pub.explorer === 'https://explorer.invalid' && !JSON.stringify(pub).includes(P.privateKey.slice(2, 12)), 'public /api/prizes lists the winners with their transactions (never the key)', lw);
let lines = []; for (let i = 0; i < 40; i++) { lines = tgCalls.filter(c => c.method === 'sendMessage' && /weekly prize/.test(c.body.text)); if (lines.length >= 6) break; await sleep(200); }
ok(lines.length === 6 && lines.every(c => c.body.message_thread_id === 632242 && /POL \(\$\d+\.\d\d\)/.test(c.body.text) && /explorer\.invalid\/tx\/0x[0-9a-f]{64}/.test(c.body.text))
&& new Set(lines.map(c => c.body.text.match(/tx\/(0x[0-9a-f]{64})/)[1])).size === 6, 'one Telegram line per confirmed prize payout (6), each with its own transaction', lines.map(c => c.body.text.split('\n')[1]));
ok(lines.some(c => c.body.text.includes('@winner1 · 1st place, most verified visitors') && c.body.text.includes('20.0000 POL ($5.00)')), 'prize line names the winner, place, board and amount', lines.map(c => c.body.text.split('\n')[1]));
const led2 = await call('/api/ledger?n=50'); ok((led2.items || []).filter(x => x.kind === 'prize' && x.confirmed).length === 6 && led2.totals.prizePayouts === 6, 'the ledger lists the 6 prize payouts with their transactions', led2.totals);
const st = await adm('/api/admin/status'); ok(!JSON.stringify(st).includes(P.privateKey.slice(2, 12)) && st.prize && st.prize.keyAddress === P.address.toLowerCase(), 'admin status shows the prize wallet, never its key');
ok(st.proof && st.proof.telegram === true && st.proof.posted === 2 && st.proof.prizeLines === 6 && !JSON.stringify(st).includes('standin-token'), 'admin status shows the proof posts, never the bot token', st.proof);
srv.kill(); an.kill();
console.log('\n' + pass + ' passed, ' + fail + ' failed');
+15
View File
@@ -519,6 +519,21 @@ async function main() {
ok((await pg.textContent('#kit')).includes('?ref=smokeleader') && (await pg.inputValue('#whoIn')) === 'smokeleader', name + ': Promote page shows the kit with the member links');
ok(!!(await pg.$('nav a[href="/promote"]')), name + ': nav links to Promote');
await pg.waitForTimeout(600); await pg.screenshot({ path: path.join(OUT, 'promote-' + name + '.png'), fullPage: true });
// trust pack (2026-11-14): footer legal + proof links, company line, network line; ledger + contract + legal pages render
await pg.goto(BASE + '/how', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => /Earners Corner/.test((document.querySelector('footer .netline') || {}).textContent || ''), null, { timeout: 6000 }).catch(() => {});
const ft = await pg.textContent('footer.foot'); const hrefs = await pg.$$eval('footer.foot a', as => as.map(a => a.getAttribute('href')));
ok(['/terms', '/disclaimer', '/privacy', '/contract', '/ledger'].every(h => hrefs.includes(h)) && /Support/.test(ft) && /TrustClickz · 615 Green Valley Drive, Moody, AL 35004/.test(ft)
&& /Part of the network · One account across the network: InstantAdPay · LinkSpin · Downline Banners · Viral Banner Blitz · Stack POL · Earners Corner/.test(ft.replace(/\s+/g, ' ')) && !/RM Circle|rmcircle/i.test(ft)
&& (await pg.textContent('footer .netline .here')) === 'Viral Banner Blitz', name + ': footer: legal + proof links, company line, network line with VBB as current, never RM Circle', ft.slice(-400));
const sw = await pg.evaluate(() => document.documentElement.scrollWidth); ok(sw <= pg.viewportSize().width, name + ': footer fits the screen (no sideways scroll)', sw);
await pg.locator('footer.foot').screenshot({ path: path.join(OUT, 'footer-' + name + '.png') });
for (const lp of ['/terms', '/disclaimer', '/privacy']) { await pg.goto(BASE + lp, { waitUntil: 'domcontentloaded' }); ok((await pg.textContent('main')).includes('TrustClickz') && !!(await pg.$('footer.foot')), name + ': ' + lp + ' renders with the footer'); }
await pg.goto(BASE + '/ledger', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => !/Loading/.test(document.querySelector('#rows tbody').textContent), null, { timeout: 8000 }).catch(() => {});
ok(!!(await pg.$('#totals .stat')) && !/Loading/.test(await pg.textContent('#rows')), name + ': /ledger renders its totals and rows', (await pg.textContent('#rows')).slice(0, 200));
await pg.screenshot({ path: path.join(OUT, 'ledger-' + name + '.png'), fullPage: true });
await pg.goto(BASE + '/contract', { waitUntil: 'domcontentloaded' }); await pg.waitForFunction(() => !/Reading the contract/.test(document.getElementById('facts').textContent), null, { timeout: 8000 }).catch(() => {});
ok(!/Reading the contract/.test(await pg.textContent('#facts')) && /30%/.test(await pg.textContent('main')), name + ': /contract renders', (await pg.textContent('#facts')).slice(0, 200));
await pg.screenshot({ path: path.join(OUT, 'contract-' + name + '.png'), fullPage: true });
await pg.goto(BASE + '/', { waitUntil: 'domcontentloaded' }); await pg.waitForTimeout(300);
ok(!(await pg.$('script[src*="linkspin.app/z.js"]')), name + ': no network zone on the loop page');
await ctx.close();