Banner Line web app v1: gate, board, buy, My Spots, dashboard, chain index, keeper, local smoke test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
data
|
||||
qa/out
|
||||
.git
|
||||
.env
|
||||
@@ -0,0 +1,14 @@
|
||||
# Banner Line app env (Coolify). Never commit real values.
|
||||
CONTRACT_ADDRESS= # default on 137: 0x6c77fc0664f58cf17e81966160fc80005a110f9b (mainnet). Required for 80002/31337
|
||||
CHAIN_ID=137 # 137 Polygon mainnet (default), 80002 Amoy, 31337 local anvil
|
||||
RPC_URLS= # comma list; default = public nodes for CHAIN_ID
|
||||
START_BLOCK= # index start block; default on 137: 97245075 (DEPLOY_BLOCK also accepted)
|
||||
CONFIRMATIONS= # default 3 (0 on anvil)
|
||||
PRICE_FEED= # only if the contract has no quoteWei() (it does)
|
||||
WALLETCONNECT_PROJECT_ID= # Reown project id (same as InstantAdPay)
|
||||
SITE_HOST=downlinebanners.com
|
||||
SESSION_SECRET= # random hex; default = generated into DATA_DIR/.secret
|
||||
ADMIN_TOKEN= # x-admin-token for /api/admin/status
|
||||
IAP_RESOLVE_URL= # optional: ?ref=<username> lookup, URL + username -> {"address":"0x.."}
|
||||
KEEPER_ENABLED=0 # 1 to run fund buys
|
||||
KEEPER_KEY= # keeper wallet private key (only read at signing time)
|
||||
@@ -0,0 +1,5 @@
|
||||
node_modules/
|
||||
data/
|
||||
*.log
|
||||
qa/out/
|
||||
.env
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev --no-audit --no-fund
|
||||
COPY . .
|
||||
RUN mkdir -p /app/data
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
CMD ["node","server.js"]
|
||||
@@ -0,0 +1,43 @@
|
||||
// Banner Line contract ABI: the ONE place the app learns the contract's shape.
|
||||
// Primary: contract-abi.json = the compiled abi copied from ../contracts/out/BannerLine.sol/BannerLine.json
|
||||
// (refresh it with `node qa/sync-abi.js` after a contract rebuild). Fallback: the SPEC.md shape below.
|
||||
// Nothing else in the app hard-codes a selector or a topic.
|
||||
// Reads are tried and skipped if missing (price falls back to the Chainlink feed math, same formula as InstantAdPay).
|
||||
const { Interface } = require('ethers');
|
||||
|
||||
const SPEC_ABI = [
|
||||
// writes
|
||||
'function buy(address sponsor) payable',
|
||||
'function buyFor(address owner, address sponsor) payable',
|
||||
'function fundBuy(address giftee)',
|
||||
// reads (OPTIONAL, any missing one is skipped)
|
||||
'function quoteWei() view returns (uint256)',
|
||||
'function requiredWei() view returns (uint256)',
|
||||
'function priceFeed() view returns (address)',
|
||||
'function fundBalance() view returns (uint256)',
|
||||
'function lastGiftAt(address) view returns (uint256)',
|
||||
'function paidSpots(address) view returns (uint256)',
|
||||
'function spotCount() view returns (uint256)',
|
||||
'function keeper() view returns (address)',
|
||||
'function paused() view returns (bool)',
|
||||
// events (names and argument order exactly as SPEC.md)
|
||||
'event SpotBought(uint256 id, address owner, address payer, address sponsor, uint8 kind, uint256 valueWei, uint256 usdPrice)',
|
||||
'event Paid(uint256 indexed spotId, address indexed to, uint256 amount, uint8 role)',
|
||||
'event FundBuy(uint256 spotId, address giftee)',
|
||||
'event MemberJoined(address member, address sponsor)',
|
||||
'event PaymentFailed(uint256 indexed spotId, address indexed to, uint256 amount, uint8 role)'
|
||||
];
|
||||
let ABI = SPEC_ABI, ABI_SOURCE = 'spec';
|
||||
try { const j = require('./contract-abi.json'); if (Array.isArray(j) && j.length) { ABI = j; ABI_SOURCE = 'compiled'; } } catch (e) {}
|
||||
|
||||
// Chainlink AggregatorV3 (POL/USD, 8 decimals), used only when the contract has no quote view
|
||||
const FEED_ABI = ['function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)'];
|
||||
|
||||
const PRICE_CENTS = 500; // $5 a spot (SPEC.md Money)
|
||||
const KINDS = { 0: 'paid', 1: 'bought for', 2: 'fund gift', 3: 'fund kept' };
|
||||
const ROLES = { 0: 'sponsor', 1: 'line', 2: 'company A', 3: 'company B', 4: 'fund' };
|
||||
|
||||
const iface = new Interface(ABI);
|
||||
const feedIface = new Interface(FEED_ABI);
|
||||
|
||||
module.exports = { ABI, ABI_SOURCE, FEED_ABI, iface, feedIface, PRICE_CENTS, KINDS, ROLES };
|
||||
@@ -0,0 +1,81 @@
|
||||
// Board rotation, creatives, and the frame check for gate visits.
|
||||
// A spot is owed cfg.viewsOwed views (300) inside cfg.spotDays (30) from purchase. Newest spots sit on top;
|
||||
// the 3 newest are always shown, the rest of the slots go to the spots furthest behind on delivery
|
||||
// (views still owed per hour left), and any empty slot is filled with member Banner Spins, then house ads.
|
||||
const cfgMod = require('./config');
|
||||
const chain = require('./chain');
|
||||
const store = require('./store');
|
||||
|
||||
const DAY = 86400000;
|
||||
|
||||
function creative(spot) {
|
||||
const m = store.spotMeta(spot.id);
|
||||
if (m && m.img && m.link) return { img: m.img, link: m.link, from: 'spot' };
|
||||
const d = store.memberDefault(spot.owner);
|
||||
if (d && d.img && d.link) return { img: d.img, link: (m && m.link) || d.link, from: 'default' };
|
||||
if ((m && m.link) || (d && d.link)) return { img: (m && m.img) || (d && d.img) || houseFor(spot.id).img, link: (m && m.link) || d.link, from: 'link-only' };
|
||||
const h = houseFor(spot.id); return { img: h.img, link: h.link, from: 'house' };
|
||||
}
|
||||
function houseFor(n) { const h = cfgMod.house(); return h[Math.abs(Number(n) || 0) % h.length]; }
|
||||
|
||||
function eligible(now) {
|
||||
const c = cfgMod.get(); now = now || Date.now();
|
||||
return chain.spots().filter(s => s.kind !== 3 && now - s.boughtAt < c.spotDays * DAY && store.views(s.id).total < c.viewsOwed);
|
||||
}
|
||||
|
||||
// Hook: member LinkSpin Banner Spins fill empty slots before house ads (SPEC "house fill"). Returns
|
||||
// [{ img, link, title }]. Not wired in v1: needs a LinkSpin endpoint listing members' active 468x60 spins.
|
||||
function memberSpins() { return []; }
|
||||
|
||||
function spotTile(s) {
|
||||
const c = cfgMod.get(); const cr = creative(s); const v = store.views(s.id);
|
||||
return { t: 'spot', id: s.id, owner: s.owner, img: cr.img, href: '/go/' + s.id, views: v.total, owed: c.viewsOwed, kind: s.kind };
|
||||
}
|
||||
function pick(n) {
|
||||
n = n || cfgMod.get().boardSlots; const now = Date.now(); const c = cfgMod.get();
|
||||
const el = eligible(now); // newest first
|
||||
const chosen = el.slice(0, Math.min(3, n));
|
||||
const rest = el.slice(chosen.length).map(s => {
|
||||
const left = Math.max(1, c.spotDays * DAY - (now - s.boughtAt)) / 3600000;
|
||||
return { s, u: (c.viewsOwed - store.views(s.id).total) / left + Math.random() * 1e-6 };
|
||||
}).sort((a, b) => b.u - a.u).slice(0, n - chosen.length).map(x => x.s);
|
||||
const tiles = chosen.concat(rest).sort((a, b) => b.id - a.id).map(spotTile);
|
||||
for (const sp of memberSpins()) { if (tiles.length >= n) break; tiles.push({ t: 'spin', img: sp.img, href: sp.link, title: sp.title }); }
|
||||
const house = cfgMod.house(); let i = Math.floor(Math.random() * house.length);
|
||||
const stop = Math.min(n, tiles.length + house.length); // each house entry at most once per board
|
||||
while (tiles.length < stop) { const h = house[i++ % house.length]; tiles.push({ t: 'house', key: h.key, img: h.img, href: '/go/h-' + h.key, title: h.title, note: h.note || '' }); }
|
||||
return tiles;
|
||||
}
|
||||
|
||||
// newest spot of an address (gate step 1), any kind except fund-kept
|
||||
function newestOf(addr) { const a = String(addr || '').toLowerCase(); return chain.spots().find(s => s.owner === a && s.kind !== 3) || null; }
|
||||
function newest(k, exclude) { const ex = new Set(exclude || []); return chain.spots().filter(s => s.kind !== 3 && !ex.has(s.id)).slice(0, k); }
|
||||
|
||||
// ---- frame check (IAP login-gate pattern): a site that refuses framing opens in a new tab instead ----
|
||||
const frameCache = new Map();
|
||||
async function frameable(url) {
|
||||
if (!/^https:\/\//i.test(url || '')) return url && url.startsWith('/');
|
||||
const hit = frameCache.get(url); if (hit && Date.now() - hit.at < 6 * 3600000) return hit.ok;
|
||||
let ok = false;
|
||||
try {
|
||||
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 4000);
|
||||
const r = await fetch(url, { method: 'GET', redirect: 'follow', signal: ac.signal, headers: { 'User-Agent': 'Mozilla/5.0 (compatible; BannerLineFrameCheck/1.0)' } });
|
||||
clearTimeout(t);
|
||||
const xfo = String(r.headers.get('x-frame-options') || '').toLowerCase();
|
||||
const csp = String(r.headers.get('content-security-policy') || '').toLowerCase();
|
||||
const fa = /frame-ancestors([^;]*)/.exec(csp);
|
||||
ok = !xfo && !(fa && !/\*|https:/.test(fa[1]));
|
||||
try { r.body && r.body.cancel && r.body.cancel(); } catch (e) {}
|
||||
} catch (e) { ok = false; }
|
||||
frameCache.set(url, { at: Date.now(), ok });
|
||||
if (frameCache.size > 5000) frameCache.clear();
|
||||
return ok;
|
||||
}
|
||||
|
||||
function target(ref) {
|
||||
if (/^h-/.test(ref)) { const h = cfgMod.house().find(x => 'h-' + x.key === ref); return h ? { link: h.link, spotId: null } : null; }
|
||||
const s = chain.spot(Number(ref)); if (!s || s.kind === 3) return null;
|
||||
return { link: creative(s).link, spotId: s.id };
|
||||
}
|
||||
|
||||
module.exports = { creative, eligible, pick, newestOf, newest, frameable, target, memberSpins, houseFor };
|
||||
@@ -0,0 +1,221 @@
|
||||
// On-chain reader + indexer for the Banner Line contract (pattern from InstantAdPay site/chain.js):
|
||||
// RPC pool with rotation + circuit breaker, a resumable eth_getLogs tail persisted in DATA_DIR, and the
|
||||
// price quote. Encoding/decoding goes through abi.js only, so the compiled ABI can drop in later.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const { EventFragment, Interface } = require('ethers');
|
||||
const { iface, feedIface, PRICE_CENTS } = require('./abi');
|
||||
const cfgMod = require('./config');
|
||||
|
||||
const CHUNK = 5000;
|
||||
let state = null, busy = false, onEvent = null, timer = null;
|
||||
const stateFile = () => path.join(cfgMod.get().dataDir, 'chain-index.json');
|
||||
|
||||
// ---- JSON-RPC with fallback rotation (http for a local anvil, https for public nodes) ----
|
||||
let rpcIdx = 0;
|
||||
const RPC_BENCH_MS = 10 * 60 * 1000; const rpcBenched = new Map();
|
||||
const benchable = e => /timeout|timed out|abort|ECONN|EAI_AGAIN|ENOTFOUND|EPIPE|socket|hang up|429|too many|rate.?limit|temporar|internal error|service unavailable|50[234]/i.test(String(e && e.message || e));
|
||||
function rpcOnce(url, method, params, timeoutMs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const body = JSON.stringify({ jsonrpc: '2.0', id: 1, method, params });
|
||||
const u = new URL(url); const mod = u.protocol === 'http:' ? http : https;
|
||||
const req = mod.request({ hostname: u.hostname, port: u.port || undefined, path: u.pathname + u.search, method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: timeoutMs || 15000 },
|
||||
res => { let d = ''; res.on('data', c => d += c); res.on('end', () => {
|
||||
try { const j = JSON.parse(d); if (j.error) { const er = new Error(j.error.message || 'rpc error'); er.data = j.error.data; reject(er); } else resolve(j.result); }
|
||||
catch (e) { reject(e); } }); });
|
||||
req.on('error', reject); req.on('timeout', () => req.destroy(new Error('rpc timeout')));
|
||||
req.end(body);
|
||||
});
|
||||
}
|
||||
async function rpc(method, params, timeoutMs) {
|
||||
const urls = cfgMod.get().rpcs; let last;
|
||||
for (let round = 0; round < 2; round++) {
|
||||
const now = Date.now(); const order = [], benched = [];
|
||||
for (let i = 0; i < urls.length; i++) { const url = urls[(rpcIdx + i) % urls.length]; ((rpcBenched.get(url) || 0) > now ? benched : order).push(url); }
|
||||
order.push(...benched);
|
||||
for (const url of order) {
|
||||
try { const r = await rpcOnce(url, method, params, timeoutMs); rpcIdx = urls.indexOf(url); rpcBenched.delete(url); return r; }
|
||||
catch (e) { last = e; if (/execution reverted|revert/i.test(String(e.message))) throw e; if (benchable(e)) rpcBenched.set(url, Date.now() + RPC_BENCH_MS); console.warn('rpc', method, 'failed on', url.replace(/\/\/([^/]+).*/, '//$1'), '->', String(e && e.message || e).slice(0, 80)); }
|
||||
}
|
||||
if (round < 1) await new Promise(r => setTimeout(r, 400));
|
||||
}
|
||||
throw last || new Error('all RPCs failed');
|
||||
}
|
||||
async function bestTip() {
|
||||
const urls = cfgMod.get().rpcs; let best = { block: -1, url: urls[0] };
|
||||
await Promise.all(urls.map(async u => { try { const b = parseInt(await rpcOnce(u, 'eth_blockNumber', [], 8000), 16); if (b > best.block) best = { block: b, url: u }; } catch (e) {} }));
|
||||
if (best.block < 0) throw new Error('no RPC answered eth_blockNumber');
|
||||
return best;
|
||||
}
|
||||
|
||||
// ---- reads ----
|
||||
async function read(fn, args, to) {
|
||||
const data = (to ? feedIface : iface).encodeFunctionData(fn, args || []);
|
||||
const r = await rpc('eth_call', [{ to: to || cfgMod.get().contract, data }, 'latest'], 5000);
|
||||
if (!r || r === '0x') throw new Error('no such function ' + fn);
|
||||
return (to ? feedIface : iface).decodeFunctionResult(fn, r);
|
||||
}
|
||||
async function tryRead(fn, args) { try { return (await read(fn, args))[0]; } catch (e) { return null; } }
|
||||
|
||||
// Required POL for one $5 spot. Order: contract quote view, else Chainlink feed math (wei = cents * 1e24 / answer,
|
||||
// the InstantAdPay formula). Cached 20 s. Returns { wei, sendWei, source } or throws.
|
||||
let quoteCache = null;
|
||||
async function quote() {
|
||||
if (quoteCache && Date.now() - quoteCache.at < 20000) return quoteCache.v;
|
||||
const c = cfgMod.get(); let wei = null, source = '';
|
||||
for (const fn of ['quoteWei', 'requiredWei']) { const v = await tryRead(fn); if (v && v > 0n) { wei = v; source = 'contract.' + fn; break; } }
|
||||
if (!wei) {
|
||||
let feed = c.priceFeed || await tryRead('priceFeed');
|
||||
if (!feed) throw new Error('No price available (contract has no quote view and PRICE_FEED is not set)');
|
||||
const r = await read('latestRoundData', [], feed);
|
||||
const ans = BigInt(r[1]); const upd = Number(r[3]);
|
||||
if (ans <= 0n) throw new Error('Price feed answer is not positive');
|
||||
if (Math.floor(Date.now() / 1000) - upd > 3600 && !c.allowStaleFeed) throw new Error('Price feed is stale (older than 1 hour); buys pause until it updates');
|
||||
wei = (BigInt(PRICE_CENTS) * 10n ** 24n) / ans; source = 'feed';
|
||||
}
|
||||
// the contract accepts [required, required * 1.02] and refunds the excess: send +1% for price drift
|
||||
const v = { wei: wei.toString(), sendWei: (wei + wei / 100n).toString(), source };
|
||||
quoteCache = { at: Date.now(), v };
|
||||
return v;
|
||||
}
|
||||
|
||||
// ---- event decode (tolerant of indexed-flag differences between the spec ABI and the compiled one) ----
|
||||
const altCache = new Map();
|
||||
function decodeLog(log) {
|
||||
let parsed = null;
|
||||
try { parsed = iface.parseLog(log); } catch (e) {}
|
||||
if (!parsed) {
|
||||
let ev; try { ev = iface.getEvent(log.topics[0]); } catch (e) { return null; }
|
||||
if (!ev) return null;
|
||||
const k = log.topics.length - 1, key = ev.name + ':' + k;
|
||||
if (!altCache.has(key)) {
|
||||
const sig = 'event ' + ev.name + '(' + ev.inputs.map((p, i) => p.type + (i < k ? ' indexed ' : ' ') + p.name).join(', ') + ')';
|
||||
altCache.set(key, new Interface([EventFragment.from(sig)]));
|
||||
}
|
||||
try { parsed = altCache.get(key).parseLog(log); } catch (e) { return null; }
|
||||
}
|
||||
if (!parsed) return null;
|
||||
const a = parsed.args, lc = x => String(x).toLowerCase();
|
||||
const base = { type: parsed.name, block: parseInt(log.blockNumber, 16), tx: log.transactionHash, li: parseInt(log.logIndex, 16) };
|
||||
switch (parsed.name) {
|
||||
case 'SpotBought': return Object.assign(base, { id: Number(a[0]), owner: lc(a[1]), payer: lc(a[2]), sponsor: lc(a[3]), kind: Number(a[4]), valueWei: a[5].toString(), usdPrice: a[6].toString() });
|
||||
case 'Paid': return Object.assign(base, { spotId: Number(a[0]), to: lc(a[1]), amount: a[2].toString(), role: Number(a[3]) });
|
||||
case 'FundBuy': return Object.assign(base, { spotId: Number(a[0]), giftee: lc(a[1]) });
|
||||
case 'MemberJoined': return Object.assign(base, { member: lc(a[0]), sponsor: lc(a[1]) });
|
||||
case 'PaymentFailed': return Object.assign(base, { spotId: Number(a[0]), to: lc(a[1]), amount: a[2].toString(), role: Number(a[3]) });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---- derived index ----
|
||||
const ZERO = '0x0000000000000000000000000000000000000000';
|
||||
function blank(c) { return { v: 1, key: c.chainId + ':' + String(c.contract).toLowerCase(), lastBlock: c.deployBlock - 1, events: [], blockTs: {} }; }
|
||||
function derive() {
|
||||
const d = { spots: new Map(), members: new Map(), wallets: new Map(), fundBuys: [], totals: { spots: 0, paidInWei: 0n, paidOutWei: 0n, members: 0, fundBuys: 0 } };
|
||||
for (const ev of state.events) apply(d, ev);
|
||||
state.d = d;
|
||||
}
|
||||
function wallet(d, a) { let w = d.wallets.get(a); if (!w) { w = { inWei: 0n, outWei: 0n, byRole: {}, payouts: 0 }; d.wallets.set(a, w); } return w; }
|
||||
function apply(d, ev) {
|
||||
const ts = state.blockTs[ev.block] ? state.blockTs[ev.block] * 1000 : (ev.ts || Date.now());
|
||||
if (ev.type === 'SpotBought') {
|
||||
d.spots.set(ev.id, { id: ev.id, owner: ev.owner, payer: ev.payer, sponsor: ev.sponsor, kind: ev.kind, valueWei: ev.valueWei, usdPrice: ev.usdPrice, boughtAt: ts, block: ev.block, tx: ev.tx });
|
||||
d.totals.spots += 1;
|
||||
if (ev.kind === 0 || ev.kind === 1) { d.totals.paidInWei += BigInt(ev.valueWei); wallet(d, ev.payer).inWei += BigInt(ev.valueWei); }
|
||||
} else if (ev.type === 'Paid') {
|
||||
const w = wallet(d, ev.to); w.outWei += BigInt(ev.amount); w.payouts += 1; w.byRole[ev.role] = (BigInt(w.byRole[ev.role] || 0) + BigInt(ev.amount)).toString();
|
||||
if (ev.role !== 4 && ev.to !== String(cfgMod.get().contract).toLowerCase()) d.totals.paidOutWei += BigInt(ev.amount); // to == contract: credited to the fund
|
||||
} else if (ev.type === 'PaymentFailed') {
|
||||
wallet(d, ev.to).failed = (wallet(d, ev.to).failed || 0) + 1; // the amount went to the fund instead
|
||||
} else if (ev.type === 'FundBuy') {
|
||||
d.fundBuys.push({ spotId: ev.spotId, giftee: ev.giftee, at: ts, tx: ev.tx }); d.totals.fundBuys += 1;
|
||||
} else if (ev.type === 'MemberJoined') {
|
||||
if (!d.members.has(ev.member)) { d.members.set(ev.member, { address: ev.member, sponsor: ev.sponsor === ZERO ? null : ev.sponsor, joinedAt: ts }); d.totals.members += 1; }
|
||||
}
|
||||
}
|
||||
function loadState() {
|
||||
const c = cfgMod.get();
|
||||
try { state = JSON.parse(fs.readFileSync(stateFile(), 'utf8')); } catch (e) { state = null; }
|
||||
if (!state || state.v !== 1 || state.key !== c.chainId + ':' + String(c.contract).toLowerCase()) state = blank(c);
|
||||
state.blockTs = state.blockTs || {};
|
||||
derive();
|
||||
}
|
||||
function saveState() {
|
||||
try { const { d, ...out } = state; const tmp = stateFile() + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(out)); fs.renameSync(tmp, stateFile()); }
|
||||
catch (e) { console.error('chain state save failed', e.message); }
|
||||
}
|
||||
async function blockTime(n) {
|
||||
if (state.blockTs[n]) return state.blockTs[n];
|
||||
const b = await rpc('eth_getBlockByNumber', ['0x' + n.toString(16), false]);
|
||||
const t = b ? parseInt(b.timestamp, 16) : Math.floor(Date.now() / 1000);
|
||||
state.blockTs[n] = t; return t;
|
||||
}
|
||||
async function tail() {
|
||||
const c = cfgMod.get();
|
||||
if (busy || !c.contract) return; busy = true;
|
||||
try {
|
||||
const tip = await bestTip();
|
||||
const latest = tip.block - c.confirmations;
|
||||
let changed = false;
|
||||
while (state.lastBlock < latest) {
|
||||
const from = state.lastBlock + 1, to = Math.min(from + CHUNK - 1, latest);
|
||||
const q = [{ address: c.contract, fromBlock: '0x' + from.toString(16), toBlock: '0x' + to.toString(16) }];
|
||||
let logs; try { logs = await rpcOnce(tip.url, 'eth_getLogs', q); } catch (e) { logs = await rpc('eth_getLogs', q); }
|
||||
logs.sort((x, y) => parseInt(x.blockNumber, 16) - parseInt(y.blockNumber, 16) || parseInt(x.logIndex, 16) - parseInt(y.logIndex, 16));
|
||||
for (const lg of logs) {
|
||||
const ev = decodeLog(lg); if (!ev) continue;
|
||||
if (state.events.some(e => e.tx === ev.tx && e.li === ev.li)) continue;
|
||||
await blockTime(ev.block); ev.ts = state.blockTs[ev.block] * 1000;
|
||||
state.events.push(ev); apply(state.d, ev); changed = true;
|
||||
if (onEvent) { try { onEvent(ev); } catch (e) { console.error('chain onEvent', e.message); } }
|
||||
}
|
||||
state.lastBlock = to; changed = true;
|
||||
}
|
||||
if (changed) saveState();
|
||||
state.lastOk = Date.now();
|
||||
} catch (e) { state.lastErr = e.message; console.error('chain tail', e.message); }
|
||||
busy = false;
|
||||
}
|
||||
|
||||
// ---- getters ----
|
||||
const d = () => state.d;
|
||||
function spots() { return [...d().spots.values()].sort((a, b) => b.id - a.id); }
|
||||
function spot(id) { return d().spots.get(Number(id)) || null; }
|
||||
function spotsOf(addr) { const a = String(addr).toLowerCase(); return spots().filter(s => s.owner === a); }
|
||||
function member(addr) { return d().members.get(String(addr).toLowerCase()) || null; }
|
||||
function isMember(addr) { const a = String(addr || '').toLowerCase(); if (a === String(cfgMod.get().contract).toLowerCase()) return false; return d().members.has(a) || spots().some(s => s.owner === a && s.kind !== 3); }
|
||||
function directs(addr) { const a = String(addr).toLowerCase(); return [...d().members.values()].filter(m => m.sponsor === a); }
|
||||
function walletTotals(addr) { const w = d().wallets.get(String(addr).toLowerCase()); return w ? { inWei: w.inWei.toString(), outWei: w.outWei.toString(), byRole: w.byRole, payouts: w.payouts } : { inWei: '0', outWei: '0', byRole: {}, payouts: 0 }; }
|
||||
function paidOf(addr) { const a = String(addr).toLowerCase(); return state.events.filter(e => e.type === 'Paid' && e.to === a).slice(-200).reverse(); }
|
||||
function fundBuys() { return d().fundBuys.slice(); }
|
||||
function totals() { const t = d().totals; return { spots: t.spots, members: t.members, fundBuys: t.fundBuys, paidInWei: t.paidInWei.toString(), paidOutWei: t.paidOutWei.toString() }; }
|
||||
function status() { return { lastBlock: state.lastBlock, events: state.events.length, lastOk: state.lastOk || null, lastErr: state.lastErr || null }; }
|
||||
function recent(n) { return state.events.slice(-(n || 50)).reverse(); }
|
||||
|
||||
async function receipt(hash) {
|
||||
const r = await rpc('eth_getTransactionReceipt', [hash]);
|
||||
if (!r) return { found: false };
|
||||
return { found: true, status: r.status, blockNumber: r.blockNumber };
|
||||
}
|
||||
async function suggestedFees() {
|
||||
let tip = 0n, base = 0n;
|
||||
try { tip = BigInt(await rpc('eth_maxPriorityFeePerGas', [])); } catch (e) {}
|
||||
try { const blk = await rpc('eth_getBlockByNumber', ['latest', false]); base = BigInt((blk && blk.baseFeePerGas) || '0x0'); } catch (e) {}
|
||||
const MIN_TIP = cfgMod.get().chainId === 31337 ? 1000000000n : 30000000000n; // 30 gwei clears Polygon's ~25 gwei floor
|
||||
const priority = tip > MIN_TIP ? tip : MIN_TIP;
|
||||
return { maxPriorityFeePerGas: '0x' + priority.toString(16), maxFeePerGas: '0x' + (base * 2n + priority).toString(16) };
|
||||
}
|
||||
|
||||
function init(opts) {
|
||||
if (opts && opts.onEvent) onEvent = opts.onEvent;
|
||||
loadState();
|
||||
if (!cfgMod.get().contract) { console.warn('CONTRACT_ADDRESS not set: chain index idle'); return; }
|
||||
tail();
|
||||
timer = setInterval(tail, cfgMod.get().pollMs); timer.unref && timer.unref();
|
||||
}
|
||||
|
||||
module.exports = { init, tail, rpc, read, tryRead, quote, decodeLog, receipt, suggestedFees, spots, spot, spotsOf, member, isMember,
|
||||
directs, walletTotals, paidOf, fundBuys, totals, status, recent, ZERO };
|
||||
@@ -0,0 +1,68 @@
|
||||
// All runtime config comes from env (Coolify sets these). Read once; the house-ad list can also be
|
||||
// overridden by DATA_DIR/house.json so it changes without a redeploy.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const NETS = {
|
||||
80002: { name: 'Polygon Amoy (testnet rehearsal)', explorer: 'https://amoy.polygonscan.com', rpcs: ['https://polygon-amoy-bor-rpc.publicnode.com', 'https://polygon-amoy.drpc.org'] },
|
||||
// drpc first: publicnode refuses some log/archive queries (kept as fallback, InstantAdPay-style rotation)
|
||||
137: { name: 'Polygon', explorer: 'https://polygonscan.com', rpcs: ['https://polygon.drpc.org', 'https://polygon-bor-rpc.publicnode.com', 'https://polygon-rpc.com'] },
|
||||
31337: { name: 'Local anvil', explorer: '', rpcs: ['http://127.0.0.1:8545'] }
|
||||
};
|
||||
|
||||
// Production default: the BannerLine contract on Polygon mainnet (deployed 2026-11-13, owner = Marty's Tangem,
|
||||
// keeper 0xcAF8EF6eFDFC9597780Db5a1F6b2efE525868e37). Other chains (80002 Amoy, 31337 anvil) need CONTRACT_ADDRESS set.
|
||||
const MAINNET = { contract: '0x6c77fc0664f58cf17e81966160fc80005a110f9b', deployBlock: 97245075 };
|
||||
|
||||
let cfg = null;
|
||||
function get() {
|
||||
if (cfg) return cfg;
|
||||
const e = process.env;
|
||||
const chainId = Number(e.CHAIN_ID || 137);
|
||||
const main = chainId === 137;
|
||||
const net = NETS[chainId] || NETS[137];
|
||||
const list = s => String(s || '').split(',').map(x => x.trim()).filter(Boolean);
|
||||
cfg = {
|
||||
port: Number(e.PORT || 3000),
|
||||
isProd: e.NODE_ENV === 'production',
|
||||
site: e.SITE_HOST || 'downlinebanners.com',
|
||||
dataDir: e.DATA_DIR || path.join(__dirname, 'data'),
|
||||
contract: (e.CONTRACT_ADDRESS || (main ? MAINNET.contract : '')).trim(),
|
||||
chainId,
|
||||
chainName: e.CHAIN_NAME || net.name,
|
||||
explorer: e.EXPLORER_URL !== undefined ? e.EXPLORER_URL : net.explorer,
|
||||
rpcs: list(e.RPC_URLS).length ? list(e.RPC_URLS) : net.rpcs,
|
||||
publicRpc: e.PUBLIC_RPC || (list(e.RPC_URLS)[0] || net.rpcs[0]), // handed to the wallet for add/switch chain
|
||||
deployBlock: Number(e.START_BLOCK || e.DEPLOY_BLOCK || (main && String(e.CONTRACT_ADDRESS || MAINNET.contract).trim().toLowerCase() === MAINNET.contract ? MAINNET.deployBlock : 0)),
|
||||
confirmations: Number(e.CONFIRMATIONS !== undefined ? e.CONFIRMATIONS : (chainId === 31337 ? 0 : 3)),
|
||||
pollMs: Number(e.POLL_MS || 20000),
|
||||
priceFeed: (e.PRICE_FEED || '').trim(),
|
||||
allowStaleFeed: e.ALLOW_STALE_FEED === '1',
|
||||
walletConnectProjectId: (e.WALLETCONNECT_PROJECT_ID || '').trim(),
|
||||
// board + gate
|
||||
viewsOwed: 300, spotDays: 30, boardSlots: Number(e.BOARD_SLOTS || 12),
|
||||
gateVisitSeconds: 9, gateBoardSeconds: 10,
|
||||
// keeper (fund buys). KEEPER_KEY is never stored in cfg: keeper.js reads it from env at signing time only.
|
||||
keeperEnabled: e.KEEPER_ENABLED === '1',
|
||||
keeperStallHours: Number(e.KEEPER_STALL_HOURS || 4),
|
||||
keeperMaxPerDay: Number(e.KEEPER_MAX_PER_DAY || 12),
|
||||
keeperEveryMs: Number(e.KEEPER_EVERY_MIN || 15) * 60000,
|
||||
iapResolveUrl: (e.IAP_RESOLVE_URL || '').trim() // optional: https://instantadpay.com/api/... returning {address} for ?ref=<username>
|
||||
};
|
||||
return cfg;
|
||||
}
|
||||
|
||||
// House ads fill empty board slots. Order of fill: member LinkSpin Banner Spins (hook in board.js), then these.
|
||||
// Image paths avoid ad-blocker patterns (no size tokens, no /banners/ folder).
|
||||
const HOUSE_DEFAULT = [
|
||||
{ key: 'iap', title: 'InstantAdPay', img: '/art/house-iap.svg', link: 'https://instantadpay.com/', note: 'Ad credits buy advertising, not income.' },
|
||||
{ key: 'linkspin', title: 'LinkSpin', img: '/art/house-linkspin.svg', link: 'https://linkspin.app/' },
|
||||
{ key: 'games', title: 'Network games', img: '/art/house-games.svg', link: 'https://enjoybestgames.com/' },
|
||||
{ key: 'self', title: 'Banner Line', img: '/art/house-line.svg', link: '/join' }
|
||||
];
|
||||
function house() {
|
||||
try { const h = JSON.parse(fs.readFileSync(path.join(get().dataDir, 'house.json'), 'utf8')); if (Array.isArray(h) && h.length) return h; } catch (e) {}
|
||||
return HOUSE_DEFAULT;
|
||||
}
|
||||
|
||||
module.exports = { get, house, reset: () => { cfg = null; } };
|
||||
@@ -0,0 +1,908 @@
|
||||
[
|
||||
{
|
||||
"type": "constructor",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_feeA",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "_feeB",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "_keeper",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "_priceFeed",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "BPS_DENOM",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "FEE_A_BPS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "FEE_B_BPS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "FUND_BPS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "GIFT_COOLDOWN",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "KIND_BOUGHT_FOR",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "KIND_FUND_GIFT",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "KIND_FUND_KEPT",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "KIND_PAID",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "LEVELS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "LEVEL_BPS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "MAX_ORACLE_AGE",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "PRICE_CENTS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "PRICE_GRACE",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ROLE_FEE_A",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ROLE_FEE_B",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ROLE_FUND",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ROLE_LEVEL",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ROLE_SPONSOR",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "SEND_GAS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "SPONSOR_BPS",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "buy",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "sponsor",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "buyFor",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spotOwner",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "sponsor",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "feeA",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "feeB",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "fundBalance",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "fundBuy",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "giftee",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "isMember",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "keeper",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "lastGiftAt",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "lastGoodAnswer",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "lastGoodAt",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "owner",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "paidSpots",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "pause",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "paused",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "priceFeed",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "contract IAggregatorV3"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "quoteWei",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "setKeeper",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "k",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "sponsorOf",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "spotCount",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "spots",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "kind",
|
||||
"type": "uint8",
|
||||
"internalType": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "boughtAt",
|
||||
"type": "uint64",
|
||||
"internalType": "uint64"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "spotsOwned",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "transferOwnership",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "unpause",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable"
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "FallbackPriceUsed",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "answer",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "feedUpdatedAt",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "FundBuy",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spotId",
|
||||
"type": "uint256",
|
||||
"indexed": true,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "giftee",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "KeeperChanged",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "oldKeeper",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "newKeeper",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "MemberJoined",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "member",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "sponsor",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "OwnershipTransferred",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "oldOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "Paid",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spotId",
|
||||
"type": "uint256",
|
||||
"indexed": true,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "role",
|
||||
"type": "uint8",
|
||||
"indexed": false,
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "Paused",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "paused",
|
||||
"type": "bool",
|
||||
"indexed": false,
|
||||
"internalType": "bool"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "PaymentFailed",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spotId",
|
||||
"type": "uint256",
|
||||
"indexed": true,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "role",
|
||||
"type": "uint8",
|
||||
"indexed": false,
|
||||
"internalType": "uint8"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "PriceCached",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "answer",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "feedUpdatedAt",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "SpotBought",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "uint256",
|
||||
"indexed": true,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "payer",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "sponsor",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "kind",
|
||||
"type": "uint8",
|
||||
"indexed": false,
|
||||
"internalType": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "valueWei",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "usdPrice",
|
||||
"type": "uint256",
|
||||
"indexed": false,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
services:
|
||||
bannerline:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
DATA_DIR: /app/data
|
||||
SITE_HOST: ${SITE_HOST:-downlinebanners.com}
|
||||
CONTRACT_ADDRESS: ${CONTRACT_ADDRESS:-}
|
||||
CHAIN_ID: ${CHAIN_ID:-137}
|
||||
RPC_URLS: ${RPC_URLS:-}
|
||||
START_BLOCK: ${START_BLOCK:-}
|
||||
WALLETCONNECT_PROJECT_ID: ${WALLETCONNECT_PROJECT_ID:-}
|
||||
SESSION_SECRET: ${SESSION_SECRET:-}
|
||||
ADMIN_TOKEN: ${ADMIN_TOKEN:-}
|
||||
IAP_RESOLVE_URL: ${IAP_RESOLVE_URL:-}
|
||||
KEEPER_ENABLED: ${KEEPER_ENABLED:-0}
|
||||
KEEPER_KEY: ${KEEPER_KEY:-}
|
||||
volumes:
|
||||
- bannerline-data:/app/data
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
bannerline-data:
|
||||
@@ -0,0 +1,96 @@
|
||||
// Keeper engine: momentum-fund buys (SPEC "Momentum fund"). OFF unless KEEPER_ENABLED=1 and KEEPER_KEY is set.
|
||||
// Every 15 min: if no spot has SOLD (kind 0 paid / 1 bought-for) for 4 h and fewer than 12 fund buys happened
|
||||
// today (US Central), call fundBuy(giftee). Giftee = an active member (signed in or bought within 7 days) who owns
|
||||
// a paid spot and had no gift in 7 days; builders (sponsored someone in the last 30 days) first, then the longest
|
||||
// wait; nobody eligible -> address(0) (the fund keeps the spot). The contract enforces the money + 7-day rules.
|
||||
// KEEPER_KEY is read from env only at signing time and is never logged, stored or returned.
|
||||
const { Wallet, JsonRpcProvider } = require('ethers');
|
||||
const cfgMod = require('./config');
|
||||
const chain = require('./chain');
|
||||
const store = require('./store');
|
||||
const { iface } = require('./abi');
|
||||
|
||||
const DAY = 86400000;
|
||||
let running = false, timer = null, lastDecision = null;
|
||||
|
||||
function centralDay(ms) { return new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date(ms)); }
|
||||
|
||||
function lastGiftMap() { const m = new Map(); for (const f of chain.fundBuys()) if (f.giftee !== chain.ZERO) m.set(f.giftee, Math.max(m.get(f.giftee) || 0, f.at)); return m; }
|
||||
|
||||
function candidates(now) {
|
||||
now = now || Date.now();
|
||||
const spots = chain.spots(); const gifts = lastGiftMap();
|
||||
const owners = new Map();
|
||||
for (const s of spots) { if (!owners.has(s.owner)) owners.set(s.owner, []); owners.get(s.owner).push(s); }
|
||||
const out = [];
|
||||
for (const [addr, list] of owners) {
|
||||
if (addr === chain.ZERO || addr === String(cfgMod.get().contract).toLowerCase()) continue;
|
||||
const paid = list.filter(s => s.kind === 0);
|
||||
if (!paid.length) continue;
|
||||
const boughtRecently = list.some(s => (s.kind === 0 || s.kind === 1) && now - s.boughtAt < 7 * DAY);
|
||||
const seenRecently = now - store.lastSeen(addr) < 7 * DAY;
|
||||
if (!boughtRecently && !seenRecently) continue;
|
||||
const lastGift = gifts.get(addr) || 0;
|
||||
if (lastGift && now - lastGift < 7 * DAY) continue;
|
||||
const builder = chain.directs(addr).some(m => now - m.joinedAt < 30 * DAY);
|
||||
const waitingSince = lastGift || Math.min(...paid.map(s => s.boughtAt));
|
||||
out.push({ address: addr, builder, waitingSince });
|
||||
}
|
||||
out.sort((a, b) => (b.builder - a.builder) || (a.waitingSince - b.waitingSince));
|
||||
return out;
|
||||
}
|
||||
|
||||
function decide(now) {
|
||||
now = now || Date.now(); const c = cfgMod.get();
|
||||
const sold = chain.spots().filter(s => s.kind === 0 || s.kind === 1);
|
||||
const lastSale = sold.length ? Math.max(...sold.map(s => s.boughtAt)) : 0;
|
||||
const today = centralDay(now);
|
||||
const fundToday = chain.fundBuys().filter(f => centralDay(f.at) === today).length
|
||||
+ store.keeperEntries().filter(e => e.status === 'sent' && centralDay(e.at) === today && !chain.fundBuys().some(f => f.tx === e.tx)).length;
|
||||
if (!chain.spots().length) return { act: false, why: 'no spots in the line yet' };
|
||||
if (now - lastSale < c.keeperStallHours * 3600000) return { act: false, why: 'a spot sold in the last ' + c.keeperStallHours + ' h' };
|
||||
if (fundToday >= c.keeperMaxPerDay) return { act: false, why: fundToday + ' fund buys today (Central), limit ' + c.keeperMaxPerDay };
|
||||
const cands = candidates(now);
|
||||
return { act: true, giftee: cands.length ? cands[0].address : chain.ZERO, candidates: cands.length, fundToday };
|
||||
}
|
||||
|
||||
async function tick() {
|
||||
const c = cfgMod.get();
|
||||
if (running || !c.keeperEnabled || !process.env.KEEPER_KEY || !c.contract) return;
|
||||
running = true;
|
||||
try {
|
||||
await chain.tail(); // decide on fresh data
|
||||
const d = decide(); lastDecision = Object.assign({ at: Date.now() }, d);
|
||||
if (!d.act) return;
|
||||
let giftee = d.giftee;
|
||||
// the contract's own 7-day check is authoritative: re-read it when the view exists
|
||||
if (giftee !== chain.ZERO) { const lg = await chain.tryRead('lastGiftAt', [giftee]); if (lg && Date.now() / 1000 - Number(lg) < 7 * 86400) giftee = chain.ZERO; }
|
||||
const q = await chain.quote();
|
||||
const fb = await chain.tryRead('fundBalance');
|
||||
if (fb !== null && BigInt(fb) < BigInt(q.wei)) { store.keeperLog({ status: 'skipped', why: 'fund balance below one spot', giftee }); return; }
|
||||
const provider = new JsonRpcProvider(c.rpcs[0], c.chainId, { staticNetwork: true });
|
||||
const signer = new Wallet(process.env.KEEPER_KEY, provider);
|
||||
const fees = await chain.suggestedFees();
|
||||
const tx = await signer.sendTransaction({ to: c.contract, data: iface.encodeFunctionData('fundBuy', [giftee]),
|
||||
maxFeePerGas: BigInt(fees.maxFeePerGas), maxPriorityFeePerGas: BigInt(fees.maxPriorityFeePerGas) });
|
||||
store.keeperLog({ status: 'sent', tx: tx.hash, giftee });
|
||||
console.log('keeper fundBuy sent', tx.hash, 'giftee', giftee);
|
||||
const r = await tx.wait(1, 180000).catch(e => null);
|
||||
store.keeperLog({ status: r && r.status === 1 ? 'mined' : 'unconfirmed', tx: tx.hash, giftee });
|
||||
await chain.tail();
|
||||
} catch (e) {
|
||||
const msg = String(e && (e.shortMessage || e.message) || e).slice(0, 200);
|
||||
store.keeperLog({ status: 'error', why: msg }); console.error('keeper', msg);
|
||||
} finally { running = false; }
|
||||
}
|
||||
|
||||
function init() {
|
||||
const c = cfgMod.get();
|
||||
if (!c.keeperEnabled || !process.env.KEEPER_KEY) { console.log('keeper: off (needs KEEPER_ENABLED=1 and KEEPER_KEY)'); return; }
|
||||
console.log('keeper: on, every ' + Math.round(c.keeperEveryMs / 60000) + ' min');
|
||||
setTimeout(tick, 15000).unref();
|
||||
timer = setInterval(tick, c.keeperEveryMs); timer.unref && timer.unref();
|
||||
}
|
||||
function statusInfo() { const c = cfgMod.get(); return { enabled: c.keeperEnabled && !!process.env.KEEPER_KEY, last: lastDecision, preview: decide(), log: store.keeperEntries().slice(-20).reverse() }; }
|
||||
|
||||
module.exports = { init, tick, decide, candidates, statusInfo, centralDay };
|
||||
Generated
+124
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"name": "banner-line",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "banner-line",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"ethers": "^6.13.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@adraffy/ens-normalize": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz",
|
||||
"integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@noble/curves": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
|
||||
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@noble/hashes": "1.3.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/@noble/hashes": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
|
||||
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz",
|
||||
"integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.19.2"
|
||||
}
|
||||
},
|
||||
"node_modules/aes-js": {
|
||||
"version": "4.0.0-beta.5",
|
||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
|
||||
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ethers": {
|
||||
"version": "6.17.0",
|
||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.17.0.tgz",
|
||||
"integrity": "sha512-BpyrpIPJ3ydEVow8zGaz1DuPS7YU8DcWxuBnY9a0UA/lvAPwrMr+EPXsfrul628SRaekPNeIM4UFh/91GWZang==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/ethers-io/"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.buymeacoffee.com/ricmoo"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@adraffy/ens-normalize": "1.11.1",
|
||||
"@noble/curves": "1.2.0",
|
||||
"@noble/hashes": "1.3.2",
|
||||
"@types/node": "22.7.5",
|
||||
"aes-js": "4.0.0-beta.5",
|
||||
"tslib": "2.7.0",
|
||||
"ws": "8.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
|
||||
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.19.8",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "banner-line",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Banner Line (downlinebanners.com): 468x60 spots in one global line, split on-chain when spots sell.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"dev": "node --watch server.js",
|
||||
"qa": "node qa/smoke.mjs"
|
||||
},
|
||||
"engines": { "node": ">=20" },
|
||||
"dependencies": {
|
||||
"ethers": "^6.13.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="468" height="60" viewBox="0 0 468 60"><defs><linearGradient id="g" x1="0" x2="1"><stop offset="0" stop-color="#3a1f4a"/><stop offset="1" stop-color="#071009"/></linearGradient></defs><rect width="468" height="60" rx="6" fill="url(#g)"/><rect x="1" y="1" width="466" height="58" rx="6" fill="none" stroke="#9d7dff" stroke-opacity=".6"/><text x="18" y="27" font-family="Segoe UI,Arial,sans-serif" font-size="19" font-weight="700" fill="#eef7f3">Network games</text><text x="18" y="46" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" fill="#cfe6de">Free browser games from the Crypto Team Build Network.</text><rect x="368" y="17" width="84" height="26" rx="13" fill="#9d7dff"/><text x="410" y="34.5" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" font-weight="700" fill="#03211a">Play</text></svg>
|
||||
|
After Width: | Height: | Size: 883 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="468" height="60" viewBox="0 0 468 60"><defs><linearGradient id="g" x1="0" x2="1"><stop offset="0" stop-color="#0f3b30"/><stop offset="1" stop-color="#071009"/></linearGradient></defs><rect width="468" height="60" rx="6" fill="url(#g)"/><rect x="1" y="1" width="466" height="58" rx="6" fill="none" stroke="#43e8c3" stroke-opacity=".6"/><text x="18" y="27" font-family="Segoe UI,Arial,sans-serif" font-size="19" font-weight="700" fill="#eef7f3">InstantAdPay</text><text x="18" y="46" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" fill="#cfe6de">Advertise to members. Ad credits buy advertising, not income.</text><rect x="368" y="17" width="84" height="26" rx="13" fill="#43e8c3"/><text x="410" y="34.5" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" font-weight="700" fill="#03211a">Visit</text></svg>
|
||||
|
After Width: | Height: | Size: 890 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="468" height="60" viewBox="0 0 468 60"><defs><linearGradient id="g" x1="0" x2="1"><stop offset="0" stop-color="#3a2c0b"/><stop offset="1" stop-color="#071009"/></linearGradient></defs><rect width="468" height="60" rx="6" fill="url(#g)"/><rect x="1" y="1" width="466" height="58" rx="6" fill="none" stroke="#ffb238" stroke-opacity=".6"/><text x="18" y="27" font-family="Segoe UI,Arial,sans-serif" font-size="19" font-weight="700" fill="#eef7f3">Banner Line: this slot is open</text><text x="18" y="46" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" fill="#cfe6de">A $5 spot = 300 guaranteed views and a place in the line.</text><rect x="368" y="17" width="84" height="26" rx="13" fill="#ffb238"/><text x="410" y="34.5" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" font-weight="700" fill="#03211a">Get a spot</text></svg>
|
||||
|
After Width: | Height: | Size: 909 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="468" height="60" viewBox="0 0 468 60"><defs><linearGradient id="g" x1="0" x2="1"><stop offset="0" stop-color="#1b2a4a"/><stop offset="1" stop-color="#071009"/></linearGradient></defs><rect width="468" height="60" rx="6" fill="url(#g)"/><rect x="1" y="1" width="466" height="58" rx="6" fill="none" stroke="#54ccff" stroke-opacity=".6"/><text x="18" y="27" font-family="Segoe UI,Arial,sans-serif" font-size="19" font-weight="700" fill="#eef7f3">LinkSpin</text><text x="18" y="46" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" fill="#cfe6de">Rotate your links and banners across the network.</text><rect x="368" y="17" width="84" height="26" rx="13" fill="#54ccff"/><text x="410" y="34.5" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="12.5" font-weight="700" fill="#03211a">Visit</text></svg>
|
||||
|
After Width: | Height: | Size: 874 B |
@@ -0,0 +1,14 @@
|
||||
// Organic board page: shows the rotation, counts views after 5 s on screen (one-time server token).
|
||||
(async function () {
|
||||
await BL.renderNav('/board'); BL.renderFooter();
|
||||
const $ = BL.$;
|
||||
const [b, s] = await Promise.all([BL.getJSON('/api/board'), BL.getJSON('/api/stats')]);
|
||||
const box = $('lots');
|
||||
for (const t of b.tiles || []) box.appendChild(BL.tile(t, { meta: true }));
|
||||
const spots = (b.tiles || []).filter(t => t.t === 'spot').length;
|
||||
$('boardNote').textContent = spots ? spots + ' member spot' + (spots === 1 ? '' : 's') + ' on this view. Reload to see the rotation.' : 'No member spots are delivering right now. Network sites fill the open slots.';
|
||||
if (b.token) setTimeout(() => { if (document.visibilityState === 'visible') BL.post('/api/board/seen', { token: b.token }); }, 5500);
|
||||
const t = (s && s.totals) || {};
|
||||
$('stats').innerHTML = [['Spots in the line', t.spots || 0], ['Members', t.members || 0], ['POL paid in', BL.fmtPol(t.paidInWei || 0)], ['POL paid out to members and fees', BL.fmtPol(t.paidOutWei || 0)]]
|
||||
.map(x => '<div class="stat"><b>' + BL.esc(x[1]) + '</b><span>' + BL.esc(x[0]) + '</span></div>').join('');
|
||||
})();
|
||||
@@ -0,0 +1,55 @@
|
||||
// Shared page helpers (BL namespace, modelled on InstantAdPay common.js).
|
||||
window.BL = (function () {
|
||||
let cfgP = null;
|
||||
const $ = id => document.getElementById(id);
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
|
||||
function fmtPol(wei, dp) {
|
||||
try { const w = BigInt(wei || 0); const whole = w / 10n ** 18n; const frac = (w % 10n ** 18n).toString().padStart(18, '0').slice(0, dp || 4).replace(/0+$/, '');
|
||||
return whole.toString() + (frac ? '.' + frac : ''); } catch (e) { return '0'; }
|
||||
}
|
||||
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
||||
const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
|
||||
function status(msg, cls) { const el = $('status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; }
|
||||
async function getJSON(url, opts) { const r = await fetch(url, opts); let j = {}; try { j = await r.json(); } catch (e) {} if (!r.ok && !j.error) j.error = 'Request failed (' + r.status + ')'; return j; }
|
||||
const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) });
|
||||
|
||||
async function renderNav(active) {
|
||||
const c = await getConfig().catch(() => ({}));
|
||||
const n = document.createElement('nav');
|
||||
const links = [['/', 'Home'], ['/board', 'Board'], ['/how', 'How it works'], ['/join', 'Get a spot'], ['/my', 'My Spots']];
|
||||
n.innerHTML = '<div class="wrap"><div class="logo-wrap"><a class="logo" href="/">Banner <b>Line</b></a>'
|
||||
+ '<span class="byline">Part of the <b>Crypto Team Build</b> Network</span></div><div class="links">'
|
||||
+ links.map(l => '<a href="' + l[0] + '"' + (l[0] === active ? ' class="active"' : '') + '>' + l[1] + '</a>').join('') + '</div></div>';
|
||||
document.body.prepend(n);
|
||||
if (c && c.chainId && c.chainId !== 137) {
|
||||
const r = document.createElement('div'); r.className = 'rehearsal';
|
||||
r.innerHTML = '<b>Rehearsal:</b> this runs on ' + esc(c.chainName) + '. Test POL only, no real money.';
|
||||
n.after(r);
|
||||
}
|
||||
// inside a traffic-exchange frame, member and buy pages open in a new tab with the sponsor carried along
|
||||
if (framed) document.querySelectorAll('nav a[href="/join"], nav a[href="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; });
|
||||
}
|
||||
function renderFooter() {
|
||||
const f = document.createElement('footer');
|
||||
f.className = 'bl-foot';
|
||||
f.innerHTML = '<div class="wrap"><p>Part of the Crypto Team Build Network</p>'
|
||||
+ '<p class="muted small">A spot buys 300 guaranteed views on the board and a place in the line. Nothing is promised: you are paid only when spots sell after yours, and a spot can earn back less than it cost.</p>'
|
||||
+ '<p class="small"><a href="/how">How it works</a> · <a href="/board">Board</a> · <a href="/my">My Spots</a></p></div>';
|
||||
document.body.appendChild(f);
|
||||
}
|
||||
// one spot tile; href goes through the /go relay, which counts the click
|
||||
function tile(t, opts) {
|
||||
const a = document.createElement('a');
|
||||
a.className = 'lot' + (t.t !== 'spot' ? ' house' : '');
|
||||
a.href = t.href; a.target = '_blank'; a.rel = 'noopener';
|
||||
const img = document.createElement('img'); img.src = t.img; img.width = 468; img.height = 60; img.alt = t.t === 'spot' ? 'Spot #' + t.id : (t.title || 'Network');
|
||||
img.loading = 'lazy'; img.referrerPolicy = 'no-referrer';
|
||||
img.onerror = () => { img.onerror = null; img.src = '/art/house-line.svg'; };
|
||||
a.appendChild(img);
|
||||
if (opts && opts.meta) { const m = document.createElement('span'); m.className = 'lot-meta'; m.textContent = t.t === 'spot' ? '#' + t.id : 'network'; a.appendChild(m); }
|
||||
return a;
|
||||
}
|
||||
function withRef(href, sponsor) { if (!sponsor) return href; return href + (href.includes('?') ? '&' : '?') + 'ref=' + encodeURIComponent(sponsor); }
|
||||
return { $, esc, getConfig, fmtPol, short, framed, status, getJSON, post, renderNav, renderFooter, tile, withRef };
|
||||
})();
|
||||
@@ -0,0 +1,79 @@
|
||||
// Home page gate: (1) the sponsor's newest spot, (2) the whole board ~10 s, (3) the 3 newest spots, each on a timer,
|
||||
// then Join unlocks. The server keeps the plan and checks every step's time; this script only drives the screens.
|
||||
// Visits load inside a frame under our timer bar (IAP login-gate pattern); a site that refuses framing opens in a
|
||||
// new tab and the timer runs from the moment it is opened.
|
||||
(async function () {
|
||||
await BL.renderNav('/'); BL.renderFooter();
|
||||
const $ = BL.$;
|
||||
const me = await BL.getJSON('/api/me').catch(() => ({}));
|
||||
const g = await BL.getJSON('/api/gate');
|
||||
if (g.error) { BL.status(g.error, 'err'); return; }
|
||||
if (g.passed) return showOpen();
|
||||
|
||||
$('gate').hidden = false;
|
||||
const labels = g.steps.map(s => s.type === 'board' ? 'The board' : s.role === 'sponsor' ? 'Your sponsor' : 'Newest spot');
|
||||
const paint = i => { $('gateSteps').innerHTML = labels.map((l, k) => '<li class="' + (k < i ? 'done' : k === i ? 'on' : '') + '">' + (k + 1) + '. ' + BL.esc(l) + '</li>').join(''); };
|
||||
|
||||
let i = 0;
|
||||
async function run() {
|
||||
paint(i);
|
||||
const st = g.steps[i]; const stage = $('gStage'); stage.innerHTML = ''; $('gNext').hidden = true; $('gOpen').hidden = true; $('gProg').style.width = '0';
|
||||
let opened = st.type === 'board' || st.frame; // a new-tab visit starts its clock when the visitor opens it
|
||||
const startClock = async () => {
|
||||
const b = await BL.post('/api/gate/begin', { gid: g.gid, i });
|
||||
if (b.error) { BL.status(b.error, 'err'); return; }
|
||||
countdown(st.seconds, () => finish());
|
||||
};
|
||||
if (st.type === 'board') {
|
||||
$('gWhat').textContent = 'The board: every spot shown here counts as a view.';
|
||||
const box = document.createElement('div'); box.className = 'lots'; for (const t of st.tiles) box.appendChild(BL.tile(t)); stage.appendChild(box);
|
||||
startClock();
|
||||
} else {
|
||||
const href = st.open + '?g=' + encodeURIComponent(g.gid) + '&i=' + i;
|
||||
$('gOpen').href = href;
|
||||
if (st.frame) {
|
||||
$('gWhat').textContent = (st.role === 'sponsor' ? 'Your sponsor\'s newest spot' : st.title || 'Newest spot') + '. Have a look while the timer runs.';
|
||||
const f = document.createElement('iframe'); f.className = 'gate-frame'; f.src = href; f.referrerPolicy = 'no-referrer';
|
||||
f.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox');
|
||||
stage.appendChild(f); $('gOpen').hidden = false; $('gOpen').textContent = 'Open site in a new tab';
|
||||
startClock();
|
||||
} else {
|
||||
$('gWhat').textContent = (st.role === 'sponsor' ? 'Your sponsor\'s newest spot' : st.title || 'Newest spot') + ' opens in a new tab. The timer starts when you open it.';
|
||||
const box = document.createElement('div'); box.className = 'gate-out';
|
||||
const pic = BL.tile({ t: 'spot', img: st.img, href, id: st.ref }); box.appendChild(pic);
|
||||
const b = document.createElement('a'); b.className = 'btn'; b.href = href; b.target = '_blank'; b.rel = 'noopener'; b.textContent = 'Open the site'; b.style.marginTop = '14px';
|
||||
box.appendChild(b); stage.appendChild(box);
|
||||
const go = () => { if (opened) return; opened = true; startClock(); };
|
||||
b.addEventListener('click', go); pic.addEventListener('click', go);
|
||||
$('gCount').textContent = st.seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
function countdown(sec, done) {
|
||||
let left = sec * 10; $('gCount').textContent = sec;
|
||||
const t = setInterval(() => {
|
||||
left -= 1;
|
||||
$('gCount').textContent = Math.max(0, Math.ceil(left / 10));
|
||||
$('gProg').style.width = Math.min(100, 100 * (1 - left / (sec * 10))) + '%';
|
||||
if (left <= 0) { clearInterval(t); done(); }
|
||||
}, 100);
|
||||
}
|
||||
async function finish() {
|
||||
const r = await BL.post('/api/gate/done', { gid: g.gid, i });
|
||||
if (r.error) { BL.status(r.error, 'err'); return; }
|
||||
if (r.passed) { paint(g.steps.length); $('gNext').hidden = false; $('gNext').textContent = 'Continue'; $('gWhat').textContent = 'Done. Join is open.'; $('gNext').onclick = () => { $('gate').hidden = true; showOpen(); }; return; }
|
||||
$('gNext').hidden = false; $('gNext').textContent = 'Next';
|
||||
$('gNext').onclick = () => { i += 1; run(); };
|
||||
}
|
||||
run();
|
||||
|
||||
async function showOpen() {
|
||||
$('open').hidden = false;
|
||||
const sp = me && me.sponsor;
|
||||
if (BL.framed) { const j = $('joinBtn'); j.href = BL.withRef('/join', sp); j.target = '_blank'; j.rel = 'noopener'; }
|
||||
const b = await BL.getJSON('/api/board');
|
||||
const box = $('lots'); box.innerHTML = '';
|
||||
for (const t of b.tiles || []) box.appendChild(BL.tile(t));
|
||||
if (b.token) setTimeout(() => { if (document.visibilityState === 'visible') BL.post('/api/board/seen', { token: b.token }); }, 5500);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1 @@
|
||||
(async function () { await BL.renderNav("/how"); BL.renderFooter(); })();
|
||||
@@ -0,0 +1,39 @@
|
||||
// Buy page: gate check, live price from /api/quote, buy(sponsor) or buyFor(owner, sponsor) from the visitor's wallet.
|
||||
(async function () {
|
||||
await BL.renderNav('/join'); BL.renderFooter();
|
||||
const $ = BL.$;
|
||||
const c = await BL.getConfig();
|
||||
const [g, me] = await Promise.all([BL.getJSON('/api/gate'), BL.getJSON('/api/me')]);
|
||||
if (!g.passed) { $('locked').hidden = false; $('tourLink').href = BL.withRef('/', me.sponsor); return; }
|
||||
$('buyCard').hidden = false;
|
||||
if (!c.ready) { BL.status('The contract address is not configured yet. Buying opens once it is.', 'err'); $('buyBtn').disabled = true; $('buyForBtn').disabled = true; }
|
||||
|
||||
let sponsor = null;
|
||||
const sp = await BL.getJSON('/api/sponsor');
|
||||
if (sp.address && sp.member) { sponsor = sp.address; $('sponsor').textContent = BL.short(sp.address); }
|
||||
else $('sponsor').textContent = sp.address ? 'not a member yet (none)' : 'none';
|
||||
|
||||
let q = null;
|
||||
async function loadQuote() {
|
||||
q = await BL.getJSON('/api/quote');
|
||||
$('price').textContent = q.error ? 'unavailable' : BL.fmtPol(q.sendWei, 5);
|
||||
if (q.error) BL.status('Price unavailable: ' + q.error, 'err');
|
||||
}
|
||||
await loadQuote(); setInterval(loadQuote, 30000);
|
||||
|
||||
async function doBuy(forAddr) {
|
||||
BL.status('');
|
||||
try {
|
||||
await loadQuote(); if (!q || q.error) throw new Error('No price right now. Try again in a minute.');
|
||||
BL.status('Confirm the payment in your wallet. The contract refunds anything above the price in the same transaction.');
|
||||
const r = forAddr ? await BLWallet.buyFor(forAddr, sponsor, q.sendWei) : await BLWallet.buy(sponsor, q.sendWei);
|
||||
if (r.receipt.status !== '0x1') throw new Error('The transaction reverted. Nothing was charged except gas.');
|
||||
BL.status('');
|
||||
$('doneCard').hidden = false; $('buyCard').hidden = true;
|
||||
$('txLink').innerHTML = c.explorer ? '<a target="_blank" rel="noopener" href="' + BL.esc(c.explorer + '/tx/' + r.hash) + '">View the transaction</a>' : BL.esc(r.hash);
|
||||
if (forAddr) $('doneCard').querySelector('h3').textContent = 'The spot is in the line for ' + BL.short(forAddr);
|
||||
} catch (e) { BL.status(String(e && e.message || e).slice(0, 300), 'err'); }
|
||||
}
|
||||
$('buyBtn').onclick = () => doBuy(null);
|
||||
$('buyForBtn').onclick = () => { const a = $('forAddr').value.trim(); if (!/^0x[0-9a-fA-F]{40}$/.test(a)) return BL.status('Enter a full wallet address (0x followed by 40 characters).', 'err'); doBuy(a); };
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Banner Line additions on top of the InstantAdPay site.css look. Neutral class names (no ad/banner words:
|
||||
ad blockers hide those). */
|
||||
.hero{padding:34px 0 10px;text-align:center}
|
||||
.hero h1{font-size:clamp(28px,4vw,44px);line-height:1.1;margin:0 0 10px}
|
||||
.hero h1 em{font-style:normal;color:var(--mint)}
|
||||
.hero p.lead{color:var(--muted);max-width:680px;margin:0 auto 14px;font-size:16px}
|
||||
.card{background:var(--panel-grad);border:1px solid var(--line-strong);border-radius:var(--radius);padding:20px 22px;margin:16px 0}
|
||||
.card h2,.card h3{margin:0 0 8px}
|
||||
.muted{color:var(--muted)} .small{font-size:13px} .mono{font-family:var(--mono)}
|
||||
.note{border-radius:12px;padding:10px 14px;margin:10px 0;background:var(--mint-faint);border:1px solid var(--line)}
|
||||
.note.err{background:var(--bad-soft);border-color:var(--bad);color:var(--ink)}
|
||||
.note.ok{background:var(--ok-soft);border-color:var(--ok)}
|
||||
.lots{display:flex;flex-direction:column;align-items:center;gap:10px;margin:14px 0}
|
||||
.lot{position:relative;display:block;width:468px;max-width:100%;line-height:0;border-radius:6px;overflow:hidden;border:1px solid var(--line)}
|
||||
.lot img{width:100%;height:auto;aspect-ratio:468/60;object-fit:cover;display:block;background:var(--panel-solid)}
|
||||
.lot.house{opacity:.92}
|
||||
.lot-meta{position:absolute;right:4px;bottom:3px;font:11px/1.2 var(--mono);background:rgba(0,0,0,.6);color:#fff;padding:1px 5px;border-radius:4px}
|
||||
.steps{display:flex;gap:6px;flex-wrap:wrap;margin:8px 0 14px;padding:0;list-style:none}
|
||||
.steps li{font-size:12.5px;padding:5px 11px;border-radius:999px;border:1px solid var(--line);color:var(--muted)}
|
||||
.steps li.on{border-color:var(--mint);color:var(--mint)} .steps li.done{color:var(--ok);border-color:var(--ok)}
|
||||
.gate-bar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:14px 14px 0 0;padding:10px 14px}
|
||||
.gate-bar .count{font:700 22px/1 var(--disp);color:var(--mint);min-width:44px}
|
||||
.gate-bar .what{flex:1;min-width:180px;font-size:14px}
|
||||
.gate-frame{width:100%;height:min(62vh,560px);border:1px solid var(--line-strong);border-top:0;border-radius:0 0 14px 14px;background:#fff;display:block}
|
||||
.gate-out{border:1px solid var(--line-strong);border-top:0;border-radius:0 0 14px 14px;padding:22px;text-align:center}
|
||||
.progress{height:6px;border-radius:3px;background:var(--line);overflow:hidden;margin-top:6px;width:100%}
|
||||
.progress i{display:block;height:100%;background:var(--mint);width:0;transition:width .25s linear}
|
||||
table.tbl{width:100%;border-collapse:collapse;font-size:14px}
|
||||
table.tbl th,table.tbl td{text-align:left;padding:8px 6px;border-bottom:1px solid var(--line);vertical-align:top}
|
||||
table.tbl th{color:var(--muted);font-weight:600;font-size:12.5px}
|
||||
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
|
||||
.stat{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px}
|
||||
.stat b{display:block;font:700 22px/1.2 var(--disp);color:var(--ink)} .stat span{color:var(--muted);font-size:13px}
|
||||
.field{display:flex;flex-direction:column;gap:4px;margin:8px 0}
|
||||
.field input{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:10px;padding:9px 12px;color:var(--ink);font:14px var(--mono);width:100%}
|
||||
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
|
||||
.spot-ed{border-top:1px solid var(--line);padding:14px 0}
|
||||
.bl-foot{margin-top:40px;padding:26px 0;border-top:1px solid var(--line);text-align:center}
|
||||
.bl-foot p{margin:6px 0}
|
||||
@media (max-width:520px){.gate-frame{height:58vh}.card{padding:16px}}
|
||||
@@ -0,0 +1,63 @@
|
||||
// My Spots + dashboard: wallet signature sign-in, per-spot image + link editing, default creative, payouts, directs.
|
||||
(async function () {
|
||||
await BL.renderNav('/my'); BL.renderFooter();
|
||||
const $ = BL.$, esc = BL.esc;
|
||||
const ROLE = { 0: 'sponsor share', 1: 'line level', 2: 'company A', 3: 'company B', 4: 'fund' };
|
||||
const KIND = { 0: 'paid', 1: 'bought for you', 2: 'fund gift', 3: 'fund kept' };
|
||||
const c = await BL.getConfig();
|
||||
const me = await BL.getJSON('/api/me');
|
||||
if (!me.signedIn) {
|
||||
$('signin').hidden = false;
|
||||
$('signBtn').onclick = async () => {
|
||||
try { BL.status('Check your wallet for the sign-in message.'); await BLWallet.signIn(); location.reload(); }
|
||||
catch (e) { BL.status(String(e && e.message || e).slice(0, 300), 'err'); }
|
||||
};
|
||||
return;
|
||||
}
|
||||
$('outBtn').onclick = async () => { await BL.post('/api/auth/logout'); location.reload(); };
|
||||
async function load() {
|
||||
const d = await BL.getJSON('/api/my');
|
||||
if (d.error) return BL.status(d.error, 'err');
|
||||
$('dash').hidden = false; $('me').textContent = d.address;
|
||||
const delivered = d.spots.reduce((t, s) => t + s.views, 0);
|
||||
$('stats').innerHTML = [['Spots owned', d.spots.length], ['Views delivered', delivered + ' of ' + d.spots.filter(s => s.kind !== 3).length * c.viewsOwed],
|
||||
['POL paid in', BL.fmtPol(d.paidInWei)], ['POL paid out to you', BL.fmtPol(d.paidOutWei)]]
|
||||
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
||||
$('share').value = d.share;
|
||||
$('copyBtn').onclick = () => { $('share').select(); try { navigator.clipboard.writeText(d.share); } catch (e) { document.execCommand('copy'); } BL.status('Link copied.', 'ok'); };
|
||||
const box = $('spots'); box.innerHTML = '';
|
||||
if (!d.spots.length) box.innerHTML = '<p>You have no spots yet. <a href="/join">Get one</a>.</p>';
|
||||
for (const s of d.spots) box.appendChild(editor('spot', s));
|
||||
$('defaults').innerHTML = ''; $('defaults').appendChild(editor('default', { img: d.defaults.img || '', link: d.defaults.link || '', showing: { img: d.defaults.img || '/art/house-line.svg' } }));
|
||||
$('payouts').innerHTML = d.payouts.length ? '<table class="tbl"><tr><th>Spot sold</th><th>Why</th><th>POL</th><th>Tx</th></tr>' + d.payouts.map(p => '<tr><td>#' + p.spotId + '</td><td>' + esc(ROLE[p.role] || p.role) + '</td><td>' + BL.fmtPol(p.amount, 6) + '</td><td class="mono small">' + txLink(p.tx) + '</td></tr>').join('') + '</table>' : '<p class="muted">No payments yet. You are paid when spots sell after yours, or when someone you referred buys.</p>';
|
||||
$('directs').innerHTML = d.directs.length ? '<table class="tbl"><tr><th>Member</th><th>Joined</th><th>Spots</th><th>Paid spots</th><th>POL paid in</th></tr>' + d.directs.map(m => '<tr><td class="mono small">' + esc(BL.short(m.address)) + '</td><td>' + new Date(m.joinedAt).toLocaleDateString() + '</td><td>' + m.spots + '</td><td>' + m.paidSpots + '</td><td>' + BL.fmtPol(m.paidInWei) + '</td></tr>').join('') + '</table>' : '<p class="muted">Nobody has joined through your link yet.</p>';
|
||||
}
|
||||
const txLink = h => c.explorer ? '<a target="_blank" rel="noopener" href="' + esc(c.explorer + '/tx/' + h) + '">' + esc(h.slice(0, 10)) + '...</a>' : esc(h.slice(0, 10)) + '...';
|
||||
function editor(kind, s) {
|
||||
const el = document.createElement('div'); el.className = 'spot-ed';
|
||||
const head = kind === 'spot' ? '<div class="row" style="justify-content:space-between"><b>Spot #' + s.id + '</b><span class="muted small">' + esc(KIND[s.kind] || '') + ' · ' + s.views + ' of ' + s.owed + ' views'
|
||||
+ (s.kind === 3 ? '' : s.delivering ? ' · ' + s.daysLeft + ' days left' : ' · delivery finished') + ' · clicks ' + (s.clicks.organic + s.clicks.gate) + '</span></div>' : '';
|
||||
el.innerHTML = head + '<div class="lots" style="align-items:flex-start"></div>'
|
||||
+ '<div class="field"><label class="small muted">Target link (https)</label><input data-k="link" placeholder="https://your-site.com/page" value="' + esc(s.link || '') + '"></div>'
|
||||
+ '<div class="field"><label class="small muted">Image address (https), or upload below</label><input data-k="img" placeholder="https://your-site.com/image.png" value="' + esc(String(s.img || '').startsWith('/art/u/') ? '' : s.img || '') + '"></div>'
|
||||
+ '<div class="row"><button class="btn small" data-a="save">Save</button><label class="btn sec small">Upload image<input type="file" accept="image/png,image/jpeg,image/gif" hidden></label></div>';
|
||||
const prev = el.querySelector('.lots'); prev.appendChild(BL.tile({ t: 'x', img: (s.showing && s.showing.img) || '/art/house-line.svg', href: s.link || '#' }));
|
||||
const url = kind === 'spot' ? '/api/my/spot/' + s.id : '/api/my/default';
|
||||
el.querySelector('[data-a=save]').onclick = async () => {
|
||||
const link = el.querySelector('[data-k=link]').value.trim(), img = el.querySelector('[data-k=img]').value.trim();
|
||||
const body = { link }; if (img || !String(s.img || '').startsWith('/art/u/')) body.img = img;
|
||||
const r = await BL.post(url, body);
|
||||
if (r.error) return BL.status(r.error, 'err');
|
||||
BL.status('Saved.', 'ok'); load();
|
||||
};
|
||||
el.querySelector('input[type=file]').onchange = async ev => {
|
||||
const f = ev.target.files[0]; if (!f) return;
|
||||
if (f.size > 150 * 1024) return BL.status('That file is ' + Math.ceil(f.size / 1024) + ' KB. The limit is 150 KB.', 'err');
|
||||
const r = await BL.getJSON('/api/my/upload?for=' + (kind === 'spot' ? s.id : 'default'), { method: 'POST', headers: { 'Content-Type': f.type || 'application/octet-stream' }, body: f });
|
||||
if (r.error) return BL.status(r.error, 'err');
|
||||
BL.status('Image uploaded.', 'ok'); load();
|
||||
};
|
||||
return el;
|
||||
}
|
||||
load();
|
||||
})();
|
||||
@@ -0,0 +1,866 @@
|
||||
/* InstantAdPay visual system v4 — built to Marty's picked reference
|
||||
(Behance 243562211 "ChainLock"): near-black ground, ONE neon-mint accent,
|
||||
sweeping light-trail hero, glowing icon plates, mockup-anchored sections,
|
||||
ghost wordmark footer. Discipline over decoration. */
|
||||
:root{
|
||||
--ground:#040807; --ground2:#071009;
|
||||
--panel:rgba(16,28,24,.55); --panel-solid:#0b1512;
|
||||
--line:rgba(84,150,128,.16); --line-strong:rgba(84,150,128,.36);
|
||||
--ink:#eef7f3; --muted:#8ba69c;
|
||||
--mint:#43e8c3; --mint-hi:#8ffbe3; --mint-ink:#03211a;
|
||||
--mint-soft:rgba(67,232,195,.09); --bad:#ff8f7d;
|
||||
--cyan:#54ccff; --violet:#9d7dff; --amber:#ffb238;
|
||||
--mono:"Consolas","JetBrains Mono",monospace;
|
||||
--disp:"Sora","Segoe UI",system-ui,sans-serif;
|
||||
--radius:18px;
|
||||
/* 2026-11-01 theme tokens (mirrored from LinkSpin): every surface, text, border and soft fill that used to be a literal
|
||||
in this file, the page inline styles and the UI-drawing scripts. Light values live in :root[data-theme="light"] at
|
||||
the end of this file; themehead.js sets data-theme on <html> before the first paint. */
|
||||
--mint-deep:#1fb894; --mint-pale:#8ffbe3;
|
||||
--mint-faint:rgba(67,232,195,.06); --mint-soft-2:rgba(67,232,195,.16); --mint-line:rgba(67,232,195,.38); --mint-line-2:rgba(67,232,195,.6);
|
||||
--ok:#22c55e; --ok-ink:#04140a; --ok-soft:rgba(34,197,94,.15); --warn:#f0a742; --bad-soft:rgba(255,143,125,.12);
|
||||
--gold:#ffd15c; --gold-2:#f2c94c; --gold-ink:#1a1206; --gold-soft:rgba(242,201,76,.14); --gold-faint:rgba(242,201,76,.04); --gold-line:rgba(242,201,76,.55);
|
||||
--amber-soft:rgba(255,178,56,.12); --amber-line:rgba(255,178,56,.4); --amber-ink:#1a1206;
|
||||
--cyan-soft:rgba(84,204,255,.1); --cyan-line:rgba(84,204,255,.3); --violet-soft:rgba(157,125,255,.12); --violet-line:rgba(157,125,255,.32);
|
||||
--muted-soft:rgba(139,166,156,.12); --muted-line:rgba(139,166,156,.4); --ink-faint:rgba(255,255,255,.04); --line-soft:rgba(84,150,128,.08);
|
||||
--ground-soft:rgba(4,8,7,.5); --field-bg:rgba(4,8,7,.65); --nav-bg:rgba(4,8,7,.75); --side-bg:rgba(10,18,15,.92); --pill-bg:rgba(16,28,24,.7);
|
||||
--panel-grad:linear-gradient(165deg,rgba(24,36,31,.6),rgba(13,19,17,.66)); --panel-grad-deep:linear-gradient(170deg,#0e1c17,#080f0c); --plate-grad:linear-gradient(160deg,#12241e,#0a1411);
|
||||
--sh-lg:0 30px 80px rgba(0,0,0,.6),0 0 60px rgba(67,232,195,.08);
|
||||
color-scheme:dark;
|
||||
}
|
||||
*{box-sizing:border-box}
|
||||
[hidden]{display:none!important} /* beats any display: set by a class (chat panel bug) */
|
||||
html{scroll-behavior:smooth}
|
||||
body{margin:0;background:var(--ground);color:var(--ink);font:16px/1.65 "Segoe UI",system-ui,sans-serif;overflow-x:hidden}
|
||||
/* topo-contour ground texture, very faint */
|
||||
body::before{content:"";position:fixed;inset:0;z-index:-1;pointer-events:none;opacity:.5;
|
||||
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='560' viewBox='0 0 560 560'%3E%3Cg fill='none' stroke='%2343e8c3' stroke-opacity='.05'%3E%3Cpath d='M60 280c40-90 160-130 220-90s60 150 160 150 120-90 120-90'/%3E%3Cpath d='M40 340c60-110 190-160 260-110s60 170 180 170'/%3E%3Cpath d='M20 400c80-130 220-190 300-130s60 190 200 190'/%3E%3Cpath d='M80 220c30-70 130-100 180-70s50 120 130 120 100-70 100-70'/%3E%3C/g%3E%3C/svg%3E")}
|
||||
a{color:var(--mint);text-decoration:none}
|
||||
a:hover{text-decoration:underline}
|
||||
.wrap{max-width:1100px;margin:0 auto;padding:0 22px}
|
||||
h1,h2,h3{font-family:var(--disp);letter-spacing:-.015em}
|
||||
/* ── nav: capsule pill ─────────────────────────────── */
|
||||
nav{position:sticky;top:0;z-index:10;background:var(--nav-bg);backdrop-filter:blur(16px);
|
||||
-webkit-backdrop-filter:blur(16px);border-bottom:1px solid var(--line)}
|
||||
nav .wrap{display:flex;align-items:center;gap:20px;min-height:66px;flex-wrap:wrap;padding-top:8px;padding-bottom:8px}
|
||||
.logo{font-family:var(--disp);font-weight:800;font-size:20px;color:var(--ink)}
|
||||
.logo b{color:var(--mint)}
|
||||
.logo-wrap{display:flex;flex-direction:column;gap:3px;min-width:0}
|
||||
.byline{display:block;font-size:10.5px;line-height:1.2;letter-spacing:.05em;color:var(--muted);white-space:nowrap}
|
||||
.byline b{color:var(--ink);font-weight:600}
|
||||
.bo-side .byline{padding:4px 8px 10px;white-space:normal}
|
||||
@media (max-width:560px){nav .byline{font-size:9.5px}}
|
||||
nav .links{display:flex;gap:4px;flex:1;flex-wrap:wrap;background:var(--pill-bg);border:1px solid var(--line);
|
||||
border-radius:999px;padding:5px 8px;width:fit-content;flex:0 1 auto;margin:0 auto}
|
||||
nav .links a{color:var(--muted);font-size:13.5px;font-weight:600;padding:7px 14px;border-radius:999px}
|
||||
nav .links a:hover{color:var(--ink);text-decoration:none}
|
||||
nav .links a.active{color:var(--mint);background:var(--mint-soft)}
|
||||
#navWallet{font-size:13px;margin-left:auto}
|
||||
.rehearsal{background:var(--mint-faint);border-bottom:1px solid var(--line);color:var(--muted);
|
||||
text-align:center;font-size:12.5px;padding:7px 12px}
|
||||
.rehearsal b{color:var(--mint)}
|
||||
/* ── buttons ───────────────────────────────────────── */
|
||||
.btn{display:inline-block;background:var(--mint);color:var(--mint-ink);border:0;border-radius:999px;
|
||||
padding:13px 26px;font-weight:700;font-size:15px;cursor:pointer;font-family:var(--disp);
|
||||
box-shadow:0 4px 30px rgba(67,232,195,.35);transition:transform .16s ease,box-shadow .16s ease,background .16s ease}
|
||||
.btn:hover{transform:translateY(-2px);background:var(--mint-hi);box-shadow:0 8px 44px rgba(67,232,195,.5);text-decoration:none}
|
||||
.btn.sec{background:transparent;color:var(--mint);border:1px solid var(--mint-line-2);box-shadow:none}
|
||||
.btn.sec:hover{background:var(--mint-soft);box-shadow:0 4px 26px rgba(67,232,195,.2)}
|
||||
.btn.small{padding:8px 17px;font-size:13px}
|
||||
/* a third, quieter button for actions that are not the main move (Archive). NOT ".ghost": that is
|
||||
the giant footer wordmark and it sets color:transparent, which made the Archive button invisible
|
||||
(Marty, 2026-09-23). */
|
||||
.btn.quiet{background:transparent;color:var(--muted);border:1px solid var(--line-strong);box-shadow:none}
|
||||
.btn.quiet:hover{background:var(--muted-soft);color:var(--ink);border-color:var(--muted);box-shadow:none}
|
||||
/* the member's campaign actions sat flush against each other on desktop; the mobile rule already
|
||||
had a gap, this gives the wide layout the same room */
|
||||
/* Campaign actions (Marty, 2026-09-23): the column is narrow, so these stack. Left-aligned pills
|
||||
of different widths read as a ragged edge, and a wrapped label inside a 999px radius turns into
|
||||
a tall oval. They are a centred, even-width stack with a modest corner instead. */
|
||||
.camp-table td.act{text-align:center;vertical-align:middle}
|
||||
.camp-table td.act .btn{display:block;width:100%;min-width:118px;margin:0 0 8px;border-radius:10px;
|
||||
text-align:center;line-height:1.25;white-space:normal}
|
||||
.camp-table td.act .btn:last-child{margin-bottom:0}
|
||||
.btn:disabled{opacity:.45;cursor:default;transform:none;box-shadow:none}
|
||||
/* ── segmented control + the Light / Dark / Auto theme switch (2026-11-01): member-area header, Profile pane, admin header ── */
|
||||
.seg{display:inline-flex;border:1px solid var(--line-strong);border-radius:999px;overflow:hidden;background:var(--pill-bg);vertical-align:middle}
|
||||
.seg button{background:transparent;border:0;border-right:1px solid var(--line-strong);padding:6px 12px;font:700 12px var(--disp);color:var(--muted);cursor:pointer;line-height:1.2}
|
||||
.seg button:last-child{border-right:0} .seg button:hover{color:var(--ink)} .seg button.on{background:var(--mint);color:var(--mint-ink)}
|
||||
.theme-seg button{min-width:0}
|
||||
.bo-top .theme-seg{margin-left:auto;flex:none} .bo-top .bo-rehearsal:not([hidden]) + .theme-seg{margin-left:0}
|
||||
@media (max-width:560px){.bo-top .theme-seg button{padding:6px 9px;font-size:11px}}
|
||||
/* ── hero: centered, light-trail set-piece ─────────── */
|
||||
.hero{position:relative;text-align:center;padding:120px 0 84px;overflow:visible}
|
||||
.hero h1{font-size:clamp(36px,5.4vw,62px);font-weight:700;line-height:1.08;margin:0 auto 18px;max-width:820px;text-wrap:balance}
|
||||
.hero h1 em{font-style:normal;color:var(--mint)}
|
||||
.hero p.lead{color:var(--muted);font-size:17.5px;max-width:600px;margin:0 auto 32px}
|
||||
.hero p.lead b{color:var(--ink)}
|
||||
.hero .ctas{display:flex;gap:14px;justify-content:center;flex-wrap:wrap}
|
||||
/* neon arcs behind the hero text */
|
||||
.arcs{position:absolute;inset:-40px 0 0 0;z-index:-1;pointer-events:none}
|
||||
.arcs svg{width:100%;height:100%;overflow:visible}
|
||||
.arc{fill:none;stroke:url(#arcGrad);stroke-width:5;stroke-linecap:round;filter:url(#arcGlow)}
|
||||
.arc2{fill:none;stroke:url(#arcGrad);stroke-width:3;stroke-linecap:round;filter:url(#arcGlow);opacity:.8}
|
||||
/* falling glow streaks */
|
||||
.streak{position:absolute;top:-140px;width:1.5px;height:110px;pointer-events:none;
|
||||
background:linear-gradient(180deg,transparent,rgba(143,251,227,.8));border-radius:2px;opacity:0}
|
||||
@media(prefers-reduced-motion:no-preference){
|
||||
.streak{animation:fall 7s linear infinite}
|
||||
@keyframes fall{0%{transform:translateY(0);opacity:0}12%{opacity:.7}55%{opacity:.5}75%{transform:translateY(72vh);opacity:0}100%{transform:translateY(72vh);opacity:0}}
|
||||
}
|
||||
/* ── counters ──────────────────────────────────────── */
|
||||
.stats{display:grid;grid-template-columns:repeat(2,1fr);gap:14px;margin:60px auto 0;max-width:900px}
|
||||
@media(min-width:760px){.stats{grid-template-columns:repeat(4,1fr)}}
|
||||
.stat{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:18px 12px;text-align:center}
|
||||
.stat .n{font-family:var(--disp);font-size:30px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--mint)}
|
||||
.stat .l{font-size:11.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.1em;margin-top:3px}
|
||||
/* ── sections ──────────────────────────────────────── */
|
||||
section{padding:64px 0 8px}
|
||||
.sectionhead{text-align:center;max-width:640px;margin:0 auto 40px}
|
||||
.cmp{width:100%;border-collapse:separate;border-spacing:0;font-size:15px;background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
|
||||
.cmp th,.cmp td{padding:13px 16px;border-bottom:1px solid var(--line);vertical-align:top;text-align:left}
|
||||
.cmp th{font-family:var(--disp);font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
|
||||
.cmp th:last-child,.cmp td:last-child{color:var(--ink);background:var(--mint-faint)}
|
||||
.cmp td:first-child{font-weight:700;white-space:nowrap}
|
||||
.cmp td:nth-child(2){color:var(--muted)}
|
||||
.cmp tr:last-child td{border-bottom:0}
|
||||
@media (max-width:640px){.cmp td:first-child{white-space:normal}.cmp th,.cmp td{padding:10px 10px;font-size:14px}}
|
||||
h2{font-size:clamp(26px,3.2vw,36px);font-weight:700;margin:0 0 12px;text-wrap:balance}
|
||||
.sectionhead p{color:var(--muted);font-size:15.5px;margin:0}
|
||||
h3{font-size:16.5px;margin:0 0 8px;font-weight:700}
|
||||
.muted{color:var(--muted)}
|
||||
.small{font-size:13.5px}
|
||||
.mono{font-family:var(--mono)}
|
||||
/* icon-plate feature cards */
|
||||
.plates{display:grid;gap:16px;grid-template-columns:1fr}
|
||||
@media(min-width:760px){.plates{grid-template-columns:1fr 1fr 1fr}}
|
||||
.platecard{background:var(--panel-grad);border:1px solid var(--line);
|
||||
border-radius:var(--radius);padding:26px 22px;text-align:center;transition:border-color .2s ease,transform .2s ease}
|
||||
.platecard:hover{border-color:var(--line-strong);transform:translateY(-4px)}
|
||||
.plate{width:88px;height:88px;margin:0 auto 18px;border-radius:22px;display:grid;place-items:center;
|
||||
background:var(--plate-grad);border:1px solid var(--line-strong);
|
||||
box-shadow:0 0 34px rgba(67,232,195,.15),inset 0 1px 0 rgba(143,251,227,.15)}
|
||||
.plate svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
||||
.platecard p{color:var(--muted);font-size:14px;margin:0}
|
||||
/* two-col flank layout (icons around a central mockup) */
|
||||
.flank{display:grid;gap:26px;align-items:center;grid-template-columns:1fr}
|
||||
@media(min-width:920px){.flank{grid-template-columns:1fr 1.15fr 1fr}}
|
||||
.flankitem{margin:0 0 26px}
|
||||
.flankitem .plate{width:52px;height:52px;border-radius:14px;margin:0 0 12px}
|
||||
.flankitem .plate svg{width:24px;height:24px}
|
||||
.flankitem p{color:var(--muted);font-size:13.5px;margin:0}
|
||||
/* ledger mockup frame */
|
||||
.mockup{background:var(--panel-grad-deep);border:1px solid var(--line-strong);border-radius:20px;
|
||||
box-shadow:var(--sh-lg);overflow:hidden}
|
||||
.mockup .bar{display:flex;gap:6px;align-items:center;padding:11px 14px;border-bottom:1px solid var(--line)}
|
||||
.mockup .bar i{width:9px;height:9px;border-radius:50%;background:var(--line-strong);display:inline-block}
|
||||
.mockup .bar .addr{font-family:var(--mono);font-size:11px;color:var(--muted);margin-left:8px;background:var(--ground-soft);
|
||||
border-radius:999px;padding:3px 12px}
|
||||
.mockup .body{padding:6px 0}
|
||||
.mockup .mrow{display:flex;justify-content:space-between;gap:10px;padding:9px 16px;font-family:var(--mono);
|
||||
font-size:12px;border-bottom:1px solid var(--line-soft)}
|
||||
.mockup .mrow span:last-child{color:var(--mint)}
|
||||
.mockup .mrow.dim span:last-child{color:var(--muted)}
|
||||
/* 2-col story block: iso illustration + checklist */
|
||||
.story{display:grid;gap:36px;align-items:center;grid-template-columns:1fr}
|
||||
@media(min-width:880px){.story{grid-template-columns:1fr 1fr}}
|
||||
.checks{list-style:none;padding:0;margin:14px 0 0}
|
||||
.checks li{padding:7px 0 7px 30px;position:relative;color:var(--muted);font-size:14.5px}
|
||||
.checks li::before{content:"✓";position:absolute;left:0;top:6px;width:20px;height:20px;border-radius:50%;
|
||||
background:var(--mint-soft);color:var(--mint);font-size:12px;font-weight:700;display:grid;place-items:center;
|
||||
border:1px solid var(--mint-line)}
|
||||
.chips{display:flex;gap:8px;margin:14px 0 4px;flex-wrap:wrap}
|
||||
.chip-t{border:1px solid var(--line-strong);border-radius:999px;padding:5px 16px;font-size:12.5px;color:var(--muted);font-family:var(--disp);font-weight:600}
|
||||
.chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
|
||||
.iso{filter:drop-shadow(0 24px 50px rgba(0,0,0,.5))}
|
||||
/* level cycler: light the paying generation */
|
||||
#genViz .edge path{stroke:var(--line-strong);transition:stroke .5s ease}
|
||||
#genViz .node-o{fill:var(--panel-solid);stroke:var(--mint-line);stroke-width:1.3;transition:stroke .5s ease,fill .5s ease}
|
||||
#genViz .node-d{fill:var(--mint-deep);transition:fill .5s ease}
|
||||
#genViz[data-lvl="1"] .e1 path,#genViz[data-lvl="2"] .e2 path,#genViz[data-lvl="3"] .e3 path{stroke:var(--mint)}
|
||||
#genViz[data-lvl="1"] .g1 .node-o,#genViz[data-lvl="2"] .g2 .node-o,#genViz[data-lvl="3"] .g3 .node-o{stroke:var(--mint);fill:var(--mint-soft-2)}
|
||||
#genViz[data-lvl="1"] .g1 .node-d,#genViz[data-lvl="2"] .g2 .node-d,#genViz[data-lvl="3"] .g3 .node-d{fill:var(--mint)}
|
||||
.chips button{cursor:pointer;background:transparent;font:inherit}
|
||||
.chips button.chip-t{border:1px solid var(--line-strong);color:var(--muted)}
|
||||
.chips button.chip-t.on{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
|
||||
/* pricing tiles: mint discipline */
|
||||
.tiles{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));align-items:stretch}
|
||||
.tile{position:relative;background:var(--panel-grad);border:1px solid var(--line);
|
||||
border-radius:var(--radius);padding:26px 18px;text-align:center;display:flex;flex-direction:column;gap:6px;
|
||||
transition:transform .2s ease,border-color .2s ease}
|
||||
.tile:hover{transform:translateY(-5px);border-color:var(--line-strong)}
|
||||
.tile .name{font-family:var(--disp);font-weight:700;font-size:13px;color:var(--muted);text-transform:uppercase;letter-spacing:.12em}
|
||||
.tile .price{font-family:var(--disp);font-size:36px;font-weight:700}
|
||||
.tile .cr{color:var(--mint);font-weight:700;font-size:14.5px}
|
||||
.tile .bonus{font-size:12px;color:var(--mint-hi)}
|
||||
.tile .pol{font-family:var(--mono);font-size:12px;color:var(--muted);flex:1}
|
||||
.tile.hot{border:1px solid var(--mint-line-2);box-shadow:0 0 44px rgba(67,232,195,.14)}
|
||||
.tile.hot::before{content:"MOST POPULAR";position:absolute;top:-11px;left:50%;transform:translateX(-50%);
|
||||
background:var(--mint);color:var(--mint-ink);font-family:var(--disp);font-size:10px;font-weight:800;
|
||||
letter-spacing:.12em;border-radius:999px;padding:4px 14px}
|
||||
/* split strip: mint opacities */
|
||||
.split{display:flex;gap:8px;margin:18px 0}
|
||||
.split div{border-radius:12px;padding:16px 6px;text-align:center;font-size:13px;font-weight:700;font-family:var(--disp);
|
||||
border:1px solid var(--line-strong);color:var(--mint)}
|
||||
.split .s50{flex:5;background:var(--mint-soft-2);box-shadow:0 0 30px rgba(67,232,195,.12)}
|
||||
.split .s20{flex:2;background:var(--mint-soft)}
|
||||
.split .s10{flex:1;background:var(--mint-faint)}
|
||||
.split .sa{flex:2;background:var(--muted-soft);color:var(--muted)}
|
||||
section[id]{scroll-margin-top:84px} /* anchored menu targets clear the sticky nav */
|
||||
/* ticker */
|
||||
.ticker{overflow:hidden;contain:layout paint;border-top:1px solid var(--line);border-bottom:1px solid var(--line);
|
||||
background:var(--mint-faint);white-space:nowrap;padding:10px 0;
|
||||
-webkit-mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent);
|
||||
mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent)}
|
||||
.ticker .inner{display:inline-block;font-family:var(--mono);font-size:12.5px;padding-left:100%;animation:tick 120s linear infinite}
|
||||
.ticker .inner span{margin-right:48px;color:var(--muted)}
|
||||
.ticker .inner span b{color:var(--mint);font-weight:600}
|
||||
@keyframes tick{to{transform:translateX(-100%)}}
|
||||
@media(prefers-reduced-motion:reduce){.ticker .inner{animation:none;padding-left:0}}
|
||||
/* cards / tables / feed (inner pages) */
|
||||
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:24px;margin:0 0 16px}
|
||||
.card:hover{border-color:var(--line-strong)}
|
||||
.grid{display:grid;gap:16px}
|
||||
.grid>*,.flank>*,.story>*{min-width:0} /* let grid children shrink so inner tablewraps scroll instead of widening the page */
|
||||
@media(min-width:760px){.grid.c3{grid-template-columns:1fr 1fr 1fr}.grid.c2{grid-template-columns:1fr 1fr}}
|
||||
table{width:100%;border-collapse:collapse;font-size:15px}
|
||||
th,td{text-align:left;padding:12px 14px;border-bottom:1px solid var(--line);vertical-align:middle}
|
||||
th{color:var(--muted);font-size:11.5px;text-transform:uppercase;letter-spacing:.1em;font-family:var(--disp)}
|
||||
td.num,th.num{font-variant-numeric:tabular-nums}
|
||||
tr:last-child td{border-bottom:0}
|
||||
.tablewrap{overflow-x:auto}
|
||||
.feed{font-family:var(--mono);font-size:13.5px;line-height:1.7}
|
||||
.feed .row{padding:9px 14px;border-bottom:1px solid var(--line);display:flex;gap:10px;align-items:baseline;flex-wrap:wrap}
|
||||
.feed .row:first-child{background:var(--mint-soft)}
|
||||
.feed .row .when{font-family:var(--mono);font-size:11px;color:var(--muted);white-space:nowrap;min-width:92px}
|
||||
.feed .t-Purchase,.feed .t-AwardPaid{color:var(--mint-hi)}
|
||||
.feed .t-TierPaid{color:var(--mint)}
|
||||
.feed .t-AdminPaid{color:var(--muted)}
|
||||
.feed .tx a{color:var(--muted);font-size:12px}
|
||||
.badge{display:inline-block;background:var(--mint-soft);color:var(--mint);border:1px solid var(--mint-line);
|
||||
border-radius:999px;padding:3px 13px;font-size:12px;font-weight:700}
|
||||
.spend-banner{background:linear-gradient(160deg,var(--gold-soft),var(--gold-faint));border-color:var(--gold-line);text-align:center;padding:22px 20px}
|
||||
.spend-banner .lbl{font-family:var(--disp);font-size:13px;letter-spacing:.14em;text-transform:uppercase;color:var(--gold-2)}
|
||||
.spend-banner .big{font-family:var(--disp);font-size:clamp(40px,6vw,64px);font-weight:800;color:var(--gold-2);line-height:1.05;margin:6px 0 4px;font-variant-numeric:tabular-nums}
|
||||
.spend-banner .big .unit{font-size:20px;font-weight:700;color:var(--ink)}
|
||||
.spend-banner .sub{color:var(--ink);font-size:15px}
|
||||
.spend-banner .rates{display:flex;gap:8px 18px;flex-wrap:wrap;justify-content:center;margin-top:12px;font-size:12.5px;color:var(--muted)}
|
||||
.spend-banner .rates b{color:var(--ink)}
|
||||
.boot-spin{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;min-height:60vh}
|
||||
.boot-spin .ring{width:46px;height:46px;border-radius:50%;border:4px solid var(--mint-soft-2);border-top-color:var(--mint);animation:bootspin .9s linear infinite}
|
||||
@keyframes bootspin{to{transform:rotate(360deg)}}
|
||||
.bo-top{flex-wrap:wrap}
|
||||
.ad-strip{flex:1 1 100%;font-size:13.5px;padding:8px 0 2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.ad-strip a{color:var(--ink)}
|
||||
.ad-strip b{color:var(--mint)}
|
||||
.ad-foot{text-align:center}
|
||||
.pv{border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:0 0 16px;background:var(--ground-soft)}
|
||||
.pv-head b{display:block;font-size:18px;margin:4px 0 2px}
|
||||
.done-big{display:flex;flex-direction:column;align-items:center;gap:6px;padding:26px 16px;text-align:center}
|
||||
.done-big .tick{width:84px;height:84px;border-radius:50%;display:grid;place-items:center;font-size:48px;font-weight:800;color:var(--mint-ink);background:var(--mint);box-shadow:0 0 0 10px rgba(67,232,195,.15),0 10px 30px rgba(67,232,195,.35)}
|
||||
.done-big b{font-family:var(--disp);font-size:22px;margin-top:8px}
|
||||
.badge.amber{background:var(--muted-soft);border-color:var(--muted-line);color:var(--muted)}
|
||||
/* faq */
|
||||
details{border:1px solid var(--line);border-radius:14px;margin:0 0 10px;background:var(--panel)}
|
||||
details[open]{border-color:var(--mint-line)}
|
||||
summary{cursor:pointer;padding:16px 20px;font-weight:700;font-family:var(--disp);font-size:15px;list-style:none}
|
||||
summary::before{content:"+";color:var(--mint);font-weight:800;margin-right:12px}
|
||||
details[open] summary::before{content:"−"}
|
||||
details p{margin:0;padding:0 20px 18px 42px;color:var(--muted);font-size:14.5px}
|
||||
/* closing cta card */
|
||||
.closer{position:relative;display:grid;gap:26px;align-items:center;grid-template-columns:1fr;
|
||||
padding:44px 36px;border-radius:24px;overflow:hidden;margin:80px 0 0;
|
||||
background:var(--panel-grad-deep);border:1px solid var(--line-strong)}
|
||||
@media(min-width:880px){.closer{grid-template-columns:1.2fr .8fr}}
|
||||
.closer::before{content:"";position:absolute;width:460px;height:460px;right:-140px;top:-260px;border-radius:50%;
|
||||
background:radial-gradient(circle,rgba(67,232,195,.2),transparent 65%);pointer-events:none}
|
||||
.closer h2{margin:0 0 12px}
|
||||
/* footer + ghost wordmark */
|
||||
footer{border-top:1px solid var(--line);margin-top:90px;padding:34px 0 0;color:var(--muted);font-size:13.5px;overflow:hidden}
|
||||
.ghost{font-family:var(--disp);font-weight:800;font-size:clamp(64px,13vw,170px);line-height:.9;text-align:center;
|
||||
margin:34px 0 -20px;letter-spacing:-.02em;user-select:none;
|
||||
background:linear-gradient(180deg,rgba(67,232,195,.14),transparent 78%);
|
||||
-webkit-background-clip:text;background-clip:text;color:transparent;white-space:nowrap}
|
||||
/* misc */
|
||||
#status{position:fixed;left:50%;transform:translateX(-50%);bottom:22px;background:var(--panel-solid);
|
||||
border:1px solid var(--line-strong);border-radius:14px;padding:13px 22px;font-size:14px;max-width:90vw;z-index:30;
|
||||
box-shadow:0 12px 40px rgba(0,0,0,.55)}
|
||||
#status.ok{border-color:var(--mint)}
|
||||
#status.bad{border-color:var(--bad)}
|
||||
input,select,textarea{background:var(--field-bg);border:1px solid var(--line-strong);color:var(--ink);border-radius:11px;
|
||||
padding:11px 14px;font-size:14.5px;font-family:inherit}
|
||||
input[type=range]{padding:0;border:0;background:transparent;accent-color:var(--mint);height:28px;vertical-align:middle}
|
||||
input:focus,select:focus,textarea:focus{border-color:var(--mint)}
|
||||
textarea{resize:vertical;font:inherit}
|
||||
:focus-visible{outline:2px solid var(--mint);outline-offset:2px}
|
||||
.hero-note{font-family:var(--mono);font-size:12px;color:var(--muted);margin-top:26px}
|
||||
/* ── member back-office shell ─────────────────────────── */
|
||||
.bo-body{background:var(--ground)}
|
||||
.bo{display:grid;grid-template-columns:236px 1fr;min-height:100vh}
|
||||
.bo-side{position:sticky;top:0;height:100vh;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none;display:flex;flex-direction:column;gap:22px;
|
||||
padding:22px 16px;background:var(--side-bg);border-right:1px solid var(--line)}
|
||||
.bo-side .logo{font-size:19px;padding:0 8px}
|
||||
.bo-menu{display:flex;flex-direction:column;gap:4px}
|
||||
.bo-menu button{display:flex;align-items:center;gap:11px;background:transparent;border:0;color:var(--muted);
|
||||
font:600 14px var(--disp);padding:11px 12px;border-radius:11px;cursor:pointer;text-align:left;
|
||||
border-left:3px solid transparent}
|
||||
.bo-menu a{display:flex;align-items:center;gap:11px;color:var(--muted);font:600 14px var(--disp);padding:11px 12px;border-radius:11px;text-align:left;border-left:3px solid transparent;text-decoration:none}
|
||||
.bo-menu a:hover{color:var(--ink);background:var(--mint-faint)}
|
||||
.bo-menu a svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
|
||||
.bo-menu button svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
|
||||
.bo-menu button:hover{color:var(--ink);background:var(--mint-faint)}
|
||||
.bo-menu button.on{color:var(--mint);background:var(--mint-soft);border-left-color:var(--mint)}
|
||||
.bo-links{display:flex;flex-direction:column;gap:2px;padding:14px 12px;border-top:1px solid var(--line)}
|
||||
.bo-cap{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
|
||||
.bo-links a{color:var(--muted);font-size:13.5px;padding:5px 0}
|
||||
.bo-links a:hover{color:var(--ink);text-decoration:none}
|
||||
.bo-foot{margin-top:auto;padding:14px 12px 0;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:6px;overflow-wrap:anywhere}
|
||||
.bo-main{min-width:0;display:flex;flex-direction:column}
|
||||
.bo-side::-webkit-scrollbar{width:0;height:0;display:none}
|
||||
.bo-pagefoot{margin-top:auto;padding:22px 26px;border-top:1px solid var(--line);display:flex;gap:20px;flex-wrap:wrap;justify-content:center;font-size:13px}
|
||||
.bo-pagefoot a{color:var(--muted)}
|
||||
.bo-pagefoot a:hover{color:var(--ink);text-decoration:none}
|
||||
.bo-top{display:flex;align-items:center;gap:16px;padding:16px 26px;border-bottom:1px solid var(--line);
|
||||
background:var(--nav-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}
|
||||
.bo-top h2{font-size:20px}
|
||||
#boBurger{display:none;background:transparent;border:1px solid var(--line-strong);color:var(--ink);
|
||||
border-radius:9px;font-size:17px;padding:5px 11px;cursor:pointer}
|
||||
.bo-rehearsal{margin-left:auto;color:var(--muted)}
|
||||
.bo-rehearsal b{color:var(--mint)}
|
||||
.bo-content{padding:26px;max-width:1060px;width:100%}
|
||||
@media(max-width:959px){
|
||||
.bo{grid-template-columns:1fr}
|
||||
.bo-side{position:fixed;left:0;top:0;bottom:0;width:250px;z-index:20;transform:translateX(-100%);
|
||||
transition:transform .22s ease;height:100dvh}
|
||||
.bo.side-open .bo-side{transform:none;box-shadow:0 0 60px rgba(0,0,0,.6)}
|
||||
#boBurger{display:block}
|
||||
.bo-content{padding:18px}
|
||||
}
|
||||
/* ── promo banners ── */
|
||||
.promo-banners{display:flex;flex-direction:column;gap:10px;margin-top:12px}
|
||||
.pb-note{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 14px;padding:10px 16px 12px;font-size:13.5px;color:var(--muted);border-bottom:1px solid var(--line)}
|
||||
.pb-note b.mono{color:var(--ink);font-family:var(--mono);font-size:12.5px;word-break:break-all}
|
||||
.pb-acc{margin:0}
|
||||
.pb-acc>summary{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:13px 16px;font-size:14.5px}
|
||||
.pb-acc>summary::before{content:none}
|
||||
.pb-acc>summary>span:first-child::before{content:"+";color:var(--mint);font-weight:800;margin-right:10px}
|
||||
.pb-acc[open]>summary>span:first-child::before{content:"−"}
|
||||
.pb-acc .pb-count{font-family:var(--mono);font-size:11px;color:var(--muted);white-space:nowrap}
|
||||
.pb-acc .pb-grid{display:flex;flex-direction:column;gap:14px;padding:0 16px 16px}
|
||||
.pb-item img{max-width:100%;border-radius:8px;border:1px solid var(--line-strong);display:block}
|
||||
.pb-item .pb-row{display:flex;gap:10px;align-items:center;margin-top:6px;flex-wrap:wrap}
|
||||
.pb-item .pb-size{font-family:var(--mono);font-size:11px;color:var(--muted)}
|
||||
/* ── featured day-slot picker ── */
|
||||
.feat-days{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.feat-day{flex:0 0 auto;min-width:82px;padding:8px 10px;border:1px solid var(--line-strong);border-radius:10px;
|
||||
background:var(--panel);cursor:pointer;text-align:center}
|
||||
.feat-day.on{border-color:var(--mint);box-shadow:0 0 0 1px var(--mint)}
|
||||
.feat-day.full{opacity:.45;cursor:not-allowed}
|
||||
.feat-day .fd-day{font-weight:700;font-size:12px}
|
||||
.feat-day .fd-occ{font-family:var(--mono);font-size:11px;color:var(--muted)}
|
||||
.feat-day.open2 .fd-occ{color:var(--mint)}
|
||||
/* ── featured rotation strip ── */
|
||||
.feat-top{max-width:760px;margin:16px auto;border:1px solid var(--amber-line)}
|
||||
.feat-strip{display:flex;justify-content:center;margin-top:10px}
|
||||
.feat-strip a{max-width:728px;width:100%;display:flex;justify-content:space-between;gap:10px;padding:11px 14px;border-radius:10px;
|
||||
background:var(--panel);border:1px solid var(--amber);color:var(--ink);text-decoration:none;font-weight:600}
|
||||
.feat-strip a:hover{border-color:var(--gold);box-shadow:0 0 0 1px var(--amber-line)}
|
||||
.feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap}
|
||||
.feat-strip .by{font-size:12px;color:var(--muted);font-weight:500;white-space:nowrap}
|
||||
/* ── achievement badges ── */
|
||||
.badges{display:flex;gap:18px;flex-wrap:wrap;margin-top:12px}
|
||||
.badge-a{display:flex;flex-direction:column;align-items:center;gap:6px;width:150px;text-align:center}
|
||||
.badge-a .badge-img{width:150px;height:150px;border-radius:14px;object-fit:cover;border:1px solid var(--line-strong)}
|
||||
.badge-a.locked .badge-img{filter:grayscale(.85) brightness(.5);opacity:.7}
|
||||
.badge-a .medal{width:76px;height:76px;border-radius:50%;display:grid;place-items:center;position:relative;
|
||||
background:radial-gradient(circle at 50% 35%,var(--mint-soft-2),var(--panel-solid));
|
||||
border:2px solid var(--mint);box-shadow:0 0 18px rgba(67,232,195,.3)}
|
||||
.badge-a.locked .medal{background:var(--muted-soft);border-color:var(--line-strong);box-shadow:none;filter:grayscale(1);opacity:.5}
|
||||
.badge-a .medal svg{width:38px;height:38px;stroke:var(--mint);fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
||||
.badge-a.locked .medal svg{stroke:var(--muted)}
|
||||
.badge-a .bl{font-size:12px;font-weight:700;line-height:1.2}
|
||||
.badge-a .bs{font-size:10.5px;color:var(--muted)}
|
||||
.badge-a .share{font-size:11px;color:var(--mint);cursor:pointer;background:none;border:0;padding:0;text-decoration:underline}
|
||||
/* ── "Your next move": milestone stepper card ── */
|
||||
.next-card{position:relative;overflow:hidden;border-color:var(--mint-line)}
|
||||
.next-card::before{content:"";position:absolute;inset:0;pointer-events:none;background:
|
||||
radial-gradient(420px 150px at 10% 0%,rgba(67,232,195,.12),transparent 70%),
|
||||
radial-gradient(360px 130px at 90% 100%,rgba(157,125,255,.09),transparent 70%)}
|
||||
.nc-head{display:flex;gap:14px;align-items:flex-start;position:relative}
|
||||
.nc-head .pl{flex:0 0 auto;width:44px;height:44px;border-radius:12px;display:grid;place-items:center;
|
||||
background:var(--mint-soft-2);border:1px solid var(--mint-line)}
|
||||
.nc-head .pl svg{width:20px;height:20px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
|
||||
.nc-steps{display:flex;margin-top:20px;position:relative;flex-wrap:wrap;row-gap:14px}
|
||||
.nc-step{flex:1;min-width:88px;display:flex;flex-direction:column;align-items:center;gap:7px;
|
||||
position:relative;text-align:center;padding:0 4px}
|
||||
.nc-step::before{content:"";position:absolute;top:13px;left:-50%;width:100%;height:2px;background:var(--line-strong)}
|
||||
.nc-step:first-child::before{display:none}
|
||||
.nc-step.hit::before{background:linear-gradient(90deg,var(--mint),var(--mint-hi))}
|
||||
.nc-step .dot{width:27px;height:27px;border-radius:50%;display:grid;place-items:center;font-size:12px;
|
||||
font-weight:800;background:var(--panel-solid);border:2px solid var(--line-strong);color:var(--muted);
|
||||
position:relative;z-index:1}
|
||||
.nc-step.hit .dot{background:var(--mint);border-color:var(--mint);color:var(--mint-ink);
|
||||
box-shadow:0 0 14px rgba(67,232,195,.35)}
|
||||
.nc-step.cur .dot{border-color:var(--amber);color:var(--amber);box-shadow:0 0 12px rgba(255,178,56,.4)}
|
||||
.nc-step .lb{font-size:12px;font-weight:700;line-height:1.25}
|
||||
.nc-step .lb i{display:block;font-style:normal;font-weight:500;font-size:10.5px;color:var(--muted);margin-top:2px}
|
||||
.nc-step.cur .lb{color:var(--amber)}
|
||||
/* ── overview v3: stat cards w/ plates+chips, hand-rolled charts ── */
|
||||
.statx{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);
|
||||
border-radius:var(--radius);padding:18px;position:relative;overflow:hidden}
|
||||
.statx .pl{flex:0 0 auto;width:46px;height:46px;border-radius:13px;display:grid;place-items:center;
|
||||
background:var(--mint-soft);border:1px solid var(--mint-line)}
|
||||
.statx .pl svg{width:22px;height:22px;stroke:var(--mint);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
|
||||
.statx.c-cyan .pl{background:var(--cyan-soft);border-color:var(--cyan-line)}
|
||||
.statx.c-cyan .pl svg{stroke:var(--cyan)}
|
||||
.statx.c-violet .pl{background:var(--violet-soft);border-color:var(--violet-line)}
|
||||
.statx.c-violet .pl svg{stroke:var(--violet)}
|
||||
.statx.c-amber .pl{background:var(--amber-soft);border-color:var(--amber-line)}
|
||||
.statx.c-amber .pl svg{stroke:var(--amber)}
|
||||
.statx .nv{font-family:var(--disp);font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1}
|
||||
.statx .lb{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;margin-top:2px}
|
||||
.chip{display:inline-block;margin-top:7px;font-size:11.5px;font-weight:700;border-radius:999px;padding:2px 10px;
|
||||
background:var(--mint-soft);color:var(--mint)}
|
||||
.chip.flat{background:var(--muted-soft);color:var(--muted)}
|
||||
.chip.warm{background:var(--amber-soft);color:var(--amber)}
|
||||
.card-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
|
||||
.card-head .sub{font-size:12px;color:var(--muted)}
|
||||
/* dismiss on the announcement cards at the top of the Overview (Marty, 2026-09-22):
|
||||
hides the card for the rest of this browser session, back at the next sign-in */
|
||||
.card-x{flex:none;align-self:center;margin:-4px -6px 0 2px;width:28px;height:28px;border-radius:50%;
|
||||
border:1px solid var(--line);background:transparent;color:var(--muted);font-size:19px;line-height:1;
|
||||
cursor:pointer;display:grid;place-items:center;padding:0}
|
||||
.card-x:hover{border-color:var(--line-strong);color:var(--ink);background:var(--muted-soft)}
|
||||
/* bar chart (divs, real data) */
|
||||
.barchart{display:flex;align-items:flex-end;gap:6px;height:120px;margin-top:14px}
|
||||
.barchart .bar{flex:1;min-width:6px;background:linear-gradient(180deg,var(--mint),var(--mint-line));
|
||||
border-radius:5px 5px 2px 2px;position:relative;transition:height .5s ease}
|
||||
.barchart .bar.alt{background:linear-gradient(180deg,var(--violet),var(--violet-line))}
|
||||
.barchart .bar:hover::after{content:attr(data-v);position:absolute;bottom:calc(100% + 4px);left:50%;
|
||||
transform:translateX(-50%);background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:7px;
|
||||
padding:2px 8px;font-family:var(--mono);font-size:11px;white-space:nowrap;z-index:3}
|
||||
.barchart .bar.empty{background:var(--muted-soft);height:4px!important}
|
||||
.chart-x{display:flex;gap:6px;margin-top:6px}
|
||||
.chart-x span{flex:1;text-align:center;font-family:var(--mono);font-size:10px;color:var(--muted);overflow:hidden;white-space:nowrap}
|
||||
/* donut + ring (SVG) */
|
||||
.donut-wrap{display:flex;gap:22px;align-items:center;margin-top:10px;flex-wrap:wrap}
|
||||
.donut-legend{display:flex;flex-direction:column;gap:8px;font-size:13px}
|
||||
.donut-legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:8px}
|
||||
.donut-center{font-family:var(--disp);font-weight:800}
|
||||
/* ── login ad interstitial: sponsor opens in a new tab, timer runs here ── */
|
||||
.lgate{position:fixed;inset:0;z-index:90;display:flex;flex-direction:column;background:var(--ground)}
|
||||
.lgate-bar{display:flex;align-items:center;gap:14px;padding:10px 16px;background:var(--panel-solid);
|
||||
border-bottom:1px solid var(--line);flex-wrap:wrap}
|
||||
.lg-brand{font-family:var(--disp);font-weight:800;font-size:15px;white-space:nowrap}
|
||||
.lg-brand em{color:var(--mint);font-style:normal}
|
||||
.lgate-note{flex:1;min-width:140px}
|
||||
.lg-timer{font-weight:700;font-size:14px;border:1px solid var(--line-strong);border-radius:999px;
|
||||
padding:5px 14px;min-width:150px;text-align:center}
|
||||
.lg-timer.done{color:var(--mint);border-color:var(--mint)}
|
||||
.lgate-body{flex:1;display:grid;place-items:center;padding:24px;overflow:auto}
|
||||
.lgate-card{max-width:560px;text-align:center}
|
||||
.lgate-card img{max-width:100%;max-height:50vh;border-radius:12px;border:1px solid var(--line-strong)}
|
||||
#lgCreative .lg-linkcard{display:inline-block;background:var(--panel);border:1px solid var(--line-strong);
|
||||
border-radius:14px;padding:22px 28px;font-family:var(--disp);font-weight:700;font-size:18px;overflow-wrap:anywhere}
|
||||
/* ── welcome tour (gauntlet): framed line sites + countdown ── */
|
||||
.lgate-frame{flex:1;border:0;width:100%;background:#fff;min-height:0}
|
||||
.ggmeta{padding:8px 16px;background:var(--panel-solid);border-bottom:1px solid var(--line)}
|
||||
/* ── bio header (wall/profile page) ── */
|
||||
.bio-head{display:flex;gap:22px;align-items:center;flex-wrap:wrap;padding:8px 0 4px}
|
||||
.bio-avatar{width:96px;height:96px;border-radius:50%;object-fit:cover;border:2px solid var(--mint);flex:0 0 auto}
|
||||
.bio-badge{width:74px;height:74px;border-radius:12px;object-fit:cover;flex:0 0 auto;border:1px solid var(--line-strong)}
|
||||
.btn.disabled{opacity:.45;pointer-events:none;filter:grayscale(.3)}
|
||||
.bio-meta{flex:1;min-width:220px}
|
||||
.bio-socials{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
|
||||
.bio-video{margin:14px auto 8px;max-width:760px}
|
||||
@media (max-width:720px){.bio-head{flex-direction:column;align-items:center;text-align:center;gap:14px}.bio-head .bio-avatar,.bio-head .bio-badge{margin:0 auto}.bio-meta{min-width:0;width:100%}.bio-socials{justify-content:center}.bio-qr{margin:4px auto 0}.bio-video .eyebrow{text-align:center}}
|
||||
.bio-video iframe,.bio-video video{width:100%;aspect-ratio:16/9;border:1px solid var(--line-strong);border-radius:16px;background:#000;display:block}
|
||||
.bio-socials a{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:var(--mint);border:1px solid var(--line-strong);
|
||||
border-radius:999px;padding:4px 12px 4px 9px;text-decoration:none}
|
||||
.bio-socials a svg{flex:0 0 auto}
|
||||
.bio-socials a:hover{border-color:var(--mint)}
|
||||
.bio-qr{flex:0 0 auto;background:var(--panel);border:1px solid var(--line-strong);border-radius:14px;padding:10px}
|
||||
.bio-qr img{display:block;border-radius:8px;background:#eef7f3}
|
||||
/* ── wall page ── */
|
||||
.wall-card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:16px;text-align:center}
|
||||
.wall-card img{max-width:100%;border-radius:10px;border:1px solid var(--line-strong)}
|
||||
.wall-pos{font-family:var(--mono);font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;margin-bottom:8px}
|
||||
.wc-creative img{max-width:100%;border-radius:10px;border:1px solid var(--line-strong)}
|
||||
.wc-action{margin-top:10px;min-height:32px;display:flex;justify-content:center;align-items:center}
|
||||
.wc-check{color:var(--mint);font-weight:800;border:1px solid var(--mint);border-radius:999px;padding:4px 14px;
|
||||
box-shadow:0 0 14px rgba(67,232,195,.3)}
|
||||
.wc-timer{color:var(--amber);font-weight:700;font-family:var(--mono);font-size:13px}
|
||||
/* ── modal (sponsor message) ── */
|
||||
.modal-back{position:fixed;inset:0;z-index:100;background:rgba(2,6,5,.72);display:flex;align-items:center;justify-content:center;padding:20px}
|
||||
.modal-card{background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:var(--radius);
|
||||
padding:24px;max-width:520px;width:100%;box-shadow:0 20px 60px rgba(0,0,0,.5)}
|
||||
/* ── downline lineage list ── */
|
||||
.lin-lvl{margin:10px 0}
|
||||
.lin-lvl>.cap{display:inline-block;font-size:13px;font-weight:800;text-transform:uppercase;letter-spacing:.06em;
|
||||
color:var(--mint);background:var(--mint-soft);border:1px solid var(--line-strong);border-radius:8px;padding:4px 10px;margin-bottom:10px}
|
||||
.lin-row{display:grid;grid-template-columns:minmax(110px,1.2fr) minmax(0,2fr) auto auto auto auto;gap:6px 14px;
|
||||
align-items:center;padding:9px 0;border-bottom:1px solid var(--line)}
|
||||
.lin-row .nm{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.lin-row .em{font-size:12px;color:var(--mint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.lin-row .id{font-family:var(--mono);font-size:11px;color:var(--muted)}
|
||||
.lin-row .sp{display:block;font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .lin-row .em{min-width:0}
|
||||
.lin-row .dt{font-size:12px;color:var(--muted);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
||||
.lin-row .chat-msg-btn{justify-self:end}
|
||||
.lin-row .sp.wrap{white-space:normal;line-height:1.7}
|
||||
/* list toolbar: sort + filter chips shared by the tank, roster and downline (2026-09-29) */
|
||||
.lst-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin:4px 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:var(--ink-faint)}
|
||||
.lst-q{flex:1 1 100%;min-width:0;background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:6px 10px;font-size:13px}
|
||||
.lst-sort{font-size:12px;color:var(--muted);display:inline-flex;align-items:center;gap:6px}
|
||||
.lst-sort select{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 8px;font-size:12.5px}
|
||||
.lst-dir{background:transparent;color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 9px;font-size:12px;cursor:pointer;white-space:nowrap}
|
||||
.lst-chips{display:flex;flex-wrap:wrap;gap:6px}
|
||||
.lst-chip{font-size:12px;color:var(--muted);background:transparent;border:1px solid var(--line);border-radius:999px;padding:3px 10px;cursor:pointer;white-space:nowrap}
|
||||
.lst-chip.on{border-color:var(--mint);color:var(--ink);background:var(--mint-soft)}
|
||||
.lst-n{margin-left:auto;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
|
||||
.roster-em{color:var(--mint);word-break:break-all;margin-top:2px}
|
||||
.lst-copy{background:transparent;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:0 6px;font-size:11px;cursor:pointer;margin-left:4px}
|
||||
.lchip{display:inline-block;font-size:11.5px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:1px 8px;white-space:nowrap;vertical-align:middle}
|
||||
.lchip.on{border-color:var(--mint-line);color:var(--ink)} .lchip.warn{border-color:var(--gold-line);color:var(--gold)}
|
||||
.roster td:nth-child(3){white-space:normal;line-height:1.8}
|
||||
.lin-row .lin-act-btn{justify-self:end;white-space:nowrap}
|
||||
.lin-act{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 10px 10px;margin:-1px 0 6px;border-bottom:1px solid var(--line);background:var(--ink-faint);border-radius:0 0 10px 10px}
|
||||
.lin-chip{font-size:12px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:3px 10px;white-space:nowrap} .lin-chip b{font-weight:600;color:var(--ink);margin-right:5px} .lin-chip.on{border-color:var(--mint-line);color:var(--ink)} .lin-chip.warn{border-color:var(--gold-line)}
|
||||
.lin-verdict{margin-left:auto;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)} .lin-verdict.on{color:var(--mint)}
|
||||
@media (max-width:560px){.lin-chip{white-space:normal}.lin-act{padding:8px 4px 10px}}
|
||||
@media (max-width:560px){.lin-row{grid-template-columns:1fr auto;gap:2px 10px}
|
||||
.lin-row .em{grid-column:1/2}.lin-row .dt{grid-column:1/2;text-align:left}.lin-row .chat-msg-btn{grid-row:1/3;grid-column:2}
|
||||
.lin-row .lin-act-btn{grid-column:2;grid-row:3/5}.lin-row:not(:has(.chat-msg-btn)) .lin-act-btn{grid-row:1/3}}
|
||||
/* ── solo composer: toolbar + contenteditable editor ── */
|
||||
.ed-bar{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}
|
||||
.ed-bar button{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;
|
||||
padding:5px 11px;font-size:12.5px;cursor:pointer}
|
||||
.ed-bar button:hover,.ed-bar button:focus-visible{border-color:var(--mint);outline:none}
|
||||
.ed-body{background:var(--field-bg);border:1px solid var(--line-strong);border-radius:11px;
|
||||
min-height:180px;padding:12px 14px;outline:none;overflow-wrap:anywhere}
|
||||
.ed-body:focus{border-color:var(--mint)}
|
||||
.ed-body:empty::before{content:attr(data-ph);color:var(--muted)}
|
||||
.ed-body img,.ed-body video,.ib-rich img,.ib-rich video{max-width:100%;border-radius:10px;margin:6px 0;display:block}
|
||||
.ed-sep{width:1px;align-self:stretch;background:var(--line-strong);margin:2px 3px}
|
||||
.ed-bar sub{font-size:9px}
|
||||
textarea.ed-body{width:100%;min-height:180px;resize:vertical}
|
||||
.ed-body a,.ib-rich a{color:var(--mint)}
|
||||
.ed-body h3,.ib-rich h3,.ed-body h4,.ib-rich h4{margin:.5em 0 .3em}
|
||||
.ed-media{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:10px 0 0}
|
||||
/* ── earn sub-tabs (Watch ads | Inbox) ── */
|
||||
.subtabs{display:flex;gap:6px;margin:0 0 16px;border-bottom:1px solid var(--line);padding-bottom:0}
|
||||
.subtab{background:none;border:0;border-bottom:2px solid transparent;color:var(--muted);
|
||||
font:inherit;font-weight:700;font-size:14px;padding:8px 14px;cursor:pointer;margin-bottom:-1px;
|
||||
display:inline-flex;align-items:center;gap:7px}
|
||||
.subtab:hover{color:var(--ink)}
|
||||
.subtab.on{color:var(--mint);border-bottom-color:var(--mint)}
|
||||
.subtab .pill{position:static}
|
||||
/* ── solo-ads inbox ── */
|
||||
.bo-menu .pill{margin-left:auto;background:var(--amber);color:var(--amber-ink);font-size:11px;font-weight:800;
|
||||
border-radius:999px;padding:1px 8px;line-height:1.5}
|
||||
.ib-row{display:flex;gap:10px;align-items:baseline;padding:11px 6px;border-bottom:1px solid var(--line);
|
||||
cursor:pointer;flex-wrap:wrap}
|
||||
.ib-row:hover{background:var(--mint-faint)}
|
||||
.ib-row .sub{font-weight:700;flex:1;min-width:160px;overflow-wrap:anywhere}
|
||||
.ib-row.unread .sub{color:var(--mint)}
|
||||
.ib-row .from,.ib-row .when{font-size:12px;color:var(--muted);white-space:nowrap}
|
||||
.cta-need{box-shadow:0 0 0 2px var(--amber),0 0 16px rgba(255,178,56,.4)!important;animation:ctapulse 1.6s ease-in-out infinite}
|
||||
@keyframes ctapulse{50%{box-shadow:0 0 0 2px var(--amber),0 0 24px rgba(255,178,56,.65)!important}}
|
||||
@media (prefers-reduced-motion:reduce){.cta-need{animation:none}}
|
||||
/* ── back-office accent family: green leads, cyan/violet/amber season the cards ── */
|
||||
.bo .stats .stat:nth-child(2) .n{color:var(--cyan)}
|
||||
.bo .stats .stat:nth-child(2)::before{background:linear-gradient(90deg,transparent,var(--cyan),transparent)}
|
||||
.bo .stats .stat:nth-child(3) .n{color:var(--violet)}
|
||||
.bo .stats .stat:nth-child(3)::before{background:linear-gradient(90deg,transparent,var(--violet),transparent)}
|
||||
.bo .stats .stat:nth-child(4) .n{color:var(--amber)}
|
||||
.bo .stats .stat:nth-child(4)::before{background:linear-gradient(90deg,transparent,var(--amber),transparent)}
|
||||
.bo .card h3::before{content:"";display:inline-block;width:9px;height:9px;border-radius:2.5px;
|
||||
background:var(--mint);margin-right:10px;transform:rotate(45deg);vertical-align:1px}
|
||||
#pane-line .card h3::before{background:var(--cyan)}
|
||||
#pane-buy .card h3::before,#pane-campaigns .card h3::before{background:var(--amber)}
|
||||
#pane-earn .card h3::before,#pane-earnings .card h3::before{background:var(--violet)}
|
||||
#pane-promo .card h3::before{background:var(--cyan)}
|
||||
#pane-wallet .card h3::before,#pane-profile .card h3::before{background:var(--mint)}
|
||||
.bo .card{background:var(--panel-grad)}
|
||||
#pane-line .qualbar,#nextCard{border-left:3px solid var(--mint-line)}
|
||||
.promo-block{background:var(--ground-soft);border:1px solid var(--line);border-radius:12px;
|
||||
padding:14px 16px;margin:0 0 12px;font-size:13.5px;line-height:1.6;white-space:pre-wrap}
|
||||
.promo-block .btn{margin-top:10px}
|
||||
/* back-office polish: pane transitions, quick actions */
|
||||
@media(prefers-reduced-motion:no-preference){
|
||||
.pane:not([hidden]){animation:panein .25s ease}
|
||||
@keyframes panein{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
||||
}
|
||||
.qa{display:flex;flex-direction:column;gap:8px}
|
||||
.qa button{display:flex;align-items:center;gap:10px;background:var(--mint-faint);border:1px solid var(--line);
|
||||
color:var(--ink);font:600 14px var(--disp);padding:11px 14px;border-radius:11px;cursor:pointer;text-align:left;
|
||||
transition:border-color .15s ease,background .15s ease}
|
||||
.qa button:hover{border-color:var(--mint);background:var(--mint-soft)}
|
||||
/* member sub-navigation */
|
||||
.subnav{display:flex;gap:6px;flex-wrap:wrap;background:var(--pill-bg);border:1px solid var(--line);
|
||||
border-radius:999px;padding:6px 8px;width:fit-content;margin:0 0 22px}
|
||||
.subnav button{background:transparent;border:0;color:var(--muted);font:600 13.5px var(--disp);
|
||||
padding:8px 16px;border-radius:999px;cursor:pointer}
|
||||
.subnav button:hover{color:var(--ink)}
|
||||
.subnav button.on{color:var(--mint-ink);background:var(--mint)}
|
||||
/* member dashboard: qualification progress + roster */
|
||||
.qualbar{position:relative;height:12px;border-radius:999px;background:var(--ground-soft);border:1px solid var(--line-strong);
|
||||
margin:26px 0 30px;max-width:520px}
|
||||
.qualbar #qualFill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--mint),var(--mint-hi));
|
||||
box-shadow:0 0 18px rgba(67,232,195,.4);width:0;transition:width .6s ease}
|
||||
.qb-mark{position:absolute;top:16px;transform:translateX(-50%);font-family:var(--mono);font-size:11px;color:var(--muted);white-space:nowrap}
|
||||
.qb-mark.end{left:auto!important;right:0;transform:none} /* keeps the last label inside the card on mobile */
|
||||
#inviteLine,#pitchPreview{overflow-wrap:anywhere}
|
||||
img{max-width:100%}
|
||||
.roster{width:100%;border-collapse:collapse;font-size:13.5px}
|
||||
.roster td{padding:8px 10px;border-bottom:1px solid var(--line)}
|
||||
.roster td:first-child{font-family:var(--mono)}
|
||||
.roster tr:last-child td{border-bottom:0}
|
||||
/* chat widget */
|
||||
#iapChatBtn{position:fixed;right:20px;bottom:20px;z-index:40;width:56px;height:56px;border-radius:50%;
|
||||
border:0;background:var(--mint);color:var(--mint-ink);font-size:24px;cursor:pointer;
|
||||
box-shadow:0 8px 30px rgba(67,232,195,.4)}
|
||||
#iapChatBtn:hover{transform:scale(1.06)}
|
||||
#iapChatPanel{position:fixed;right:20px;bottom:88px;z-index:40;width:min(360px,calc(100vw - 40px));
|
||||
background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:18px;overflow:hidden;
|
||||
box-shadow:0 24px 70px rgba(0,0,0,.65);display:flex;flex-direction:column}
|
||||
.ch-head{padding:14px 16px;border-bottom:1px solid var(--line);font-family:var(--disp);position:relative}
|
||||
.ch-head .ch-sub{display:block;font-size:12px;color:var(--muted);font-family:"Segoe UI",system-ui,sans-serif}
|
||||
#iapChatClose{position:absolute;right:10px;top:10px;background:transparent;border:0;color:var(--muted);
|
||||
font-size:22px;cursor:pointer;line-height:1}
|
||||
.ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px}
|
||||
.ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%}
|
||||
.ch-m.bot{background:var(--mint-soft);border:1px solid var(--mint-line);align-self:flex-start}
|
||||
.ch-m.me{background:var(--muted-soft);border:1px solid var(--line);align-self:flex-end}
|
||||
.ch-m a{word-break:break-all}
|
||||
.ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line)}
|
||||
.ch-input input{flex:1;min-width:0}
|
||||
.ch-input button{background:var(--mint);color:var(--mint-ink);border:0;border-radius:10px;padding:0 16px;
|
||||
font-weight:700;cursor:pointer;font-family:var(--disp)}
|
||||
@media(prefers-reduced-motion:no-preference){
|
||||
.feed .row:first-child{animation:landed .9s ease}
|
||||
@keyframes landed{from{background:var(--mint-soft-2)}to{background:var(--mint-soft)}}
|
||||
}
|
||||
|
||||
/* ── Sponsor chat: FAB, slide-in drawer, threads, bubbles, presence ── */
|
||||
.bo-chat{display:flex;align-items:center}
|
||||
.bo-chat .pill{margin-left:auto;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--mint);
|
||||
color:var(--mint-ink);font:700 12px/20px var(--disp);text-align:center}
|
||||
.chat-drawer{position:fixed;right:0;top:0;bottom:0;width:380px;max-width:92vw;z-index:70;display:flex;flex-direction:column;
|
||||
background:var(--panel-solid);border-left:1px solid var(--line-strong);box-shadow:-16px 0 40px rgba(0,0,0,.45);
|
||||
transform:translateX(0);animation:chatIn .16s ease}
|
||||
@keyframes chatIn{from{transform:translateX(24px);opacity:.4}to{transform:translateX(0);opacity:1}}
|
||||
@media (prefers-reduced-motion:reduce){.chat-drawer{animation:none}.chat-fab{transition:none}}
|
||||
.chat-head{display:flex;align-items:center;gap:8px;padding:12px 12px;border-bottom:1px solid var(--line)}
|
||||
.chat-who{display:flex;flex-direction:column;line-height:1.15;min-width:0;flex:1}
|
||||
.chat-who b{font:700 15px var(--disp);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.chat-icon{background:none;border:0;color:var(--muted);font-size:26px;line-height:1;cursor:pointer;padding:0 6px}
|
||||
.chat-icon:hover{color:var(--ink)}
|
||||
.pres-dot{width:9px;height:9px;border-radius:50%;background:var(--muted);flex:0 0 auto}
|
||||
.pres-dot.on{background:var(--mint);box-shadow:0 0 8px var(--mint)}
|
||||
.chat-threads{flex:1;overflow:auto}
|
||||
.chat-thread{display:flex;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid var(--line);cursor:pointer}
|
||||
.chat-thread:hover{background:var(--mint-soft)}
|
||||
.chat-thread .ct-main{flex:1;min-width:0}
|
||||
.chat-thread .ct-name{font:700 14px var(--disp)}
|
||||
.chat-thread .ct-last{color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.chat-thread .ct-un{min-width:20px;height:20px;padding:0 5px;border-radius:10px;background:var(--mint);color:var(--mint-ink);
|
||||
font:700 12px/20px var(--disp);text-align:center}
|
||||
.chat-empty{padding:22px 16px;color:var(--muted);font-size:14px}
|
||||
.chat-convo{flex:1;display:flex;flex-direction:column;min-height:0}
|
||||
.chat-msgs{flex:1;overflow:auto;padding:14px;display:flex;flex-direction:column;gap:8px}
|
||||
.cbub{max-width:78%;padding:9px 12px;border-radius:14px;font-size:14px;line-height:1.4;white-space:pre-wrap;word-wrap:break-word}
|
||||
.cbub.them{align-self:flex-start;background:var(--panel);border:1px solid var(--line);border-bottom-left-radius:4px}
|
||||
.cbub.me{align-self:flex-end;background:var(--mint);color:var(--mint-ink);border-bottom-right-radius:4px}
|
||||
.cbub .ct-time{display:block;margin-top:4px;font-size:10.5px;opacity:.6}
|
||||
.chat-day{align-self:center;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.05em;margin:6px 0}
|
||||
.chat-banner{padding:8px 14px;border-top:1px solid var(--line);color:var(--muted);font-size:12.5px;background:var(--ground2)}
|
||||
.chat-compose{display:flex;gap:8px;padding:10px;border-top:1px solid var(--line);align-items:flex-end}
|
||||
.chat-compose textarea{flex:1;resize:vertical;min-height:44px;max-height:45vh;line-height:1.45;background:var(--ground2);border:1px solid var(--line);
|
||||
border-radius:12px;color:var(--ink);padding:9px 11px;font:400 14px var(--disp)}
|
||||
.chat-compose .btn{padding:9px 16px}
|
||||
.chat-msg-btn{margin-left:auto;font-size:12px;padding:3px 10px}
|
||||
.switch{display:flex;align-items:center;gap:10px;cursor:pointer;font-size:14px}
|
||||
.switch input{width:18px;height:18px;accent-color:var(--mint)}
|
||||
|
||||
/* ── Overview line tree ── */
|
||||
.line-tree{margin-top:6px}
|
||||
.lt-top{margin-left:26px}
|
||||
.lt-you{display:inline-block;background:var(--mint);color:var(--mint-ink);font-weight:800;padding:6px 18px;border-radius:999px;font-size:13px}
|
||||
.lt-stem{height:12px;border-left:2px solid var(--line-strong);width:0;margin:0 0 6px 30px}
|
||||
.lt-row{display:flex;align-items:center;gap:10px;margin:7px 0}
|
||||
.lt-cap{font:700 11px var(--mono);color:var(--muted);width:22px;flex:0 0 auto}
|
||||
.lt-nodes{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.lt-node{background:var(--panel);border:1px solid var(--line-strong);border-radius:10px;padding:6px 12px;font-size:13px;font-weight:600;white-space:nowrap}
|
||||
.lt-node.deep{color:var(--muted)}
|
||||
.lt-node.qualified{border-color:var(--amber);color:var(--gold);box-shadow:0 0 0 1px var(--amber-line)}
|
||||
.lt-node.open{border-style:dashed;color:var(--muted);background:transparent}
|
||||
.lt-node .lt-n{display:inline-block;font-style:normal;font-size:10px;line-height:16px;min-width:16px;text-align:center;border-radius:8px;background:var(--amber-soft);color:var(--gold);margin-left:6px;padding:0 4px;font-variant-numeric:tabular-nums}
|
||||
|
||||
.sh-report{display:block;text-align:center;margin-top:10px;color:var(--muted);font-size:12px}
|
||||
.sh-report:hover{color:var(--ink)}
|
||||
|
||||
/* ── promo tools (2026-09-09) ── */
|
||||
.promo-strip{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;padding:16px 20px}
|
||||
.angle-list{display:flex;flex-direction:column;gap:8px}
|
||||
.hp-field{position:absolute;left:-9999px;top:auto;width:1px;height:1px;opacity:0;overflow:hidden}
|
||||
.hbars{display:flex;align-items:flex-end;gap:2px;height:20px;margin-top:6px;width:120px}
|
||||
.hbars i{flex:1 1 0;background:var(--mint);opacity:.75;border-radius:1px 1px 0 0;min-width:2px}
|
||||
.hbars i:hover{opacity:1}
|
||||
.icon-check{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 12px}
|
||||
.icon-check .ic-btn{font-size:26px;line-height:1;padding:10px 14px;border-radius:12px;border:1px solid var(--line-strong);background:var(--panel);cursor:pointer}
|
||||
.icon-check .ic-btn:hover{border-color:var(--mint)}
|
||||
.angle-row.pb-acc>summary{padding:12px 14px;font-size:14.5px}
|
||||
.angle-row .angle-body{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;padding:0 14px 14px}
|
||||
.angle-row .angle-txt{flex:1 1 320px;min-width:0}
|
||||
.angle-name{font-family:var(--disp);font-weight:700;font-size:15px}
|
||||
.angle-hook{color:var(--mint);font-size:13px;font-weight:500}
|
||||
.angle-tag{font-family:var(--mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);border:1px solid var(--line-strong);border-radius:999px;padding:1px 7px}
|
||||
.angle-url{overflow-wrap:anywhere;margin-top:4px;display:block;color:var(--mint);text-decoration:none}
|
||||
.angle-url:hover{text-decoration:underline}
|
||||
.angle-btns{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.angle-btns .btn{margin-top:0}
|
||||
.promo-pills{margin:4px 0 14px}
|
||||
.promo-block .pb-head{display:flex;gap:8px;align-items:center;margin-bottom:8px;font-size:13.5px}
|
||||
.promo-block .pb-net{font-family:var(--mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--mint)}
|
||||
.promo-block .pb-text{white-space:pre-wrap;font-size:14.5px;line-height:1.5}
|
||||
.promo-block .pb-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
|
||||
.promo-block .pb-actions .btn{margin-top:0}
|
||||
.promo-bv{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:16px;padding:14px 16px;border:1px dashed var(--line-strong);border-radius:12px}
|
||||
.promo-bv b{font-family:var(--disp)}
|
||||
.obj-wrap{display:flex;flex-direction:column;gap:8px}
|
||||
.obj{border:1px solid var(--line);border-radius:12px;background:var(--ground-soft)}
|
||||
.obj summary{cursor:pointer;padding:12px 16px;font-family:var(--disp);font-weight:700;font-size:15px;list-style:none;display:flex;justify-content:space-between;gap:10px}
|
||||
.obj summary::after{content:"+";color:var(--mint);font-weight:800}
|
||||
.obj[open] summary::after{content:"–"}
|
||||
.obj summary::-webkit-details-marker{display:none}
|
||||
.obj summary::marker{content:""}
|
||||
.obj summary{text-align:left}
|
||||
.obj-body{padding:0 16px 14px;display:grid;gap:12px}
|
||||
.obj .lab{display:inline-block;font-family:var(--mono);font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--mint);margin-bottom:4px}
|
||||
.obj .lab-say{color:var(--amber)}
|
||||
.obj-truth p{margin:0;font-size:14.5px;color:var(--ink)}
|
||||
.obj-say{margin:0}
|
||||
|
||||
.lin-row .earn{font-family:var(--mono);font-size:12px;color:var(--muted);white-space:nowrap;font-variant-numeric:tabular-nums}
|
||||
.lin-row .earn.on{color:var(--mint);font-weight:700}
|
||||
|
||||
.wo-slot{border:1px solid var(--line);border-radius:12px;padding:12px 14px}
|
||||
.wo-slot.locked{opacity:.6}
|
||||
.wo-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
|
||||
.wo-slot img{max-width:100%;border-radius:8px}
|
||||
|
||||
/* getting-started stepper on the Overview (Jim could not find the wallet step, 2026-09-14) */
|
||||
.gs{border-color:var(--mint-line)}
|
||||
.gs-steps{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:4px 0 12px}
|
||||
.gs-step{display:flex;gap:10px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:10px 12px;color:var(--muted);font-size:14px}
|
||||
.gs-step .n{flex:0 0 26px;width:26px;height:26px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:700;border:1px solid var(--line);font-size:13px}
|
||||
.gs-step.done{color:var(--ink)} .gs-step.done .n{background:var(--mint);color:var(--mint-ink);border-color:var(--mint)}
|
||||
.gs-step.now{color:var(--ink);border-color:var(--mint);background:var(--mint-faint)} .gs-step.now .n{border-color:var(--mint);color:var(--mint)}
|
||||
.gs-now{display:flex;gap:14px;align-items:center;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:12px}
|
||||
.gs-now p{margin:0;flex:1;min-width:240px;max-width:60ch} .gs-now p b{display:block;font-family:var(--disp);font-size:16px;margin-bottom:2px}
|
||||
@keyframes gsPulse{0%{box-shadow:0 0 0 0 rgba(67,232,195,.7)}70%{box-shadow:0 0 0 14px rgba(67,232,195,0)}100%{box-shadow:0 0 0 0 rgba(67,232,195,0)}}
|
||||
.pulse{animation:gsPulse 1.2s ease-out 4}
|
||||
|
||||
/* promo toolkit tiers */
|
||||
.tk-tiers{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px}
|
||||
.tk-tier{border:1px solid var(--line);border-radius:12px;padding:12px 14px;font-size:13.5px;color:var(--muted)}
|
||||
.tk-tier.reached{border-color:var(--mint-line);color:var(--ink)} .tk-tier.current{background:var(--mint-faint)}
|
||||
.tk-tier b{display:block;font-family:var(--disp);font-size:15px;color:var(--ink)} .tk-tier .need{font-size:12px;margin:2px 0 8px;color:var(--muted)}
|
||||
.tk-tier ul{margin:0;padding-left:16px} .tk-tier li{margin:3px 0} .tk-tier li.soon{opacity:.65} .tk-tier li.soon::after{content:' (coming)';font-size:11px;color:var(--muted)}
|
||||
.tk-tier .lock{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--gold)}
|
||||
.tk-hist{border-top:1px solid var(--line);padding:8px 0;font-size:13px} .tk-hist .muted{font-size:12px}
|
||||
.tk-sec{margin-top:18px;padding-top:14px;border-top:1px solid var(--line)} .tk-grid{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.tk-vids{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px} .tk-vid{border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:13px} .tk-vid b{display:block;font-weight:600;margin-bottom:4px} .tk-vid .st{font-size:12px;color:var(--muted)}
|
||||
.tk-bar{height:8px;border-radius:99px;background:var(--muted-soft);overflow:hidden;margin:6px 0 4px} .tk-bar i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,var(--mint-deep),var(--mint));transition:width .6s ease;min-width:4px}
|
||||
.tk-table{width:100%;border-collapse:collapse;font-size:13px} .tk-table th,.tk-table td{text-align:left;padding:6px 8px;border-bottom:1px solid var(--line)} .tk-table th{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)} .tk-table td.n{font-variant-numeric:tabular-nums;text-align:right} .tk-table th.n{text-align:right} .tk-table tr.best td{color:var(--mint)}
|
||||
.tk-team{border:1px solid var(--line);border-radius:10px;padding:8px 12px;margin:6px 0;font-size:13px;display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:space-between} .tk-team .who b{font-weight:600} .tk-team .who span{color:var(--muted);font-size:12px} .tk-team.stalled{border-color:var(--gold-line)}
|
||||
.tk-nudge{width:100%;margin:8px 0 0;padding:8px 12px;border:1px dashed var(--line);border-radius:10px;font-size:13px}
|
||||
/* click sources stack one per line so the Clicks column stays narrow (Marty, 2026-09-15) */
|
||||
.clk-src span{display:block;white-space:nowrap} .camp-table td{white-space:normal} .camp-table td:first-child{max-width:260px}
|
||||
/* campaigns list on phones and tablets: each row becomes a card, buttons at the bottom, no sideways scroll (Jim, 2026-09-15) */
|
||||
@media (max-width:900px){
|
||||
.tablewrap:has(.camp-table){overflow:visible}
|
||||
.camp-table{display:block;width:100%;border-collapse:separate}
|
||||
.camp-table thead{display:none}
|
||||
.camp-table tbody{display:block}
|
||||
.camp-table tr{display:block;border:1px solid var(--line);border-radius:12px;padding:10px 12px 12px;margin:0 0 10px;background:var(--panel)}
|
||||
.camp-table td{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:5px 0;border:0;text-align:left;max-width:100%;overflow:hidden}
|
||||
.camp-table td.num{text-align:right;font-variant-numeric:tabular-nums}
|
||||
.camp-table td::before{content:attr(data-l);color:var(--muted);font-size:11px;letter-spacing:.06em;text-transform:uppercase;flex:0 0 auto}
|
||||
.camp-table td:first-child{display:block;padding:0 0 6px;font-size:16px} .camp-table td:first-child::before{display:none}
|
||||
.camp-table td:first-child > *{max-width:100%}
|
||||
.camp-table td.act{display:flex;flex-wrap:wrap;justify-content:flex-start;gap:8px;margin-top:8px;padding-top:10px;border-top:1px solid var(--line)} .camp-table td.act::before{display:none}
|
||||
/* on a phone the card is wide enough for them to share a row, so undo the desktop stack */
|
||||
.camp-table td.act .btn{flex:1 1 auto;text-align:center;display:inline-block;width:auto;min-width:0;margin:0}
|
||||
}
|
||||
|
||||
/* Pipeline board (Marty, 2026-09-15): columns scroll sideways inside their own box, never the page */
|
||||
.pipe-board{display:flex;gap:10px;overflow-x:auto;padding:4px 2px 10px;scroll-snap-type:x proximity}
|
||||
.pipe-col{flex:0 0 220px;scroll-snap-align:start;background:var(--ground-soft);border:1px solid var(--line);border-radius:12px;padding:10px;min-height:120px}
|
||||
.pipe-col h4{margin:0 0 2px;font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);display:flex;justify-content:space-between;gap:8px}
|
||||
.pipe-col h4 span{color:var(--muted);font-variant-numeric:tabular-nums}
|
||||
.pipe-col .hint{font-size:11.5px;color:var(--muted);margin:0 0 8px;line-height:1.35}
|
||||
.pipe-card{background:var(--ink-faint);border:1px solid var(--line);border-radius:10px;padding:8px 10px;margin:0 0 8px;cursor:pointer;transition:border-color .15s}
|
||||
.pipe-card:hover,.pipe-card:focus-visible{border-color:var(--mint);outline:none}
|
||||
.pipe-card.on{border-color:var(--gold,#e6c15a)}
|
||||
.pipe-card .nm{font-weight:700;font-size:14px;display:flex;justify-content:space-between;gap:6px;align-items:baseline}
|
||||
.pipe-card .nm small{font-weight:400;font-size:11px;color:var(--muted);white-space:nowrap}
|
||||
.pipe-card .sub{font-size:12px;color:var(--muted);margin-top:3px;line-height:1.35}
|
||||
.pipe-card .note{font-size:12px;color:var(--ink);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.pipe-card .chip{margin-top:5px;margin-right:4px}
|
||||
.pipe-due{display:grid;gap:6px}
|
||||
.pipe-due .pipe-card{margin:0}
|
||||
@media (max-width:640px){.pipe-form{grid-template-columns:1fr !important}.pipe-col{flex-basis:200px}}
|
||||
/* Overview chips drill down to My line (Marty, 2026-09-15) */
|
||||
.lt-node.lt-go{cursor:pointer;transition:border-color .15s,transform .15s} .lt-node.lt-go:hover,.lt-node.lt-go:focus-visible{border-color:var(--mint);transform:translateY(-1px);outline:none}
|
||||
.lin-row.lin-focus{box-shadow:0 0 0 2px var(--mint);border-radius:10px}
|
||||
/* paged lists: 25 rows, then a control bar that reads as a control, not more list (Marty, 2026-09-19) */
|
||||
.pgr{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin:12px 0 4px;padding:10px 12px;border:1px solid var(--line-strong);border-radius:12px;background:var(--mint-faint)}
|
||||
.pgr-n{color:var(--ink);font-size:13px} .pgr-n b{color:var(--mint);font-variant-numeric:tabular-nums}
|
||||
.pgr-b{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
||||
.pgr-pg{font-size:11px;color:var(--muted);letter-spacing:.06em;text-transform:uppercase;white-space:nowrap}
|
||||
.pgr-btn{background:var(--mint);color:var(--mint-ink);border:0;border-radius:999px;padding:8px 14px;font-weight:800;font-size:13px;cursor:pointer;white-space:nowrap}
|
||||
.pgr-btn:hover{background:var(--mint-hi)} .pgr-btn[disabled]{opacity:.35;cursor:default}
|
||||
.pipe-col .pgr{padding:8px;gap:6px;margin-top:8px} .pipe-col .pgr-btn{padding:6px 10px;font-size:12px}
|
||||
#chatThreads .pgr{margin:8px 10px}
|
||||
|
||||
/* Five Dollar Friday strip (landing) */
|
||||
.fdf{margin:18px auto 0;max-width:760px;padding:12px 16px;border-radius:12px;background:var(--mint-soft);border:1px solid var(--mint-line);color:var(--ink);font-size:14px;line-height:1.5;text-align:center}
|
||||
.fdf a{color:var(--mint);font-weight:600}
|
||||
|
||||
/* My line: section pills, sticky under the top bar (Marty, 2026-09-26) */
|
||||
.line-jump{position:sticky;top:var(--jumpTop,64px);z-index:4;margin:0 0 14px;padding:10px 0;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;
|
||||
background:var(--nav-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
|
||||
.line-jump::-webkit-scrollbar{display:none}
|
||||
.line-jump .chip-t{flex:none;white-space:nowrap}
|
||||
#pane-line > .card[data-jump]{scroll-margin-top:calc(var(--jumpTop,64px) + 64px)}
|
||||
.tablewrap > .pgr{margin-top:10px}
|
||||
|
||||
/* a game return bar sits at the bottom: lift the status toast above it (Marty 2026-10-08: the bar hid the purchase result) */
|
||||
body.hasback #status{bottom:92px}
|
||||
|
||||
/* ── Light theme (2026-11-01, mirrored from LinkSpin): light mint-grey ground, white panels, dark ink, the mint family
|
||||
darkened to a teal that reads as text on white (every pair below clears WCAG AA 4.5:1, measured by qa/theme-contrast.mjs).
|
||||
themehead.js resolves auto | light | dark to data-theme on <html> before the first paint; nothing stored keeps dark. ── */
|
||||
:root[data-theme="light"]{
|
||||
--ground:#E8F0EC; --ground2:#F2F7F4; --panel:#FFFFFF; --panel-solid:#FFFFFF;
|
||||
--line:#C9D8D1; --line-strong:#A6BBB1; --line-soft:#DDE7E2; --ink:#0B1A14; --muted:#50665C;
|
||||
--mint:#0A6B56; --mint-hi:#075744; --mint-deep:#064A3A; --mint-ink:#FFFFFF; --mint-pale:#075744;
|
||||
--mint-faint:#EDF6F2; --mint-soft:#DDF0E8; --mint-soft-2:#C6E6DA; --mint-line:#8FC9B6; --mint-line-2:#3E9E85;
|
||||
--cyan:#0A6F8C; --violet:#5B3FD6; --amber:#8A5200; --bad:#B42318; --bad-soft:#FDE8E6;
|
||||
--ok:#0B7A52; --ok-ink:#FFFFFF; --ok-soft:#E3F6EC; --warn:#9A4A00;
|
||||
--gold:#7A5200; --gold-2:#7F5C00; --gold-ink:#FFFFFF; --gold-soft:#FFF4D1; --gold-faint:#FFFBEB; --gold-line:#E6C25E;
|
||||
--amber-soft:#FFF1D6; --amber-line:#E8C27A; --amber-ink:#FFFFFF;
|
||||
--cyan-soft:#DDF1F8; --cyan-line:#9FD3E6; --violet-soft:#EEE9FF; --violet-line:#C4B5FF;
|
||||
--muted-soft:rgba(80,102,92,.12); --muted-line:rgba(80,102,92,.45); --ink-faint:rgba(11,26,20,.05);
|
||||
--ground-soft:#F2F7F4; --field-bg:#FFFFFF; --nav-bg:rgba(242,247,244,.88); --side-bg:rgba(242,247,244,.97); --pill-bg:rgba(255,255,255,.85);
|
||||
--panel-grad:linear-gradient(180deg,#FFFFFF,#F5FAF7); --panel-grad-deep:linear-gradient(180deg,#F2F7F4,#E2ECE7); --plate-grad:linear-gradient(160deg,#FFFFFF,#E6F1EC);
|
||||
--sh-lg:0 0 0 1px rgba(11,26,20,.04),0 14px 34px -20px rgba(11,26,20,.35);
|
||||
color-scheme:light;
|
||||
}
|
||||
:root[data-theme="light"] body::before{opacity:.7}
|
||||
:root[data-theme="light"] .ghost{background:linear-gradient(180deg,rgba(10,107,86,.22),transparent 78%);-webkit-background-clip:text;background-clip:text}
|
||||
:root[data-theme="light"] .btn{box-shadow:0 4px 18px rgba(10,107,86,.22)} :root[data-theme="light"] .btn:hover{box-shadow:0 8px 26px rgba(10,107,86,.3)}
|
||||
:root[data-theme="light"] .mockup,:root[data-theme="light"] .modal-card,:root[data-theme="light"] #status,:root[data-theme="light"] #iapChatPanel,:root[data-theme="light"] .chat-drawer{box-shadow:0 18px 50px -20px rgba(11,26,20,.35)}
|
||||
:root[data-theme="light"] .bo.side-open .bo-side{box-shadow:0 0 60px rgba(11,26,20,.25)}
|
||||
:root[data-theme="light"] .plate{box-shadow:0 0 24px rgba(10,107,86,.12),inset 0 1px 0 rgba(255,255,255,.8)}
|
||||
@@ -0,0 +1,271 @@
|
||||
// Banner Line wallet plumbing: InstantAdPay's wallet.js (same AppKit build, chain guard, fee fix, dead-session
|
||||
// recovery), with buy(sponsor) / buyFor(owner, sponsor) in place of the IAP product buy. Selectors come from
|
||||
// /api/config (server abi.js), so the ABI lives in one module.
|
||||
// Wallet plumbing via Reown AppKit — the universal connector every wallet is
|
||||
// built for (all wallets, QR + mobile deep-links, working icons). AppKit is
|
||||
// lazy-loaded from the CDN on first use; once connected we drive the raw
|
||||
// EIP-1193 provider for chain switch, SIWE sign-in, and contract transactions.
|
||||
window.BLWallet = (function () {
|
||||
const pad = v => BigInt(v).toString(16).padStart(64, '0');
|
||||
const padAddr = a => { if (!a) return pad(0); if (!/^0x[0-9a-fA-F]{40}$/.test(a)) throw new Error('Bad address: ' + a); return a.slice(2).toLowerCase().padStart(64, '0'); };
|
||||
// Normalize a chainId to a decimal number. eth_chainId is meant to return a
|
||||
// hex string, but some wallets return a number or a decimal string — compare
|
||||
// numerically so a wallet's shape never crashes the flow.
|
||||
const chainNum = v => {
|
||||
if (v == null) return NaN;
|
||||
if (typeof v === 'number') return v;
|
||||
const s = String(v).trim();
|
||||
return /^0x/i.test(s) ? parseInt(s, 16) : parseInt(s, 10);
|
||||
};
|
||||
const APPKIT_URL = 'https://cdn.jsdelivr.net/npm/@reown/appkit-cdn@1.8.23/dist/appkit.js';
|
||||
|
||||
let modal = null, akPromise = null, provider = null;
|
||||
|
||||
async function initAppKit(c) {
|
||||
if (modal) return modal;
|
||||
if (akPromise) return akPromise;
|
||||
akPromise = (async () => {
|
||||
const mod = await import(APPKIT_URL);
|
||||
const { createAppKit, WagmiAdapter, networks } = mod;
|
||||
const netMap = { 80002: networks.polygonAmoy, 137: networks.polygon, 31337: networks.hardhat || networks.localhost };
|
||||
const base = netMap[Number(c.chainId)] || networks.polygonAmoy;
|
||||
// Override the chain's RPC with our clean public endpoint. AppKit's built-in
|
||||
// networks advertise the WalletConnect RPC proxy
|
||||
// (rpc.walletconnect.org/v1/?chainId=…&projectId=…) as the chain RPC, and
|
||||
// wallets reject that query-string URL as "Invalid URL" when adding/switching
|
||||
// the network — the cause of Trust's "Invalid URL", MetaMask's switch loop,
|
||||
// and the failed mobile buy (the chain switch never completed).
|
||||
const rpc = String(c.rpc || '').trim();
|
||||
const net = rpc ? Object.assign({}, base, { rpcUrls: { default: { http: [rpc] }, public: { http: [rpc] } } }) : base;
|
||||
// Accept the wallet's usual networks too, so AppKit doesn't trap the user in
|
||||
// its own "Switch Network" modal — that modal loops on a testnet the wallet
|
||||
// can't auto-add. We switch to `net` ourselves (wallet_addEthereumChain adds
|
||||
// + switches in one step) and sendTx hard-guards the chain before signing.
|
||||
const allNets = [net];
|
||||
for (const k of ['polygon', 'mainnet']) {
|
||||
try { const n = networks[k]; if (n && n.id !== net.id) allNets.push(n); } catch (e) {}
|
||||
}
|
||||
const projectId = String(c.walletConnectProjectId || '').trim();
|
||||
const wagmiAdapter = new WagmiAdapter({ networks: allNets, projectId });
|
||||
modal = createAppKit({
|
||||
adapters: [wagmiAdapter], networks: allNets, projectId, defaultNetwork: net,
|
||||
metadata: { name: 'Banner Line', description: 'Spots on the board, split on-chain when spots sell.',
|
||||
url: location.origin, icons: [location.origin + '/logo-icon.png'] },
|
||||
features: { analytics: false, email: false, socials: [] },
|
||||
// Picker order: wallets without Trust's balance-proportion block go first.
|
||||
// Trust Wallet is NOT excluded; it just drops out of the featured row into
|
||||
// "All wallets" (Marty, 2026-09-09: move Trust to the bottom, not off).
|
||||
featuredWalletIds: [
|
||||
'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // MetaMask
|
||||
'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393', // Phantom
|
||||
'0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150', // SafePal
|
||||
'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa' // Coinbase Wallet
|
||||
]
|
||||
});
|
||||
return modal;
|
||||
})();
|
||||
return akPromise;
|
||||
}
|
||||
|
||||
function currentAddress() { try { return (modal && modal.getAddress && modal.getAddress()) || null; } catch (e) { return null; } }
|
||||
|
||||
function waitForConnection(timeoutMs) {
|
||||
if (currentAddress()) return Promise.resolve(currentAddress());
|
||||
return new Promise((resolve, reject) => {
|
||||
let done = false, unsub = null;
|
||||
const finish = (addr, err) => { if (done) return; done = true; try { unsub && unsub(); } catch (e) {} err ? reject(err) : resolve(addr); };
|
||||
try { unsub = modal.subscribeAccount(acc => { if (acc && acc.isConnected && acc.address) finish(acc.address); }); } catch (e) {}
|
||||
const t0 = Date.now();
|
||||
(function poll() {
|
||||
if (done) return;
|
||||
const a = currentAddress();
|
||||
if (a) return finish(a);
|
||||
if (Date.now() - t0 > (timeoutMs || 180000)) return finish(null, new Error('Wallet connection timed out. Tap Connect and try again.'));
|
||||
setTimeout(poll, 400);
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
async function resolveProvider() {
|
||||
for (let i = 0; i < 20; i++) {
|
||||
try { const p = modal.getWalletProvider ? await Promise.resolve(modal.getWalletProvider()) : null; if (p && p.request) return p; } catch (e) {}
|
||||
await new Promise(r => setTimeout(r, 300));
|
||||
}
|
||||
throw new Error('Could not reach your wallet. Try connecting again.');
|
||||
}
|
||||
|
||||
function eth() { if (!provider) throw new Error('Connect your wallet first.'); return provider; }
|
||||
const isInjected = () => !!(provider && window.ethereum && (provider === window.ethereum || provider.isMetaMask));
|
||||
// the account the wallet will actually sign with: for an injected wallet (MetaMask
|
||||
// extension) that is its active account, which can differ from AppKit's cached one
|
||||
async function activeAddress(fallback) {
|
||||
if (isInjected()) { try { const a = await provider.request({ method: 'eth_accounts' }); if (a && a[0]) return a[0]; } catch (e) {} }
|
||||
return fallback || currentAddress();
|
||||
}
|
||||
// Force the wallet's own account picker. Injected wallets stay connected to the
|
||||
// site, so a plain disconnect/reconnect never shows one: asking for permissions
|
||||
// again makes MetaMask open its account-selection prompt, and whatever the user
|
||||
// ticks becomes the active account. WalletConnect wallets fall back to a fresh
|
||||
// session (the picker + the wallet app's own account choice).
|
||||
async function pickAccount() {
|
||||
const c = await BL.getConfig();
|
||||
await initAppKit(c);
|
||||
const inj = window.ethereum;
|
||||
if (inj && inj.request) {
|
||||
try {
|
||||
await inj.request({ method: 'wallet_requestPermissions', params: [{ eth_accounts: {} }] });
|
||||
const accs = await inj.request({ method: 'eth_accounts' });
|
||||
if (accs && accs[0]) { provider = inj; await ensureChain(c).catch(() => {}); return accs[0]; }
|
||||
} catch (e) {
|
||||
if (e && (e.code === 4001 || /reject|denied/i.test(String(e.message || '')))) throw new Error('You closed the account picker. Pick the account you want and try again.');
|
||||
}
|
||||
}
|
||||
return freshConnect(c);
|
||||
}
|
||||
|
||||
// A WalletConnect session can die underneath AppKit's cached "connected"
|
||||
// state: the wallet app rejects or kills it (Trust does this after its own
|
||||
// security stop), the phone sleeps, the relay drops. AppKit still reports an
|
||||
// address, so the next request fails with a "disconnected" style error.
|
||||
// Detect that, wipe the stale session, and re-open the picker for a fresh one.
|
||||
const DEAD_RE = /disconnect|not connected|no matching key|session (topic|expired|deleted|not found)|call connect|please call connect|missing or invalid|relay/i;
|
||||
const isDead = e => DEAD_RE.test(String((e && e.message) || e || ''));
|
||||
async function freshConnect(c) {
|
||||
try { BL.status('Your wallet session dropped. Reconnect in the picker…'); } catch (e) {}
|
||||
await disconnect();
|
||||
try { await modal.open(); } catch (e) {}
|
||||
const addr = await waitForConnection(180000);
|
||||
try { if (modal && modal.close) await modal.close(); } catch (e) {}
|
||||
provider = await resolveProvider();
|
||||
await ensureChain(c).catch(() => {});
|
||||
return addr;
|
||||
}
|
||||
|
||||
async function connect() {
|
||||
const c = await BL.getConfig();
|
||||
await initAppKit(c);
|
||||
let addr = currentAddress();
|
||||
if (!addr) {
|
||||
// give AppKit a moment to rehydrate an existing session before popping the
|
||||
// picker — otherwise an already-connected wallet still gets the modal
|
||||
for (let i = 0; i < 8 && !addr; i++) { await new Promise(r => setTimeout(r, 150)); addr = currentAddress(); }
|
||||
}
|
||||
if (!addr) { try { await modal.open(); } catch (e) {} addr = await waitForConnection(180000); }
|
||||
try { if (modal && modal.close) await modal.close(); } catch (e) {} // dismiss the picker once we're connected
|
||||
provider = await resolveProvider();
|
||||
// probe the session: a dead WalletConnect session answers with a disconnect error
|
||||
try { await provider.request({ method: 'eth_chainId' }); }
|
||||
catch (e) { if (isDead(e)) return freshConnect(c); }
|
||||
await ensureChain(c).catch(() => {}); // AppKit already connects on the right network; switch is best-effort
|
||||
return addr;
|
||||
}
|
||||
|
||||
async function ensureChain(c) {
|
||||
const want = '0x' + Number(c.chainId).toString(16);
|
||||
let cur; try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) { return; }
|
||||
if (chainNum(cur) === Number(c.chainId)) return;
|
||||
try {
|
||||
await eth().request({ method: 'wallet_switchEthereumChain', params: [{ chainId: want }] });
|
||||
} catch (e) {
|
||||
// any failure (not just 4902): try to add the chain — wallet_addEthereumChain
|
||||
// adds AND switches in one step, which is what unblocks wallets that can't
|
||||
// otherwise reach a chain they don't already have (e.g. a testnet).
|
||||
const addParams = { chainId: want, chainName: c.chainName, nativeCurrency: { name: 'POL', symbol: 'POL', decimals: 18 }, rpcUrls: [c.rpc] };
|
||||
if (c.explorer && /^https?:\/\//i.test(c.explorer)) addParams.blockExplorerUrls = [c.explorer];
|
||||
try { await eth().request({ method: 'wallet_addEthereumChain', params: [addParams] }); } catch (e2) {}
|
||||
}
|
||||
}
|
||||
|
||||
// SIWE: challenge -> personal_sign -> verify (server sets the session cookie)
|
||||
async function signIn(opts) {
|
||||
const addr = (opts && opts.pick) ? await pickAccount() : await activeAddress(await connect());
|
||||
const ch = await (await fetch('/api/auth/challenge', { method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: addr }) })).json();
|
||||
if (ch.error) throw new Error(ch.error);
|
||||
// hex-encode the message (Trust and others require hex for personal_sign)
|
||||
const hexMsg = '0x' + Array.from(new TextEncoder().encode(ch.message)).map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
const sig = await eth().request({ method: 'personal_sign', params: [hexMsg, addr] });
|
||||
const r = await (await fetch('/api/auth/verify', { method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address: addr, signature: sig, asPosition: !!(opts && opts.asPosition) }) })).json();
|
||||
if (r.error) throw new Error(r.error);
|
||||
return r;
|
||||
}
|
||||
|
||||
async function sendTx(data, valueWei) {
|
||||
const c = await BL.getConfig();
|
||||
const addr = await connect();
|
||||
// Hard chain guard: connect()'s switch is best-effort and some wallets (or
|
||||
// AppKit's own modal) don't complete it. Never sign on the wrong chain —
|
||||
// a value tx to a contract that doesn't exist on that chain would look like
|
||||
// it "succeeded" while doing nothing.
|
||||
const wantNum = Number(c.chainId);
|
||||
let cur; try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) {}
|
||||
if (!isNaN(chainNum(cur)) && chainNum(cur) !== wantNum) {
|
||||
await ensureChain(c);
|
||||
try { cur = await eth().request({ method: 'eth_chainId' }); } catch (e) {}
|
||||
if (!isNaN(chainNum(cur)) && chainNum(cur) !== wantNum)
|
||||
throw new Error('Your wallet is on the wrong network. Switch it to ' + (c.chainName || 'the correct network') + ', then try again.');
|
||||
}
|
||||
const tx = { from: await activeAddress(addr), to: c.contract, data };
|
||||
if (valueWei) tx.value = '0x' + BigInt(valueWei).toString(16);
|
||||
// Amoy's Bor nodes enforce a ~25 gwei minimum priority fee that MetaMask's
|
||||
// own estimate misses ("gas tip below minimum"). Pull the network's correct
|
||||
// fees from the server and set them so the tx clears the floor.
|
||||
try {
|
||||
const g = await (await fetch('/api/gas')).json();
|
||||
if (g && g.maxPriorityFeePerGas && g.maxFeePerGas) {
|
||||
tx.maxPriorityFeePerGas = g.maxPriorityFeePerGas;
|
||||
tx.maxFeePerGas = g.maxFeePerGas;
|
||||
}
|
||||
} catch (e) {}
|
||||
try {
|
||||
return await eth().request({ method: 'eth_sendTransaction', params: [tx] });
|
||||
} catch (e) {
|
||||
if (!isDead(e)) throw e;
|
||||
// session died between connect and send: reconnect once and resend
|
||||
tx.from = await freshConnect(c);
|
||||
return eth().request({ method: 'eth_sendTransaction', params: [tx] });
|
||||
}
|
||||
}
|
||||
|
||||
async function waitTx(hash) {
|
||||
for (let i = 0; i < 90; i++) {
|
||||
try {
|
||||
const r = await (await fetch('/api/tx/' + hash)).json();
|
||||
if (r.found) return { status: r.status, blockNumber: r.blockNumber };
|
||||
} catch (e) { /* transient fetch failure (e.g. mobile app-switch) — keep polling */ }
|
||||
await new Promise(res => setTimeout(res, 2500));
|
||||
}
|
||||
throw new Error('Timed out waiting for the transaction. Check the explorer.');
|
||||
}
|
||||
|
||||
// sendWei = quoteWei plus ~1% headroom (from /api/quote); the contract refunds anything above the price in the same tx
|
||||
async function buy(sponsor, sendWei) {
|
||||
const c = await BL.getConfig();
|
||||
const hash = await sendTx(c.sel.buy + padAddr(sponsor), sendWei);
|
||||
return { hash, receipt: await waitTx(hash) };
|
||||
}
|
||||
async function buyFor(owner, sponsor, sendWei) {
|
||||
const c = await BL.getConfig();
|
||||
if (!owner) throw new Error('Enter the wallet address that should own the spot.');
|
||||
const hash = await sendTx(c.sel.buyFor + padAddr(owner) + padAddr(sponsor), sendWei);
|
||||
return { hash, receipt: await waitTx(hash) };
|
||||
}
|
||||
|
||||
async function disconnect() {
|
||||
// AppKit's disconnect can hang on the WalletConnect relay (esp. mobile) —
|
||||
// never block on it, so the UI can't get stuck "disconnecting".
|
||||
try { if (modal && modal.disconnect) await Promise.race([modal.disconnect(), new Promise(r => setTimeout(r, 1200))]); } catch (e) {}
|
||||
provider = null;
|
||||
try { Object.keys(localStorage).forEach(k => { if (/wc@2|walletconnect|w3m|wcm|reown|wagmi|appkit/i.test(k)) localStorage.removeItem(k); }); } catch (e) {}
|
||||
}
|
||||
|
||||
// native balance of the connected wallet (pre-flight check before a buy)
|
||||
async function balance(addr) {
|
||||
await connect();
|
||||
const h = await eth().request({ method: 'eth_getBalance', params: [addr || currentAddress(), 'latest'] });
|
||||
return BigInt(h);
|
||||
}
|
||||
function walletName() { try { const w = modal && modal.getWalletInfo && modal.getWalletInfo(); return (w && w.name) || ''; } catch (e) { return ''; } }
|
||||
return { connect, signIn, buy, buyFor, waitTx, disconnect, balance, address: currentAddress, activeAddress, pickAccount, walletName };
|
||||
})();
|
||||
@@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Board | Banner Line</title>
|
||||
<meta name="description" content="Banner Line: a $5 spot buys 300 guaranteed views on the board and a place in the line. Paid instantly on-chain when spots sell.">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=1">
|
||||
<link rel="stylesheet" href="/assets/line.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<section class="hero"><h1>The board</h1>
|
||||
<p class="lead">Every spot is owed 300 views. Newest spots sit on top, and the board rotates until each spot has its views (30-day limit). Open slots show network sites.</p></section>
|
||||
<div class="card"><div class="lots" id="lots"></div><p class="muted small" id="boardNote"></p></div>
|
||||
<div class="card"><h3>The line so far</h3><div id="stats" class="grid2"></div></div>
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/board.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>How it works | Banner Line</title>
|
||||
<meta name="description" content="Banner Line: a $5 spot buys 300 guaranteed views on the board and a place in the line. Paid instantly on-chain when spots sell.">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=1">
|
||||
<link rel="stylesheet" href="/assets/line.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<section class="hero"><h1>How Banner Line works</h1><p class="lead">One global line of 468x60 spots. Plain rules, all on-chain, nothing held by the site.</p></section>
|
||||
<div class="card"><h3>What a spot buys</h3><p>A spot costs $5 in POL at the Chainlink POL/USD price. It buys two things: 300 guaranteed views on the board for your image and link (delivered within 30 days, newest spots on top), and a place in the line.</p></div>
|
||||
<div class="card"><h3>Where the $5 goes, in the same transaction</h3>
|
||||
<table class="tbl"><tr><th>Share</th><th>To</th></tr>
|
||||
<tr><td>30% ($1.50)</td><td>the buyer's sponsor (no sponsor: the momentum fund)</td></tr>
|
||||
<tr><td>55% ($0.275 x 10)</td><td>the owners of the 10 spots bought just before this one</td></tr>
|
||||
<tr><td>10%</td><td>the company</td></tr>
|
||||
<tr><td>5%</td><td>the momentum fund, which can only buy spots</td></tr></table>
|
||||
<p class="muted small">The contract holds nothing except the momentum fund. The splits cannot be changed and there is no owner withdraw.</p></div>
|
||||
<div class="card"><h3>What is not promised</h3><p>Nothing is promised. You are paid only when spots sell after yours. The line pays each spot at most 10 times ($2.75), so a member who refers nobody always gets back less than $5. This is advertising with a share of later sales, not an investment.</p></div>
|
||||
<div class="card"><h3>The momentum fund</h3><p>When no spot has sold for 4 hours, the fund buys one (at most 12 a day). It gifts the spot to an active member who owns a paid spot and has not had a gift in 7 days, members who referred someone recently first. If nobody qualifies, the fund keeps the spot and its line money goes back into the fund.</p></div>
|
||||
<div class="card"><h3>The rest of the network</h3><p>Open board slots show network sites such as InstantAdPay and LinkSpin. On InstantAdPay, ad credits buy advertising, not income.</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/how.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Banner Line | Banner real estate in one line</title>
|
||||
<meta name="description" content="Banner Line: a $5 spot buys 300 guaranteed views on the board and a place in the line. Paid instantly on-chain when spots sell.">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=1">
|
||||
<link rel="stylesheet" href="/assets/line.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<section class="hero">
|
||||
<h1>Banner real estate on every page in your line, <em>paid instantly on-chain when spots sell.</em></h1>
|
||||
<p class="lead">A $5 spot buys 300 guaranteed views on the board and a place in the line. When a later spot sells, the contract pays the 10 spots above it and the buyer's sponsor in the same transaction. Nothing is promised.</p>
|
||||
</section>
|
||||
|
||||
<section id="gate" class="card" hidden>
|
||||
<h2>Look around first</h2>
|
||||
<p class="muted small" id="gateIntro">A few short steps, then Join unlocks. Each step has a timer. Keep this tab open while it counts down.</p>
|
||||
<ol class="steps" id="gateSteps"></ol>
|
||||
<div class="gate-bar"><span class="count" id="gCount">-</span><span class="what" id="gWhat">Loading...</span>
|
||||
<a class="btn sec small" id="gOpen" target="_blank" rel="noopener" hidden>Open site in a new tab</a>
|
||||
<button class="btn small" id="gNext" hidden>Next</button>
|
||||
<div class="progress"><i id="gProg"></i></div></div>
|
||||
<div id="gStage"></div>
|
||||
</section>
|
||||
|
||||
<section id="open" hidden>
|
||||
<div class="card">
|
||||
<h2>You are in</h2>
|
||||
<p>Get a spot for $5 in POL. It shows on the board until it has 300 views (up to 30 days) and it takes the next place in the line.</p>
|
||||
<div class="row"><a class="btn" id="joinBtn" href="/join">Get a spot</a><a class="btn sec" href="/how">How it works</a><a class="btn quiet" href="/board">See the full board</a></div>
|
||||
</div>
|
||||
<div class="card"><h3>The board</h3><p class="muted small">Newest spots on top.</p><div class="lots" id="lots"></div></div>
|
||||
</section>
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/gate.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Get a spot | Banner Line</title>
|
||||
<meta name="description" content="Banner Line: a $5 spot buys 300 guaranteed views on the board and a place in the line. Paid instantly on-chain when spots sell.">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=1">
|
||||
<link rel="stylesheet" href="/assets/line.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<section class="hero"><h1>Get a spot</h1>
|
||||
<p class="lead">$5 in POL, paid from your own wallet straight to the contract. The site never holds your money.</p></section>
|
||||
<div class="card" id="locked" hidden><h3>Look around first</h3><p>Finish the short tour on the home page (your sponsor's spot, the board, the 3 newest spots), then come back here.</p><a class="btn" id="tourLink" href="/">Start the tour</a></div>
|
||||
<div class="card" id="buyCard" hidden>
|
||||
<h3>What $5 buys</h3>
|
||||
<ul>
|
||||
<li>300 guaranteed views on the board for your 468x60 image and link, delivered within 30 days.</li>
|
||||
<li>A place in the line. Each time one of the next 10 spots sells, the contract sends you $0.275 in POL in that same transaction.</li>
|
||||
<li>When someone you referred buys a spot, you get $1.50 in POL.</li>
|
||||
</ul>
|
||||
<p class="muted small">Nothing is promised. You are paid only when spots sell after yours, and a spot can earn back less than it cost. The other 15% goes to the company (10%) and the momentum fund (5%), which buys spots when sales go quiet.</p>
|
||||
<div class="grid2">
|
||||
<div class="stat"><b id="price">...</b><span>POL for one spot (about $5)</span></div>
|
||||
<div class="stat"><b id="sponsor">...</b><span>your sponsor</span></div>
|
||||
</div>
|
||||
<div class="row" style="margin-top:16px"><button class="btn" id="buyBtn">Connect wallet and buy</button></div>
|
||||
<details style="margin-top:14px"><summary>Buy a spot for someone else</summary>
|
||||
<div class="field"><label for="forAddr" class="small muted">Their wallet address (they own the spot)</label><input id="forAddr" placeholder="0x..."></div>
|
||||
<button class="btn sec small" id="buyForBtn">Buy it for them</button></details>
|
||||
</div>
|
||||
<div id="status" class="note" hidden></div>
|
||||
<div class="card" id="doneCard" hidden><h3>Your spot is in the line</h3><p>Next: add your image and link in <a href="/my">My Spots</a>.</p><p class="small mono" id="txLink"></p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/wallet.js?v=1"></script>
|
||||
<script src="/assets/join.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>My Spots | Banner Line</title>
|
||||
<meta name="description" content="Banner Line: a $5 spot buys 300 guaranteed views on the board and a place in the line. Paid instantly on-chain when spots sell.">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=1">
|
||||
<link rel="stylesheet" href="/assets/line.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
<section class="hero"><h1>My Spots</h1><p class="lead">Your spots, your images and links, and every payment the contract sent you.</p></section>
|
||||
<div class="card" id="signin" hidden><h3>Sign in with your wallet</h3><p class="muted small">You sign a short message. It is free and cannot move funds or approve anything.</p><button class="btn" id="signBtn">Sign in</button></div>
|
||||
<div id="dash" hidden>
|
||||
<div class="card"><div class="row" style="justify-content:space-between"><div><span class="muted small">Signed in as</span> <span class="mono" id="me"></span></div><button class="btn quiet small" id="outBtn">Sign out</button></div>
|
||||
<div class="grid2" style="margin-top:12px" id="stats"></div></div>
|
||||
<div class="card"><h3>Your share link</h3><p class="muted small">People who join through this link have you as their sponsor. It is set once, on their first spot.</p>
|
||||
<div class="field"><input id="share" readonly></div><button class="btn sec small" id="copyBtn">Copy link</button></div>
|
||||
<div class="card"><h3>Spots</h3><p class="muted small">Image: 468x60 PNG, JPG or GIF up to 150 KB, or an https image address. Link: https only. Change them any time. A spot with no image shows your default, or a network image until you add one.</p>
|
||||
<div id="spots"></div></div>
|
||||
<div class="card"><h3>Default image and link</h3><p class="muted small">Used by any spot you have not set up.</p><div id="defaults"></div></div>
|
||||
<div class="card"><h3>Payments to you</h3><div id="payouts"></div></div>
|
||||
<div class="card"><h3>Your direct members</h3><div id="directs"></div></div>
|
||||
</div>
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/wallet.js?v=1"></script>
|
||||
<script src="/assets/my.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
Disallow: /my
|
||||
Disallow: /api/
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
// Banner Line local smoke test. Everything runs on this machine: a throwaway anvil chain, the REAL BannerLine
|
||||
// contract (compiled artifacts read from ../contracts/out, nothing written there) with its mock $2000 feed,
|
||||
// the app server against that chain, HTTP checks of every API, and Playwright page renders + a full UI gate run.
|
||||
// No real network, no real wallet, no real money. Keys used are anvil's public test keys.
|
||||
//
|
||||
// node qa/smoke.mjs (needs ~/.foundry/bin/anvil.exe and contracts/out built)
|
||||
// SKIP_UI=1 node qa/smoke.mjs (API checks only)
|
||||
import { spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import zlib from 'node:zlib';
|
||||
import os from 'node:os';
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const require = createRequire(import.meta.url);
|
||||
const { ethers } = require('ethers');
|
||||
|
||||
const APP = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const OUT = path.join(APP, 'qa', 'out'); fs.mkdirSync(OUT, { recursive: true });
|
||||
const ART = path.resolve(APP, '..', 'contracts', 'out');
|
||||
const ANVIL = process.env.ANVIL || path.join(os.homedir(), '.foundry', 'bin', 'anvil.exe');
|
||||
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||
const RPC_PORT = Number(process.env.SMOKE_RPC_PORT || 18645), APP_PORT = Number(process.env.SMOKE_APP_PORT || 3111), BASE = 'http://127.0.0.1:' + APP_PORT;
|
||||
const ADMIN = 'smoke-admin';
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
let pass = 0, fail = 0; const procs = [];
|
||||
const ok = (cond, what, extra) => { if (cond) { pass++; console.log(' ok ' + what); } else { fail++; console.log(' FAIL ' + what + (extra !== undefined ? ' -> ' + JSON.stringify(extra).slice(0, 300) : '')); } };
|
||||
function cleanup() { for (const p of procs) { try { p.kill(); } catch (e) {} } }
|
||||
process.on('exit', cleanup);
|
||||
|
||||
// ---- tiny cookie-jar HTTP client ----
|
||||
function client(ua) {
|
||||
const jar = {};
|
||||
return {
|
||||
jar,
|
||||
async req(p, opts = {}) {
|
||||
const headers = Object.assign({ 'User-Agent': ua || 'Mozilla/5.0 smoke', Cookie: Object.entries(jar).map(([k, v]) => k + '=' + v).join('; ') }, opts.headers || {});
|
||||
const r = await fetch(BASE + p, { method: opts.method || 'GET', headers, body: opts.body, redirect: 'manual' });
|
||||
for (const c of r.headers.getSetCookie ? r.headers.getSetCookie() : []) { const [kv] = c.split(';'); const i = kv.indexOf('='); jar[kv.slice(0, i)] = kv.slice(i + 1); }
|
||||
return r;
|
||||
},
|
||||
async json(p, body, extraHeaders) { const r = await this.req(p, body === undefined ? { headers: extraHeaders } : { method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, extraHeaders), body: JSON.stringify(body) }); return Object.assign({ _status: r.status }, await r.json().catch(() => ({}))); }
|
||||
};
|
||||
}
|
||||
function png(w, h) {
|
||||
const crcT = Array.from({ length: 256 }, (_, n) => { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; return c >>> 0; });
|
||||
const crc = b => { let c = 0xffffffff; for (const x of b) c = crcT[(c ^ x) & 255] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
||||
const chunk = (t, d) => { const len = Buffer.alloc(4); len.writeUInt32BE(d.length); const td = Buffer.concat([Buffer.from(t), d]); const c = Buffer.alloc(4); c.writeUInt32BE(crc(td)); return Buffer.concat([len, td, c]); };
|
||||
const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(w, 0); ihdr.writeUInt32BE(h, 4); ihdr[8] = 8; ihdr[9] = 2;
|
||||
const raw = Buffer.alloc((w * 3 + 1) * h); for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const o = y * (w * 3 + 1) + 1 + x * 3; raw[o] = 40 + x % 200; raw[o + 1] = 120; raw[o + 2] = 90 + y * 2; }
|
||||
return Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), chunk('IHDR', ihdr), chunk('IDAT', zlib.deflateSync(raw)), chunk('IEND', Buffer.alloc(0))]);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// ---- 1. chain ----
|
||||
console.log('1. anvil + contract');
|
||||
// never talk to someone else's node: the port must be free before our anvil starts
|
||||
const busy = await fetch('http://127.0.0.1:' + RPC_PORT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}' }).then(() => true, () => false);
|
||||
if (busy) throw new Error('port ' + RPC_PORT + ' is already in use; set SMOKE_RPC_PORT');
|
||||
const appBusy = await fetch('http://127.0.0.1:' + APP_PORT).then(() => true, () => false);
|
||||
if (appBusy) throw new Error('port ' + APP_PORT + ' is already in use; set SMOKE_APP_PORT');
|
||||
const anvil = spawn(ANVIL, ['--port', String(RPC_PORT), '--silent'], { stdio: 'ignore' }); procs.push(anvil);
|
||||
const provider = new ethers.JsonRpcProvider('http://127.0.0.1:' + RPC_PORT, 31337, { staticNetwork: true, pollingInterval: 200 });
|
||||
for (let i = 0; i < 50; i++) { try { await provider.getBlockNumber(); break; } catch (e) { await sleep(200); } }
|
||||
const W = Array.from({ length: 10 }, (_, i) => new ethers.NonceManager(ethers.HDNodeWallet.fromPhrase('test test test test test test test test test test test junk', undefined, "m/44'/60'/0'/0/" + i).connect(provider)));
|
||||
const addr = await Promise.all(W.map(w => w.getAddress()));
|
||||
const art = n => JSON.parse(fs.readFileSync(path.join(ART, n + '.sol', n + '.json'), 'utf8'));
|
||||
const feedA = art('MockV3Aggregator'), lineA = art('BannerLine');
|
||||
const feed = await (await new ethers.ContractFactory(feedA.abi, feedA.bytecode.object, W[0]).deploy(200000000000n)).waitForDeployment();
|
||||
const deployBlock = await provider.getBlockNumber();
|
||||
const line = await (await new ethers.ContractFactory(lineA.abi, lineA.bytecode.object, W[0]).deploy(addr[8], addr[9], addr[7], await feed.getAddress())).waitForDeployment();
|
||||
const CA = await line.getAddress();
|
||||
const q = await line.quoteWei(); ok(q === 2500000000000000n, 'quoteWei = 0.0025 POL at $2000', q.toString());
|
||||
const send = q + q / 100n;
|
||||
const [A, B, Cc, D, E, F] = [1, 2, 3, 4, 5, 6];
|
||||
const buy = async (i, sponsor) => (await line.connect(W[i]).buy(sponsor, { value: send })).wait();
|
||||
await buy(A, ethers.ZeroAddress); await buy(B, addr[A]); await buy(Cc, addr[B]); await buy(D, addr[B]);
|
||||
await (await line.connect(W[F]).buyFor(addr[E], addr[A], { value: send })).wait();
|
||||
await buy(A, ethers.ZeroAddress); await buy(0, ethers.ZeroAddress); // no-sponsor buys feed the momentum fund enough for one keeper buy
|
||||
ok(Number(await line.spotCount()) === 7, '7 spots bought on anvil');
|
||||
const paidTo = async a => (await line.queryFilter(line.filters.Paid(null, a), deployBlock)).reduce((t, e) => t + e.args.amount, 0n);
|
||||
|
||||
// ---- 2. server ----
|
||||
console.log('2. server');
|
||||
const DATA = path.join(OUT, 'data-' + Date.now()); fs.mkdirSync(DATA, { recursive: true });
|
||||
// house list for tests: reserved example domains only, so no real site sees test traffic
|
||||
fs.writeFileSync(path.join(DATA, 'house.json'), JSON.stringify([{ key: 'one', title: 'Test house 1', img: '/art/house-iap.svg', link: 'https://example.com/' }, { key: 'two', title: 'Test house 2', img: '/art/house-linkspin.svg', link: 'https://example.net/' }]));
|
||||
const env = Object.assign({}, process.env, { PORT: String(APP_PORT), DATA_DIR: DATA, CHAIN_ID: '31337', RPC_URLS: 'http://127.0.0.1:' + RPC_PORT, CONTRACT_ADDRESS: CA,
|
||||
DEPLOY_BLOCK: String(deployBlock), POLL_MS: '1000', ADMIN_TOKEN: ADMIN, KEEPER_ENABLED: '1', KEEPER_KEY: W[7].signer.privateKey, KEEPER_STALL_HOURS: '0.01', KEEPER_EVERY_MIN: '0.25', NODE_ENV: 'development' });
|
||||
const srv = spawn(process.execPath, ['server.js'], { cwd: APP, env, stdio: ['ignore', 'pipe', 'pipe'] }); procs.push(srv);
|
||||
const log = fs.createWriteStream(path.join(OUT, 'server.log')); srv.stdout.pipe(log); srv.stderr.pipe(log);
|
||||
const u = client();
|
||||
for (let i = 0; i < 60; i++) { try { const s = await u.json('/api/stats'); if (s.totals && s.totals.spots >= 7) break; } catch (e) {} await sleep(300); }
|
||||
const st = await u.json('/api/stats');
|
||||
ok(st.totals && st.totals.spots === 7, 'index parsed 7 SpotBought', st.totals);
|
||||
ok(st.totals && st.totals.members === 6, 'index parsed 6 MemberJoined (payer of a buyFor is not a member)', st.totals);
|
||||
ok(BigInt(st.totals.paidInWei) === 7n * q, 'paid in = 7 x quote (refunds excluded)', st.totals.paidInWei);
|
||||
const cfg = await u.json('/api/config'); ok(cfg.ready && cfg.sel.buy === '0xf088d547', '/api/config has contract + selectors');
|
||||
const qq = await u.json('/api/quote'); ok(qq.wei === q.toString() && qq.source === 'contract.quoteWei', '/api/quote reads quoteWei()', qq);
|
||||
for (const p of ['/', '/board', '/join', '/my', '/how', '/assets/site.css', '/art/house-line.svg']) { const r = await u.req(p); ok(r.status === 200, 'GET ' + p + ' 200'); }
|
||||
const r404 = await u.req('/nope'); ok(r404.status === 404, 'unknown path 404');
|
||||
const myHdr = await u.req('/my'); ok(myHdr.headers.get('x-frame-options') === 'DENY' && !(await u.req('/')).headers.get('x-frame-options'), '/my not frameable, / frameable');
|
||||
|
||||
// ---- 3. gate (HTTP) ----
|
||||
console.log('3. gate over HTTP (about 50 s of timers)');
|
||||
const v = client(); await v.req('/?ref=' + addr[B]);
|
||||
ok(!!v.jar['bl.ref'], 'ref cookie set from ?ref=');
|
||||
const g = await v.json('/api/gate');
|
||||
ok(!g.passed && g.steps && g.steps[0].role === 'sponsor', 'gate starts with the sponsor spot', g.steps && g.steps.map(s => s.role || s.type));
|
||||
ok(g.steps && g.steps[1].type === 'board' && g.steps.filter(s => s.role === 'newest').length === 3, 'board step then 3 newest spots');
|
||||
const early = await v.json('/api/gate/done', { gid: g.gid, i: 0 }); ok(early._status === 400, 'done before begin is refused');
|
||||
let passedGate = false;
|
||||
for (let i = 0; i < g.steps.length; i++) {
|
||||
const s = g.steps[i];
|
||||
await v.json('/api/gate/begin', { gid: g.gid, i });
|
||||
if (s.type === 'visit') { const r = await v.req(s.open + '?g=' + g.gid + '&i=' + i); ok(r.status === 302, 'step ' + i + ' visit relays (302 to ' + r.headers.get('location') + ')'); }
|
||||
if (i === 0) { const tooSoon = await v.json('/api/gate/done', { gid: g.gid, i }); ok(tooSoon._status === 400, 'done before the timer is refused'); }
|
||||
await sleep(s.seconds * 1000);
|
||||
const d = await v.json('/api/gate/done', { gid: g.gid, i });
|
||||
if (d.passed) passedGate = true; else if (d.error) ok(false, 'step ' + i + ' done', d);
|
||||
}
|
||||
ok(passedGate && !!v.jar['bl.pass'], 'gate passed, pass cookie set');
|
||||
ok((await v.json('/api/gate')).passed === true, 'gate reports passed on return');
|
||||
const st2 = await u.json('/api/stats'); const day = Object.values(st2.daily || {}).pop() || {};
|
||||
ok(day.views_gate >= 7 && day.clicks_gate >= 4, 'gate views + gate clicks stored apart', day);
|
||||
const bot = client('Googlebot/2.1'); ok((await bot.json('/api/gate')).passed === true, 'bots skip the gate');
|
||||
|
||||
// ---- 4. organic board view ----
|
||||
const bd = await v.json('/api/board'); ok(bd.tiles && bd.tiles.filter(t => t.t === 'spot').length >= 7 && bd.tiles[0].id > bd.tiles[1].id && bd.tiles.some(t => t.t === 'house'), 'board: all spots newest first + house fill', bd.tiles && bd.tiles.map(t => t.id || t.key));
|
||||
const fast = await v.json('/api/board/seen', { token: bd.token }); ok(fast.counted === 0, 'board view before 5 s not counted');
|
||||
const bd2 = await v.json('/api/board'); await sleep(5000);
|
||||
const gateIds = new Set(g.steps[1].tiles.filter(t => t.t === 'spot').map(t => t.id)); const fresh = bd2.tiles.filter(t => t.t === 'spot' && !gateIds.has(t.id)).length; // a keeper spot may be new
|
||||
const seen = await v.json('/api/board/seen', { token: bd2.token }); ok(seen.counted === fresh, 'same visitor within the hour: views not double counted', [seen, fresh]);
|
||||
const v2 = client('Mozilla/5.0 other'); const bd3 = await v2.json('/api/board'); await sleep(5000);
|
||||
const seen3 = await v2.json('/api/board/seen', { token: bd3.token }); ok(seen3.counted === bd3.tiles.filter(t => t.t === 'spot').length && seen3.counted > 0, 'new visitor organic views counted', seen3);
|
||||
ok((await v2.json('/api/board/seen', { token: bd3.token })).counted === 0, 'board token is one-time');
|
||||
|
||||
// ---- 5. sign in + My Spots ----
|
||||
console.log('5. sign-in + My Spots');
|
||||
const m = client();
|
||||
const ch = await m.json('/api/auth/challenge', { address: addr[A] });
|
||||
const sig = await W[A].signer.signMessage(ch.message);
|
||||
const bad = await m.json('/api/auth/verify', { address: addr[A], signature: await W[B].signer.signMessage(ch.message) }); ok(bad._status === 400, 'signature from another wallet refused');
|
||||
const ch2 = await m.json('/api/auth/challenge', { address: addr[A] });
|
||||
const ver = await m.json('/api/auth/verify', { address: addr[A], signature: await W[A].signer.signMessage(ch2.message) });
|
||||
ok(ver.ok && !!m.jar['bl.sid'], 'wallet signature sign-in sets session', ver);
|
||||
const my = await m.json('/api/my');
|
||||
ok(my.spots && my.spots.length >= 2, 'A owns 2+ spots', my.spots && my.spots.length);
|
||||
let my2 = my, onChain = await paidTo(addr[A]);
|
||||
if (BigInt(my2.paidOutWei) !== onChain) { await sleep(2500); my2 = await m.json('/api/my'); onChain = await paidTo(addr[A]); } // a keeper buy may land in between
|
||||
ok(BigInt(my2.paidOutWei) === onChain && onChain > 0n, 'A paid out matches Paid events on chain (' + ethers.formatEther(onChain) + ' POL)', my2.paidOutWei);
|
||||
ok(BigInt(my.paidInWei) === 2n * q, 'A paid in = 2 spots', my.paidInWei);
|
||||
ok(my.directs && my.directs.length === 2 && my.directs.some(x => x.address === addr[B].toLowerCase()), 'A directs = B and E (buyFor sponsor)', my.directs);
|
||||
ok(my.share.endsWith('?ref=' + addr[A].toLowerCase()), 'share link');
|
||||
const sid = my.spots[my.spots.length - 1].id;
|
||||
ok((await m.json('/api/my/spot/' + sid, { link: 'http://example.org/' }))._status === 400, 'http link refused');
|
||||
ok((await m.json('/api/my/spot/' + sid, { link: 'https://192.168.1.1/' }))._status === 400, 'IP link refused');
|
||||
ok((await m.json('/api/my/spot/' + sid, { link: 'https://bit.ly/x' }))._status === 400, 'shortener refused');
|
||||
ok((await m.json('/api/my/spot/' + sid, { link: 'javascript:alert(1)' }))._status === 400, 'javascript: refused');
|
||||
ok((await m.json('/api/my/spot/' + sid, { link: 'https://example.org/landing' })).ok, 'https link saved');
|
||||
const otherSpot = (await u.json('/api/stats')).recent.find(s => s.owner === addr[B].toLowerCase());
|
||||
ok((await m.json('/api/my/spot/' + otherSpot.id, { link: 'https://example.org/' }))._status === 403, 'cannot edit someone else\'s spot');
|
||||
const up = await (await m.req('/api/my/upload?for=' + sid, { method: 'POST', headers: { 'Content-Type': 'image/png' }, body: png(468, 60) })).json();
|
||||
ok(up.ok && /^\/art\/u\//.test(up.img), 'PNG 468x60 upload saved', up);
|
||||
ok((await m.req(up.img)).status === 200, 'uploaded image served');
|
||||
const upBad = await (await m.req('/api/my/upload?for=' + sid, { method: 'POST', headers: { 'Content-Type': 'image/png' }, body: png(300, 250) })).json();
|
||||
ok(!!upBad.error, 'wrong size refused', upBad);
|
||||
const upBig = await m.req('/api/my/upload?for=' + sid, { method: 'POST', headers: { 'Content-Type': 'image/png' }, body: Buffer.concat([png(468, 60), Buffer.alloc(160 * 1024)]) });
|
||||
ok(upBig.status === 400, 'over 150 KB refused');
|
||||
ok((await m.json('/api/my/default', { link: 'https://example.org/default' })).ok, 'default link saved');
|
||||
const bd4 = await v.json('/api/board'); const t = bd4.tiles.find(x => x.id === sid);
|
||||
ok(t && t.img === up.img, 'board shows the uploaded image for that spot');
|
||||
const go = await v.req('/go/' + sid); ok(go.headers.get('location') === 'https://example.org/landing', 'click relay goes to the member link');
|
||||
|
||||
// ---- 6. keeper ----
|
||||
console.log('6. keeper (stall set to 36 s for the test)');
|
||||
const adm = await u.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
|
||||
ok(adm.keeper && adm.keeper.enabled && !JSON.stringify(adm).includes(W[7].signer.privateKey.slice(2, 20)), 'keeper on, key never in output');
|
||||
let fb = null;
|
||||
for (let i = 0; i < 40 && !fb; i++) { const s = await u.json('/api/stats'); fb = (s.recent || []).find(x => x.kind === 2 || x.kind === 3); if (!fb) await sleep(2000); }
|
||||
ok(fb && fb.kind === 2 && fb.owner === addr[A].toLowerCase(), 'keeper fundBuy gifted a spot to A (builder, longest wait)', fb);
|
||||
const adm2 = await u.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN });
|
||||
ok(adm2.keeper.log.some(e => e.status === 'mined'), 'keeper log shows the mined tx', adm2.keeper.log.slice(0, 3));
|
||||
const logTxt = fs.readFileSync(path.join(OUT, 'server.log'), 'utf8');
|
||||
ok(!logTxt.includes(W[7].signer.privateKey.slice(2)), 'keeper key not in server log');
|
||||
|
||||
// ---- 7. pages in a browser ----
|
||||
if (!process.env.SKIP_UI) {
|
||||
console.log('7. Playwright: page renders + full UI gate');
|
||||
const { chromium } = require(PW);
|
||||
const browser = await chromium.launch();
|
||||
const errors = [];
|
||||
const watch = (pg, name) => { pg.on('console', msg => { if (msg.type() === 'error') errors.push(name + ': ' + msg.text() + ' @ ' + ((msg.location() || {}).url || '')); }); pg.on('pageerror', e => errors.push(name + ': ' + e.message)); };
|
||||
// member context: signed in, gate skipped
|
||||
const ctxM = await browser.newContext(); await ctxM.addCookies([{ name: 'bl.sid', value: m.jar['bl.sid'], url: BASE }]);
|
||||
for (const p of ['/', '/board', '/how', '/join', '/my']) {
|
||||
const pg = await ctxM.newPage(); watch(pg, 'member ' + p);
|
||||
await pg.goto(BASE + p, { waitUntil: 'networkidle' });
|
||||
await pg.screenshot({ path: path.join(OUT, 'member' + (p === '/' ? '-home' : p.replace('/', '-')) + '.png'), fullPage: true });
|
||||
const foot = await pg.textContent('footer').catch(() => ''); ok(/Part of the Crypto Team Build Network/.test(foot || ''), 'member ' + p + ' renders with footer');
|
||||
if (p === '/my') { await pg.waitForSelector('#dash:not([hidden])', { timeout: 8000 }).catch(() => {}); ok(await pg.isVisible('#dash'), '/my dashboard visible'); ok((await pg.$$('.spot-ed')).length >= 3, '/my spot editors listed'); }
|
||||
if (p === '/join') { await pg.waitForSelector('#buyCard:not([hidden])', { timeout: 8000 }).catch(() => {}); const price = await pg.textContent('#price'); ok(/^0\.0025/.test(price), '/join shows price ' + price); }
|
||||
const em = await pg.evaluate(() => document.body.innerText.includes('\u2014')); ok(!em, p + ' has no em dash');
|
||||
await pg.close();
|
||||
}
|
||||
// visitor context: full gate in the UI
|
||||
const ctxV = await browser.newContext(); const pg = await ctxV.newPage(); watch(pg, 'visitor /');
|
||||
await pg.goto(BASE + '/?ref=' + addr[B], { waitUntil: 'domcontentloaded' });
|
||||
await pg.waitForSelector('#gate:not([hidden])');
|
||||
for (let i = 0; i < 8; i++) {
|
||||
await pg.waitForSelector('#gNext:not([hidden])', { timeout: 20000 });
|
||||
const label = await pg.textContent('#gNext'); await pg.click('#gNext');
|
||||
if (label === 'Continue') break;
|
||||
}
|
||||
await pg.waitForSelector('#open:not([hidden])', { timeout: 5000 }).catch(() => {});
|
||||
ok(await pg.isVisible('#joinBtn'), 'UI gate completes and Join unlocks');
|
||||
await pg.screenshot({ path: path.join(OUT, 'visitor-after-gate.png'), fullPage: true });
|
||||
const pj = await ctxV.newPage(); watch(pj, 'visitor /join'); await pj.goto(BASE + '/join', { waitUntil: 'networkidle' });
|
||||
ok(await pj.isVisible('#buyCard'), 'visitor /join unlocked after gate');
|
||||
// fresh visitor: /join is locked
|
||||
// visitor = IP + UA, so a fresh visitor needs its own UA
|
||||
const ctxL = await browser.newContext({ userAgent: 'Mozilla/5.0 (fresh visitor) Chrome/130' }); const pl = await ctxL.newPage(); watch(pl, 'locked /join'); await pl.goto(BASE + '/join', { waitUntil: 'networkidle' });
|
||||
ok(await pl.isVisible('#locked'), 'fresh visitor /join is locked');
|
||||
const pm = await ctxL.newPage(); watch(pm, 'signed-out /my'); await pm.goto(BASE + '/my', { waitUntil: 'networkidle' }); ok(await pm.isVisible('#signin'), 'signed-out /my shows sign-in');
|
||||
await browser.close();
|
||||
// example.com pages inside the gate frame may log their own errors; only ours count
|
||||
const ours = errors.filter(e => !/example\.(com|net|org)/.test(e)); // gate frames load example.* sites; their own 404s (favicon) are not ours
|
||||
ok(ours.length === 0, 'no console errors on our pages', ours);
|
||||
}
|
||||
console.log('\n' + pass + ' passed, ' + fail + ' failed. Output in ' + OUT);
|
||||
cleanup(); process.exit(fail ? 1 : 0);
|
||||
}
|
||||
main().catch(e => { console.error(e); cleanup(); process.exit(1); });
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copy the compiled BannerLine abi into the app (run after `forge build` in ../contracts).
|
||||
const fs = require('fs'), path = require('path');
|
||||
const src = path.join(__dirname, '..', '..', 'contracts', 'out', 'BannerLine.sol', 'BannerLine.json');
|
||||
fs.writeFileSync(path.join(__dirname, '..', 'contract-abi.json'), JSON.stringify(require(src).abi, null, 1));
|
||||
console.log('contract-abi.json updated from', src);
|
||||
@@ -0,0 +1,57 @@
|
||||
// Link + image checks for My Spots. https only, a real public hostname, no tricks; uploads must be a real
|
||||
// PNG/JPG/GIF at 468x60 (or 936x120 retina) and at most 150 KB.
|
||||
const net = require('net');
|
||||
|
||||
const MAX_UPLOAD = 150 * 1024;
|
||||
const BAD_HOST = /(^|\.)(localhost|local|internal|lan|home|corp|onion|test|invalid|example)$/i;
|
||||
// shorteners and redirectors hide where a click goes; a member link must show its real destination
|
||||
const REDIRECTORS = /(^|\.)(bit\.ly|tinyurl\.com|t\.co|goo\.gl|is\.gd|cutt\.ly|ow\.ly|rebrand\.ly|shorturl\.at|rb\.gy|s\.id|t\.ly|v\.gd|bl\.ink|tiny\.cc)$/i;
|
||||
|
||||
function checkLink(raw, what) {
|
||||
what = what || 'Link';
|
||||
const s = String(raw || '').trim();
|
||||
if (!s) return { error: what + ' is empty.' };
|
||||
if (s.length > 600) return { error: what + ' is too long (600 characters max).' };
|
||||
if (/[\s<>"'`\\]/.test(s)) return { error: what + ' has spaces or characters a web address cannot have.' };
|
||||
let u; try { u = new URL(s); } catch (e) { return { error: what + ' is not a valid web address.' }; }
|
||||
if (u.protocol !== 'https:') return { error: what + ' must start with https://' };
|
||||
if (u.username || u.password) return { error: what + ' cannot contain a username or password.' };
|
||||
const h = u.hostname.toLowerCase().replace(/\.$/, '');
|
||||
if (net.isIP(h.replace(/^\[|\]$/g, ''))) return { error: what + ' must use a domain name, not an IP address.' };
|
||||
if (!h.includes('.') || BAD_HOST.test(h)) return { error: what + ' must point to a public website.' };
|
||||
if (!/^[a-z0-9.-]+$/.test(h) && !/^xn--/.test(h)) return { error: what + ' has an unusual domain name.' };
|
||||
if (REDIRECTORS.test(h)) return { error: 'Use the real destination, not a link shortener.' };
|
||||
if (u.port && !['443', ''].includes(u.port)) return { error: what + ' must use the normal https port.' };
|
||||
return { ok: true, url: u.toString() };
|
||||
}
|
||||
|
||||
function imageInfo(buf) {
|
||||
if (!buf || buf.length < 24) return null;
|
||||
if (buf.slice(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])))
|
||||
return { type: 'png', ext: '.png', w: buf.readUInt32BE(16), h: buf.readUInt32BE(20) };
|
||||
if (buf.slice(0, 6).toString('latin1') === 'GIF87a' || buf.slice(0, 6).toString('latin1') === 'GIF89a')
|
||||
return { type: 'gif', ext: '.gif', w: buf.readUInt16LE(6), h: buf.readUInt16LE(8) };
|
||||
if (buf[0] === 0xff && buf[1] === 0xd8) {
|
||||
let i = 2;
|
||||
while (i + 9 < buf.length) {
|
||||
if (buf[i] !== 0xff) { i++; continue; }
|
||||
const m = buf[i + 1];
|
||||
if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) return { type: 'jpg', ext: '.jpg', h: buf.readUInt16BE(i + 5), w: buf.readUInt16BE(i + 7) };
|
||||
if (m === 0xd8 || m === 0x01 || (m >= 0xd0 && m <= 0xd7)) { i += 2; continue; }
|
||||
i += 2 + buf.readUInt16BE(i + 2);
|
||||
}
|
||||
return { type: 'jpg', ext: '.jpg', w: 0, h: 0 };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function checkImage(buf) {
|
||||
if (!buf || !buf.length) return { error: 'No file received.' };
|
||||
if (buf.length > MAX_UPLOAD) return { error: 'That file is ' + Math.ceil(buf.length / 1024) + ' KB. The limit is 150 KB.' };
|
||||
const info = imageInfo(buf);
|
||||
if (!info) return { error: 'Upload a PNG, JPG or GIF file.' };
|
||||
const ok = (info.w === 468 && info.h === 60) || (info.w === 936 && info.h === 120);
|
||||
if (!ok) return { error: 'The image is ' + info.w + 'x' + info.h + '. It must be 468x60 (or 936x120).' };
|
||||
return { ok: true, info };
|
||||
}
|
||||
|
||||
module.exports = { checkLink, checkImage, imageInfo, MAX_UPLOAD };
|
||||
@@ -0,0 +1,331 @@
|
||||
// Banner Line web app (downlinebanners.com). Plain Node http server, no framework (InstantAdPay pattern).
|
||||
// Pages: / (gate, then board + join), /board, /join (buy), /my (My Spots + dashboard), /how.
|
||||
// Chain index: chain.js. Board/rotation: board.js. Creative + link checks: safety.js. Keeper: keeper.js.
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const { verifyMessage, getAddress } = require('ethers');
|
||||
const cfgMod = require('./config');
|
||||
const chain = require('./chain');
|
||||
const store = require('./store');
|
||||
const board = require('./board');
|
||||
const safety = require('./safety');
|
||||
const keeper = require('./keeper');
|
||||
const { iface } = require('./abi');
|
||||
const SEL = { buy: iface.getFunction('buy').selector, buyFor: iface.getFunction('buyFor').selector }; // the browser builds calldata from these (ABI stays in abi.js)
|
||||
|
||||
const C = cfgMod.get();
|
||||
fs.mkdirSync(path.join(C.dataDir, 'art'), { recursive: true });
|
||||
store.load();
|
||||
chain.init();
|
||||
keeper.init();
|
||||
|
||||
const PUB = path.join(__dirname, 'public');
|
||||
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||
const BOT_UA = /bot|crawl|spider|slurp|facebookexternalhit|preview|monitor|wget|curl|python-requests|httpclient|scrapy|semrush|ahrefs/i;
|
||||
const SECRET = (() => {
|
||||
if (process.env.SESSION_SECRET) return process.env.SESSION_SECRET;
|
||||
const f = path.join(C.dataDir, '.secret');
|
||||
try { return fs.readFileSync(f, 'utf8').trim(); } catch (e) {}
|
||||
const s = crypto.randomBytes(32).toString('hex'); try { fs.writeFileSync(f, s, { mode: 0o600 }); } catch (e) {} return s;
|
||||
})();
|
||||
const hmac = s => crypto.createHmac('sha256', SECRET).update(s).digest('hex').slice(0, 32);
|
||||
|
||||
// ---- http helpers ----
|
||||
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg',
|
||||
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8' };
|
||||
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
|
||||
+ "img-src 'self' data: blob: https:; connect-src 'self' https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org "
|
||||
+ "https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com; "
|
||||
+ "font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: 'self'";
|
||||
function headers(extra) { return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {}); }
|
||||
function json(res, code, obj, extra) { res.writeHead(code, headers(Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }, extra))); res.end(JSON.stringify(obj)); }
|
||||
function sendFile(res, file, extra) {
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) { res.writeHead(404, headers({ 'Content-Type': 'text/plain' })); return res.end('Not found'); }
|
||||
const ext = path.extname(file).toLowerCase();
|
||||
res.writeHead(200, headers(Object.assign({ 'Content-Type': MIME[ext] || 'application/octet-stream', 'Cache-Control': ext === '.html' ? 'no-store, must-revalidate' : 'public, max-age=3600' }, extra)));
|
||||
res.end(data);
|
||||
});
|
||||
}
|
||||
function readRaw(req, max) {
|
||||
return new Promise((resolve, reject) => { const ch = []; let n = 0;
|
||||
// over the limit: keep draining (so the 400 reaches the client) but store nothing; cut the socket only far past it
|
||||
req.on('data', c => { n += c.length; if (n > max * 8) { req.destroy(); return; } if (n <= max) ch.push(c); });
|
||||
req.on('end', () => n > max ? reject(new Error('too big')) : resolve(Buffer.concat(ch))); req.on('error', reject); });
|
||||
}
|
||||
async function readBody(req) { const b = await readRaw(req, 32 * 1024); try { return b.length ? JSON.parse(b.toString('utf8')) : {}; } catch (e) { return {}; } }
|
||||
function cookies(req) { const o = {}; for (const p of (req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { o[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } } return o; }
|
||||
function cookie(name, val, maxAgeSec, httpOnly) { return name + '=' + encodeURIComponent(val) + '; Path=/; SameSite=Lax; Max-Age=' + maxAgeSec + (httpOnly ? '; HttpOnly' : '') + (C.isProd ? '; Secure' : ''); }
|
||||
function ip(req) { return String(req.headers['cf-connecting-ip'] || (req.headers['x-forwarded-for'] || '').split(',')[0] || req.socket.remoteAddress || '').trim(); }
|
||||
const isBot = req => BOT_UA.test(req.headers['user-agent'] || '') || !req.headers['user-agent'];
|
||||
// visitor = IP + user agent (not a cookie: traffic-exchange frames drop cookies, and the gate must work there)
|
||||
function visitorKey(req) { return crypto.createHash('sha256').update(ip(req) + '|' + (req.headers['user-agent'] || '')).digest('hex').slice(0, 20); }
|
||||
|
||||
// per-IP fixed-window limiter
|
||||
const buckets = new Map();
|
||||
function limited(req, name, max, windowMs) {
|
||||
const k = name + ':' + ip(req); const now = Date.now(); let b = buckets.get(k);
|
||||
if (!b || now - b.t > windowMs) { b = { t: now, n: 0 }; buckets.set(k, b); }
|
||||
if (buckets.size > 100000) buckets.clear();
|
||||
return ++b.n > max;
|
||||
}
|
||||
|
||||
// ---- sponsor ref (?ref=<address or InstantAdPay username>) ----
|
||||
const refCache = new Map();
|
||||
async function resolveRef(raw) {
|
||||
const r = String(raw || '').trim();
|
||||
if (ADDR_RE.test(r)) return r.toLowerCase();
|
||||
if (!/^[a-zA-Z0-9_.-]{2,32}$/.test(r) || !C.iapResolveUrl) return null;
|
||||
const hit = refCache.get(r.toLowerCase()); if (hit && Date.now() - hit.at < 3600000) return hit.a;
|
||||
let a = null;
|
||||
try { const ac = new AbortController(); setTimeout(() => ac.abort(), 4000).unref();
|
||||
const j = await (await fetch(C.iapResolveUrl + encodeURIComponent(r), { signal: ac.signal })).json();
|
||||
if (j && ADDR_RE.test(j.address || '')) a = j.address.toLowerCase(); } catch (e) {}
|
||||
refCache.set(r.toLowerCase(), { at: Date.now(), a }); return a;
|
||||
}
|
||||
const sponsorOf = req => { const v = cookies(req)['bl.ref']; return ADDR_RE.test(v || '') ? v.toLowerCase() : null; };
|
||||
|
||||
// ---- sessions (wallet signature sign-in) ----
|
||||
const challenges = new Map();
|
||||
function session(req) { const s = store.session(cookies(req)['bl.sid']); return s; }
|
||||
|
||||
// ---- gate ----
|
||||
const gates = new Map(); // gid -> plan
|
||||
const GATE_TTL = 2 * 3600000;
|
||||
function passToken(vk) { const exp = Date.now() + 24 * 3600000; return exp + '.' + hmac('pass:' + vk + ':' + exp); }
|
||||
const passedKeys = new Map(); // vk -> expiry, for visitors whose browser dropped the pass cookie (framed)
|
||||
function passed(req) {
|
||||
const vk = visitorKey(req);
|
||||
if ((passedKeys.get(vk) || 0) > Date.now()) return true;
|
||||
const t = cookies(req)['bl.pass'] || ''; const [exp, sig] = t.split('.');
|
||||
return Number(exp) > Date.now() && sig === hmac('pass:' + vk + ':' + exp);
|
||||
}
|
||||
async function visitStep(role, ref, img, link, title) {
|
||||
return { type: 'visit', role, ref: String(ref), img, title: title || '', seconds: C.gateVisitSeconds, frame: await board.frameable(link), open: '/go/' + ref };
|
||||
}
|
||||
async function makeGate(req) {
|
||||
const vk = visitorKey(req); const steps = [];
|
||||
const sp = sponsorOf(req); const sSpot = sp && board.newestOf(sp);
|
||||
if (sSpot) { const cr = board.creative(sSpot); steps.push(await visitStep('sponsor', sSpot.id, cr.img, cr.link, 'Your sponsor\'s newest spot')); }
|
||||
steps.push({ type: 'board', tiles: board.pick(), seconds: C.gateBoardSeconds });
|
||||
const nw = board.newest(3, sSpot ? [sSpot.id] : []);
|
||||
for (const s of nw) { const cr = board.creative(s); steps.push(await visitStep('newest', s.id, cr.img, cr.link, 'Spot #' + s.id)); }
|
||||
const house = cfgMod.house().filter(h => h.link.startsWith('https://')); let hi = 0;
|
||||
while (steps.filter(x => x.role === 'newest' || x.role === 'house').length < 3 && house.length) { const h = house[hi++ % house.length]; steps.push(await visitStep('house', 'h-' + h.key, h.img, h.link, h.title)); if (hi > 6) break; }
|
||||
const gid = crypto.randomBytes(12).toString('hex');
|
||||
const g = { gid, vk, created: Date.now(), steps, idx: 0, stepStart: 0 };
|
||||
gates.set(gid, g);
|
||||
if (gates.size > 20000) { const cut = Date.now() - GATE_TTL; for (const [k, v] of gates) if (v.created < cut) gates.delete(k); }
|
||||
return g;
|
||||
}
|
||||
|
||||
// one-time board tokens for organic views
|
||||
const boardTokens = new Map();
|
||||
|
||||
// ---- dashboard data ----
|
||||
function spotView(s) {
|
||||
const v = store.views(s.id); const m = store.spotMeta(s.id) || {}; const cr = board.creative(s); const now = Date.now();
|
||||
const left = Math.max(0, C.spotDays - Math.floor((now - s.boughtAt) / 86400000));
|
||||
return { id: s.id, kind: s.kind, boughtAt: s.boughtAt, tx: s.tx, valueWei: s.valueWei, views: v.total, gateViews: v.gate, owed: C.viewsOwed,
|
||||
clicks: store.clicks(s.id), daysLeft: left, delivering: s.kind !== 3 && left > 0 && v.total < C.viewsOwed,
|
||||
img: m.img || '', link: m.link || '', showing: cr };
|
||||
}
|
||||
function myData(addr) {
|
||||
const a = addr.toLowerCase();
|
||||
const mine = chain.spotsOf(a).map(spotView);
|
||||
const w = chain.walletTotals(a);
|
||||
const dir = chain.directs(a).map(m => { const ss = chain.spotsOf(m.address); return { address: m.address, joinedAt: m.joinedAt, spots: ss.length, paidSpots: ss.filter(x => x.kind === 0).length,
|
||||
paidInWei: ss.filter(x => x.kind === 0 || x.kind === 1).reduce((t, x) => t + BigInt(x.valueWei), 0n).toString() }; });
|
||||
const me = chain.member(a);
|
||||
return { address: a, member: chain.isMember(a), sponsor: me ? me.sponsor : null, spots: mine, paidInWei: w.inWei, paidOutWei: w.outWei, byRole: w.byRole,
|
||||
payouts: chain.paidOf(a).slice(0, 50), directs: dir, defaults: store.memberDefault(a) || {}, share: 'https://' + C.site + '/?ref=' + a };
|
||||
}
|
||||
|
||||
// ---- server ----
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const u = new URL(req.url, 'http://x'); const p = u.pathname;
|
||||
try {
|
||||
// visitor cookie (used for rate limits only)
|
||||
const ck = cookies(req); const setVid = !ck['bl.vid'] && !isBot(req) ? cookie('bl.vid', crypto.randomBytes(9).toString('hex'), 365 * 86400, true) : null;
|
||||
const extra = setVid ? { 'Set-Cookie': setVid } : {};
|
||||
|
||||
// -- pages
|
||||
if (req.method === 'GET' || req.method === 'HEAD') {
|
||||
const PAGES = { '/': 'index.html', '/board': 'board.html', '/join': 'join.html', '/my': 'my.html', '/how': 'how.html' };
|
||||
if (PAGES[p]) {
|
||||
const set = [];
|
||||
if (setVid) set.push(setVid);
|
||||
if (u.searchParams.get('ref')) { const a = await resolveRef(u.searchParams.get('ref')); if (a) set.push(cookie('bl.ref', a, 90 * 86400, false)); }
|
||||
const ex = set.length ? { 'Set-Cookie': set } : {};
|
||||
if (p === '/my') ex['X-Frame-Options'] = 'DENY'; // member board: never framed (public pages stay frameable for traffic exchanges)
|
||||
return sendFile(res, path.join(PUB, PAGES[p]), ex);
|
||||
}
|
||||
if (/^\/r\/[^/]+$/.test(p)) { res.writeHead(302, { Location: '/?ref=' + encodeURIComponent(decodeURIComponent(p.slice(3))) }); return res.end(); }
|
||||
if (p.startsWith('/assets/') || p.startsWith('/art/house-') || p === '/logo-icon.png' || p === '/robots.txt') {
|
||||
const f = path.normalize(path.join(PUB, p)); if (!f.startsWith(PUB)) { res.writeHead(400); return res.end(); }
|
||||
return sendFile(res, f);
|
||||
}
|
||||
if (p.startsWith('/art/u/')) {
|
||||
const name = path.basename(p); if (!/^[a-z0-9-]+\.(png|jpg|gif)$/.test(name)) { res.writeHead(404); return res.end(); }
|
||||
return sendFile(res, path.join(C.dataDir, 'art', name), { 'Cache-Control': 'public, max-age=86400' });
|
||||
}
|
||||
// click relay: /go/<spotId | h-key>[?g=<gid>&i=<step>] (gate visits counted apart from organic clicks)
|
||||
if (/^\/go\/[\w-]+$/.test(p)) {
|
||||
const ref = p.slice(4); const t = board.target(ref);
|
||||
if (!t) { res.writeHead(302, { Location: '/' }); return res.end(); }
|
||||
if (t.spotId && !isBot(req)) {
|
||||
const g = gates.get(u.searchParams.get('g') || ''); const gi = Number(u.searchParams.get('i'));
|
||||
const isGate = g && g.vk === visitorKey(req) && g.steps[gi] && g.steps[gi].ref === ref;
|
||||
store.addClick(t.spotId, visitorKey(req), isGate ? 'gate' : 'organic');
|
||||
}
|
||||
const loc = t.link.startsWith('/') ? t.link : t.link;
|
||||
res.writeHead(302, { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
||||
}
|
||||
}
|
||||
|
||||
// -- public API
|
||||
if (p === '/api/config' && req.method === 'GET') {
|
||||
return json(res, 200, { site: C.site, chainId: C.chainId, chainName: C.chainName, contract: C.contract, rpc: C.publicRpc, explorer: C.explorer,
|
||||
walletConnectProjectId: C.walletConnectProjectId, viewsOwed: C.viewsOwed, spotDays: C.spotDays, priceUsd: 5, ready: !!C.contract, sel: SEL }, extra);
|
||||
}
|
||||
if (p === '/api/quote' && req.method === 'GET') {
|
||||
try { return json(res, 200, await chain.quote()); } catch (e) { return json(res, 503, { error: e.message }); }
|
||||
}
|
||||
if (p === '/api/gas' && req.method === 'GET') { try { return json(res, 200, await chain.suggestedFees()); } catch (e) { return json(res, 200, {}); } }
|
||||
if (/^\/api\/tx\/0x[0-9a-fA-F]{64}$/.test(p)) { try { return json(res, 200, await chain.receipt(p.slice(8))); } catch (e) { return json(res, 200, { found: false }); } }
|
||||
if (p === '/api/stats' && req.method === 'GET') {
|
||||
const t = chain.totals(); const recent = chain.spots().slice(0, 10).map(s => ({ id: s.id, owner: s.owner, kind: s.kind, boughtAt: s.boughtAt, tx: s.tx }));
|
||||
return json(res, 200, { totals: t, index: chain.status(), recent, daily: store.daily() });
|
||||
}
|
||||
if (p === '/api/sponsor' && req.method === 'GET') {
|
||||
const raw = u.searchParams.get('ref'); const a = raw ? await resolveRef(raw) : sponsorOf(req);
|
||||
return json(res, 200, { address: a || null, member: a ? chain.isMember(a) : false });
|
||||
}
|
||||
|
||||
// board: organic view counting with a one-time token, after 5 s on screen
|
||||
if (p === '/api/board' && req.method === 'GET') {
|
||||
const tiles = board.pick(); const token = crypto.randomBytes(12).toString('hex');
|
||||
if (!isBot(req)) boardTokens.set(token, { at: Date.now(), vk: visitorKey(req), ids: tiles.filter(t => t.t === 'spot').map(t => t.id) });
|
||||
if (boardTokens.size > 50000) { const cut = Date.now() - 600000; for (const [k, v] of boardTokens) if (v.at < cut) boardTokens.delete(k); }
|
||||
return json(res, 200, { tiles, token }, extra);
|
||||
}
|
||||
if (p === '/api/board/seen' && req.method === 'POST') {
|
||||
const b = await readBody(req); const t = boardTokens.get(String(b.token || ''));
|
||||
if (!t || t.vk !== visitorKey(req) || Date.now() - t.at < 4500 || Date.now() - t.at > 600000) return json(res, 200, { counted: 0 });
|
||||
boardTokens.delete(b.token);
|
||||
if (limited(req, 'views', 400, 3600000)) return json(res, 200, { counted: 0 });
|
||||
let n = 0; for (const id of t.ids) if (store.addView(id, t.vk, 'organic')) n++;
|
||||
return json(res, 200, { counted: n });
|
||||
}
|
||||
|
||||
// gate
|
||||
if (p === '/api/gate' && req.method === 'GET') {
|
||||
const s = session(req);
|
||||
if (isBot(req)) return json(res, 200, { passed: true, bot: true });
|
||||
if (passed(req) || (s && chain.isMember(s.address))) return json(res, 200, { passed: true });
|
||||
if (limited(req, 'gate', 60, 3600000)) return json(res, 429, { error: 'Too many gate starts from this connection. Try again in a while.' });
|
||||
const g = await makeGate(req);
|
||||
return json(res, 200, { passed: false, gid: g.gid, steps: g.steps.map(st => Object.assign({}, st)) }, extra);
|
||||
}
|
||||
if (p === '/api/gate/begin' && req.method === 'POST') {
|
||||
const b = await readBody(req); const g = gates.get(String(b.gid || ''));
|
||||
if (!g || g.vk !== visitorKey(req)) return json(res, 400, { error: 'Gate expired. Reload the page.' });
|
||||
if (Number(b.i) !== g.idx) return json(res, 400, { error: 'Out of order.', idx: g.idx });
|
||||
g.stepStart = Date.now(); return json(res, 200, { ok: true });
|
||||
}
|
||||
if (p === '/api/gate/done' && req.method === 'POST') {
|
||||
const b = await readBody(req); const g = gates.get(String(b.gid || ''));
|
||||
if (!g || g.vk !== visitorKey(req)) return json(res, 400, { error: 'Gate expired. Reload the page.' });
|
||||
const st = g.steps[g.idx];
|
||||
if (Number(b.i) !== g.idx || !st || !g.stepStart) return json(res, 400, { error: 'Out of order.', idx: g.idx });
|
||||
if (Date.now() - g.stepStart < (st.seconds - 1.5) * 1000) return json(res, 400, { error: 'Keep the page open until the timer ends.' });
|
||||
if (st.type === 'board' && !limited(req, 'views', 400, 3600000)) for (const t of st.tiles) if (t.t === 'spot') store.addView(t.id, g.vk, 'gate');
|
||||
g.idx += 1; g.stepStart = 0;
|
||||
if (g.idx >= g.steps.length) { gates.delete(g.gid); passedKeys.set(g.vk, Date.now() + 86400000); if (passedKeys.size > 100000) passedKeys.clear(); return json(res, 200, { ok: true, passed: true }, { 'Set-Cookie': cookie('bl.pass', passToken(g.vk), 86400, true) }); }
|
||||
return json(res, 200, { ok: true, idx: g.idx });
|
||||
}
|
||||
|
||||
// wallet sign-in
|
||||
if (p === '/api/auth/challenge' && req.method === 'POST') {
|
||||
if (limited(req, 'auth', 30, 600000)) return json(res, 429, { error: 'Too many sign-in attempts. Wait a few minutes.' });
|
||||
const b = await readBody(req); if (!ADDR_RE.test(b.address || '')) return json(res, 400, { error: 'Bad address' });
|
||||
const a = b.address.toLowerCase(); const nonce = crypto.randomBytes(16).toString('hex');
|
||||
const message = C.site + ' wants you to sign in with your wallet:\n' + getAddress(a) + '\n\nBanner Line sign-in. This signature is free and cannot move funds or approve anything.\n\nChain ID: ' + C.chainId + '\nNonce: ' + nonce + '\nIssued At: ' + new Date().toISOString();
|
||||
challenges.set(a, { message, exp: Date.now() + 600000 });
|
||||
if (challenges.size > 20000) challenges.clear();
|
||||
return json(res, 200, { message });
|
||||
}
|
||||
if (p === '/api/auth/verify' && req.method === 'POST') {
|
||||
const b = await readBody(req); const a = String(b.address || '').toLowerCase(); const ch = challenges.get(a);
|
||||
if (!ch || ch.exp < Date.now()) return json(res, 400, { error: 'Sign-in request expired. Tap sign in again.' });
|
||||
let rec; try { rec = verifyMessage(ch.message, String(b.signature || '')).toLowerCase(); } catch (e) { return json(res, 400, { error: 'Invalid signature.' }); }
|
||||
if (rec !== a) return json(res, 400, { error: 'Your wallet signed with a different account (' + rec.slice(0, 6) + '...' + rec.slice(-4) + '). Switch accounts and try again.' });
|
||||
challenges.delete(a);
|
||||
const token = store.mintSession(a);
|
||||
return json(res, 200, { ok: true, address: a }, { 'Set-Cookie': cookie('bl.sid', token, store.SESSION_TTL / 1000, true) });
|
||||
}
|
||||
if (p === '/api/auth/logout' && req.method === 'POST') {
|
||||
const s = session(req); if (s) store.dropSession(s.token);
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': cookie('bl.sid', '', 0, true) });
|
||||
}
|
||||
if (p === '/api/me' && req.method === 'GET') {
|
||||
const s = session(req); if (!s) return json(res, 200, { signedIn: false, sponsor: sponsorOf(req) });
|
||||
store.touch(s.address);
|
||||
return json(res, 200, { signedIn: true, address: s.address, member: chain.isMember(s.address), sponsor: sponsorOf(req) });
|
||||
}
|
||||
|
||||
// -- member API (signed in)
|
||||
if (p.startsWith('/api/my')) {
|
||||
const s = session(req); if (!s) return json(res, 401, { error: 'Sign in with your wallet first.' });
|
||||
const me = s.address;
|
||||
if (p === '/api/my' && req.method === 'GET') return json(res, 200, myData(me));
|
||||
let m = /^\/api\/my\/spot\/(\d+)$/.exec(p);
|
||||
if (m && req.method === 'POST') {
|
||||
const sp = chain.spot(m[1]); if (!sp || sp.owner !== me) return json(res, 403, { error: 'That spot is not yours.' });
|
||||
const b = await readBody(req); const out = {};
|
||||
if (b.link !== undefined) { if (b.link === '') out.link = ''; else { const r = safety.checkLink(b.link, 'Target link'); if (r.error) return json(res, 400, r); out.link = r.url; } }
|
||||
if (b.img !== undefined && !String(b.img).startsWith('/art/u/')) { if (b.img === '') out.img = ''; else { const r = safety.checkLink(b.img, 'Image URL'); if (r.error) return json(res, 400, r); out.img = r.url; } }
|
||||
return json(res, 200, { ok: true, meta: store.setSpotMeta(sp.id, out) });
|
||||
}
|
||||
if (p === '/api/my/default' && req.method === 'POST') {
|
||||
const b = await readBody(req); const out = {};
|
||||
if (b.link !== undefined) { if (b.link === '') out.link = ''; else { const r = safety.checkLink(b.link, 'Default link'); if (r.error) return json(res, 400, r); out.link = r.url; } }
|
||||
if (b.img !== undefined && !String(b.img).startsWith('/art/u/')) { if (b.img === '') out.img = ''; else { const r = safety.checkLink(b.img, 'Image URL'); if (r.error) return json(res, 400, r); out.img = r.url; } }
|
||||
return json(res, 200, { ok: true, defaults: store.setMemberDefault(me, out) });
|
||||
}
|
||||
if (p === '/api/my/upload' && req.method === 'POST') {
|
||||
if (limited(req, 'upload', 40, 3600000)) return json(res, 429, { error: 'Too many uploads this hour.' });
|
||||
const target = u.searchParams.get('for') || '';
|
||||
let sp = null;
|
||||
if (target !== 'default') { sp = chain.spot(target); if (!sp || sp.owner !== me) return json(res, 403, { error: 'That spot is not yours.' }); }
|
||||
let buf; try { buf = await readRaw(req, safety.MAX_UPLOAD + 1); } catch (e) { return json(res, 400, { error: 'The file is over 150 KB.' }); }
|
||||
const r = safety.checkImage(buf); if (r.error) return json(res, 400, r);
|
||||
const name = (sp ? 's' + sp.id : 'd' + me.slice(2, 10)) + '-' + crypto.randomBytes(5).toString('hex') + r.info.ext;
|
||||
fs.writeFileSync(path.join(C.dataDir, 'art', name), buf);
|
||||
const img = '/art/u/' + name;
|
||||
if (sp) store.setSpotMeta(sp.id, { img }); else store.setMemberDefault(me, { img });
|
||||
return json(res, 200, { ok: true, img });
|
||||
}
|
||||
return json(res, 404, { error: 'Not found' });
|
||||
}
|
||||
|
||||
// -- admin (ADMIN_TOKEN header): keeper preview + index status. No key material is ever returned.
|
||||
if (p === '/api/admin/status' && req.method === 'GET') {
|
||||
const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' });
|
||||
return json(res, 200, { index: chain.status(), totals: chain.totals(), keeper: keeper.statusInfo() });
|
||||
}
|
||||
|
||||
if (p.startsWith('/api/')) return json(res, 404, { error: 'Not found' });
|
||||
res.writeHead(404, headers({ 'Content-Type': 'text/html; charset=utf-8' }));
|
||||
return res.end('<!doctype html><title>Not found</title><p style="font-family:sans-serif">Not found. <a href="/">Banner Line home</a></p>');
|
||||
} catch (e) {
|
||||
console.error('request', p, e.message);
|
||||
if (!res.headersSent) json(res, 500, { error: 'Server error' });
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(C.port, () => console.log('Banner Line on :' + C.port + ' chain ' + C.chainName + ' (' + C.chainId + ') contract ' + (C.contract || '(not set)')));
|
||||
process.on('SIGTERM', () => { store.flush(); process.exit(0); });
|
||||
process.on('SIGINT', () => { store.flush(); process.exit(0); });
|
||||
@@ -0,0 +1,70 @@
|
||||
// JSON volume store (the InstantAdPay JSON-mode pattern: one file in DATA_DIR, atomic tmp+rename, debounced).
|
||||
// Holds only what the chain does not: banner + link per spot, member defaults, views/visits delivered,
|
||||
// sign-in sessions, last-seen times and the keeper log. Every function is sync and small so a MySQL
|
||||
// version can replace this file behind the same names later.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const cfgMod = require('./config');
|
||||
|
||||
let S = null, saveT = null;
|
||||
const FILE = () => path.join(cfgMod.get().dataDir, 'store.json');
|
||||
function load() {
|
||||
try { S = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { S = null; }
|
||||
S = Object.assign({ v: 1, spotMeta: {}, defaults: {}, views: {}, clicks: {}, seen: {}, sessions: {}, keeper: { log: [] }, daily: {} }, S || {});
|
||||
const now = Date.now();
|
||||
for (const [k, s] of Object.entries(S.sessions)) if (s.expires < now) delete S.sessions[k];
|
||||
}
|
||||
function save(now) {
|
||||
if (saveT && !now) return;
|
||||
const run = () => { saveT = null; try { const tmp = FILE() + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(S), { mode: 0o600 }); fs.renameSync(tmp, FILE()); } catch (e) { console.error('store save failed', e.message); } };
|
||||
if (now) { clearTimeout(saveT); run(); } else saveT = setTimeout(run, 1500);
|
||||
}
|
||||
function flush() { save(true); }
|
||||
|
||||
// ---- creative per spot + member default ----
|
||||
function spotMeta(id) { return S.spotMeta[id] || null; }
|
||||
function setSpotMeta(id, m) { S.spotMeta[id] = Object.assign({}, S.spotMeta[id] || {}, m, { updatedAt: Date.now() }); save(); return S.spotMeta[id]; }
|
||||
function memberDefault(addr) { return S.defaults[String(addr).toLowerCase()] || null; }
|
||||
function setMemberDefault(addr, m) { const a = String(addr).toLowerCase(); S.defaults[a] = Object.assign({}, S.defaults[a] || {}, m, { updatedAt: Date.now() }); save(); return S.defaults[a]; }
|
||||
|
||||
// ---- views + clicks (gate and organic kept apart) ----
|
||||
// Rate limit: one counted view per visitor per spot per hour, one counted click per visitor per spot per hour.
|
||||
const seenView = new Map(), seenClick = new Map();
|
||||
const HOUR = 3600000;
|
||||
function prune(m) { if (m.size < 50000) return; const cut = Date.now() - HOUR; for (const [k, t] of m) if (t < cut) m.delete(k); }
|
||||
function addView(spotId, visitorKey, source) {
|
||||
const k = visitorKey + ':' + spotId; const t = seenView.get(k);
|
||||
if (t && Date.now() - t < HOUR) return false;
|
||||
seenView.set(k, Date.now()); prune(seenView);
|
||||
const v = S.views[spotId] || (S.views[spotId] = { organic: 0, gate: 0 });
|
||||
v[source === 'gate' ? 'gate' : 'organic'] += 1; bumpDaily('views_' + (source === 'gate' ? 'gate' : 'organic')); save();
|
||||
return true;
|
||||
}
|
||||
function views(spotId) { const v = S.views[spotId] || { organic: 0, gate: 0 }; return { organic: v.organic, gate: v.gate, total: v.organic + v.gate }; }
|
||||
function addClick(spotId, visitorKey, source) {
|
||||
const k = visitorKey + ':' + spotId + ':' + source; const t = seenClick.get(k);
|
||||
if (t && Date.now() - t < HOUR) return false;
|
||||
seenClick.set(k, Date.now()); prune(seenClick);
|
||||
const c = S.clicks[spotId] || (S.clicks[spotId] = { organic: 0, gate: 0 });
|
||||
c[source === 'gate' ? 'gate' : 'organic'] += 1; bumpDaily('clicks_' + (source === 'gate' ? 'gate' : 'organic')); save();
|
||||
return true;
|
||||
}
|
||||
function clicks(spotId) { return S.clicks[spotId] || { organic: 0, gate: 0 }; }
|
||||
function bumpDaily(k) { const day = new Date().toISOString().slice(0, 10); const d = S.daily[day] || (S.daily[day] = {}); d[k] = (d[k] || 0) + 1; }
|
||||
function daily() { return S.daily; }
|
||||
|
||||
// ---- sessions + last seen ----
|
||||
const SESSION_TTL = 7 * 24 * HOUR;
|
||||
function mintSession(address) { const token = crypto.randomBytes(32).toString('hex'); S.sessions[token] = { address: address.toLowerCase(), expires: Date.now() + SESSION_TTL }; touch(address); save(); return token; }
|
||||
function session(token) { const s = token && S.sessions[token]; return s && s.expires > Date.now() ? Object.assign({ token }, s) : null; }
|
||||
function dropSession(token) { delete S.sessions[token]; save(); }
|
||||
function touch(address) { S.seen[String(address).toLowerCase()] = Date.now(); save(); }
|
||||
function lastSeen(address) { return S.seen[String(address).toLowerCase()] || 0; }
|
||||
|
||||
// ---- keeper ----
|
||||
function keeperLog(entry) { S.keeper.log.push(Object.assign({ at: Date.now() }, entry)); if (S.keeper.log.length > 2000) S.keeper.log = S.keeper.log.slice(-2000); save(true); }
|
||||
function keeperEntries() { return S.keeper.log.slice(); }
|
||||
|
||||
module.exports = { load, flush, spotMeta, setSpotMeta, memberDefault, setMemberDefault, addView, views, addClick, clicks, daily,
|
||||
mintSession, session, dropSession, touch, lastSeen, keeperLog, keeperEntries, SESSION_TTL };
|
||||
Reference in New Issue
Block a user