Network Weekend (Marty 2026-11-17): 8 instant picks per position Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, ribbon, chatbot facts

weekend.js: date gate by the purchase's chain time (WEEKEND_PICKS=0 switches it off, WEEKEND_NOW test clock); /api/config, quote,
order and the attach hook use it. Tank check 11-17: draft pool 1,339, 2 positions sold. netdeals.js + /assets/netweekend.js ribbon
(/api/network-deals from the hub), loaded by common.js (not draftday/admin), common.js?v=4. chatbot FACTS weekend line and a
chatcore finish hook so stored instant answers say 8 while live. qa/weekend.test.cjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 07:22:44 -06:00
parent 394aec44c3
commit f56fc551fe
22 changed files with 199 additions and 22 deletions
+10 -6
View File
@@ -31,6 +31,8 @@ const hubline = require('./hubline');
const hubevents = require('./hubevents'); // network hub hook (2026-11-16): sign-out-everywhere, block and erase end sessions here
const proof = require('./proof');
const netsites = require('./netsites');
const netdeals = require('./netdeals');
const weekend = require('./weekend');
const wild = require('./wild');
const PUB = path.join(__dirname, 'public');
@@ -256,7 +258,7 @@ const server = http.createServer(async (req, res) => {
// -- public API
if (p === '/api/config' && req.method === 'GET') {
return json(res, 200, { site: C.site, siteName: C.siteName, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
position: C.position, split: C.split, draft: { dow: C.draft.dow, hour: C.draft.hour, rounds: C.draft.rounds, pickSeconds: C.draft.pickSeconds }, picks: { returnDays: C.picks.returnDays, maxOpen: C.picks.maxOpen, holdHours: C.picks.holdHours },
position: Object.assign({}, C.position, { picksOnBuy: weekend.picks(C), weekend: weekend.live() }), split: C.split, draft: { dow: C.draft.dow, hour: C.draft.hour, rounds: C.draft.rounds, pickSeconds: C.draft.pickSeconds }, picks: { returnDays: C.picks.returnDays, maxOpen: C.picks.maxOpen, holdHours: C.picks.holdHours },
pot: C.pot, sso: networksso.enabled(), shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, tank: C.tankMode, testMode: tank.preview(), joinUrl: joinUrl('') });
}
if (p === '/api/board' && req.method === 'GET') { const s = session(req); return json(res, 200, await board(s ? s.address : null)); }
@@ -275,6 +277,7 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/ledger' && req.method === 'GET') return json(res, 200, proof.ledger(u.searchParams.get('n')), { 'Cache-Control': 'public, max-age=10' });
if (p === '/api/contract' && req.method === 'GET') { if (limited(req, 'contract', 600, 3600000)) return json(res, 429, { error: 'Too many requests' }); return json(res, 200, await proof.contract(), { 'Cache-Control': 'public, max-age=60' }); }
if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res);
if (p === '/api/network-deals' && req.method === 'GET') return netdeals.handle(req, res, 'fivex'); // Network Weekend ribbon (2026-11-17)
// toasts: real events of the last 30 minutes (new coaches, picks, picks that levelled up)
if (p === '/api/recent' && req.method === 'GET') {
const t = now(); const cut = t - 30 * 60000;
@@ -288,7 +291,7 @@ const server = http.createServer(async (req, res) => {
if (limited(req, 'quote', 600, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
const qty = Number(u.searchParams.get('qty') || 1);
if (!Number.isInteger(qty) || qty < 1 || qty > C.position.maxQty) return json(res, 400, { error: 'Pick 1 to ' + C.position.maxQty + ' positions.' });
try { return json(res, 200, Object.assign({ usd: C.position.usd * qty, picks: C.position.picksOnBuy * qty }, await shop.quote(qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
try { return json(res, 200, Object.assign({ usd: C.position.usd * qty, picks: weekend.picks(C) * qty }, await shop.quote(qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/gas' && req.method === 'GET') { try { return json(res, 200, shop.watching() ? await shop.fees() : {}); } catch (e) { return json(res, 200, {}); } }
if (/^\/api\/tx\/0x[0-9a-fA-F]{64}$/.test(p) && req.method === 'GET') {
@@ -360,7 +363,7 @@ const server = http.createServer(async (req, res) => {
}
if (p === '/api/my/instant' && req.method === 'POST') {
const b = await readBody(req); if (!HUBID_RE.test(String(b.person || ''))) return json(res, 400, { error: 'Pick a player.' });
if (!isCoach(me)) return json(res, 403, { error: 'Get a position first: it comes with ' + C.position.picksOnBuy + ' picks right away.' });
if (!isCoach(me)) return json(res, 403, { error: 'Get a position first: it comes with ' + weekend.picks(C) + ' picks right away.' });
return json(res, 200, await league.instantPick(me, String(b.person)));
}
if (p === '/api/my/queue' && req.method === 'POST') {
@@ -410,7 +413,7 @@ const server = http.createServer(async (req, res) => {
if (!wallets.length) why = 'no-line'; else v = await shop.voucher(me, wallets);
}
const hubRef = m.hubId ? BigInt('0x' + crypto.createHash('sha256').update(m.hubId).digest('hex').slice(0, 15)) : 0n; // ref = a short hash of the hub id (free data)
try { return json(res, 200, Object.assign({ buyer: me, usd: C.position.usd * qty, picks: C.position.picksOnBuy * qty, qty, why }, await shop.order(me, qty, hubRef, v))); }
try { return json(res, 200, Object.assign({ buyer: me, usd: C.position.usd * qty, picks: weekend.picks(C) * qty, qty, why }, await shop.order(me, qty, hubRef, v))); }
catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/my/paid' && req.method === 'POST') { shop.nudge(); return json(res, 200, { ok: true, confirmations: C.shopConfirmations }); }
@@ -422,7 +425,7 @@ const server = http.createServer(async (req, res) => {
if (!isAdmin(req)) return json(res, 401, { error: 'no' });
if (p === '/api/admin/status' && req.method === 'GET') {
const t = now(); const w = league.weekInfo(t); const d = store.draft(w.week);
return json(res, 200, { day: store.ctDay(t), week: w.week, now: t, draftAt: w.draftAt, config: { position: C.position, split: C.split, draft: C.draft, picks: C.picks, pot: C.pot, tankMode: C.tankMode },
return json(res, 200, { day: store.ctDay(t), week: w.week, now: t, draftAt: w.draftAt, config: { position: Object.assign({}, C.position, { picksOnBuy: weekend.picks(C), weekend: weekend.live() }), split: C.split, draft: C.draft, picks: C.picks, pot: C.pot, tankMode: C.tankMode },
members: store.members().length, coaches: store.coaches().length, picks: { all: store.picks().length, open: store.picks().filter(x => x.status === 'open').length, done: store.picks().filter(x => x.status === 'done').length, returned: store.picks().filter(x => x.status === 'returned').length, kept: store.picks().filter(x => x.status === 'kept').length },
draft: d ? { status: d.status, made: d.made.length, slots: d.slots.length, why: d.why || null } : null, pot: { weekWei: proof.potOf(w.from, w.to), best: draft.bestCoach(store.picks(), w.from, w.to, display).slice(0, 5) },
shop: shop.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), tank: tank.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length, testClock: C.testClock });
@@ -474,7 +477,8 @@ const server = http.createServer(async (req, res) => {
proof.init(C, { shop, weekStats, nameOf: async a => { const h = await hubpeople.byWallet(a).catch(() => ({ ok: false })); return h.ok && h.person && h.person.username ? h.person.username : null; } });
league.init(C, { proof });
hubreport.init({ dataDir: C.dataDir, purchases: () => store.purchases().map(x => ({ key: x.key, buyer: x.buyer, sponsor: x.sponsor || null, usdCents: x.usdCents, block: x.block, at: x.at })) });
shop.setAttach(rec => { store.addCredits(rec.buyer, C.position.picksOnBuy * (Number(rec.qty) || 1)); store.bump('positions', Number(rec.qty) || 1); });
shop.setAttach(rec => { store.addCredits(rec.buyer, weekend.picks(C, Number(rec.blockAt) ? Number(rec.blockAt) * 1000 : (Number(rec.at) || undefined)) * (Number(rec.qty) || 1)); store.bump('positions', Number(rec.qty) || 1); }); // Network Weekend: the purchase's chain time decides the picks
netdeals.setLocal(d => (weekend.weekendPicks() > 0 ? d : null)); // WEEKEND_PICKS=0: no 5x line on the ribbon
shop.setHook(proof.onPurchase);
shop.init(C);
const loop = () => league.tick().catch(e => console.error('league tick', e.message)).finally(() => setTimeout(loop, C.draft.tickMs).unref());