Compare commits
14 Commits
816417d172
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d915884409 | |||
| a71d8ea276 | |||
| 5e8c903b63 | |||
| 654cd7b408 | |||
| 408a30cf31 | |||
| 3709d91f59 | |||
| 6599c2f4ec | |||
| 94a414cc1c | |||
| ab57b4089e | |||
| 4c0aa35e6c | |||
| 395ed1fac1 | |||
| 281e134a15 | |||
| 8856b619b4 | |||
| 73b6cf74db |
@@ -11,7 +11,7 @@
|
||||
{ "q": "What should you never share with anyone?", "options": ["Your Secret Recovery Phrase", "Your invite link", "Your member ID", "Your wallet address"], "fact": "Video 2: Never share your Secret Recovery Phrase with anyone." },
|
||||
{ "q": "Which wallet does the training show you how to set up?", "options": ["MetaMask", "PayPal", "Cash App", "A bank account"], "fact": "Video 2: Create your MetaMask wallet." },
|
||||
{ "q": "Which network do you fund your wallet on?", "options": ["Polygon Mainnet", "Bitcoin", "Solana", "Dogecoin"], "fact": "Video 3: Get POL onto Polygon Mainnet." },
|
||||
{ "q": "For someone brand new to crypto, which service does the page name for buying POL with a card?", "options": ["MoonPay", "Venmo", "Western Union", "Zelle"], "fact": "The simplest path is MoonPay." },
|
||||
{ "q": "When you buy POL with a card, which address do you send it to?", "options": ["Your own wallet address", "Your sponsor's address", "The site's address", "Any address works"], "fact": "Paste your own wallet address as the destination." },
|
||||
{ "q": "According to Video 7, what does every level you own do?", "options": ["Extends your reach one generation deeper", "Doubles every payment", "Removes the need for directs", "Nothing, levels are cosmetic"], "fact": "Every level you own extends your reach exactly one generation deeper." }
|
||||
]},
|
||||
{ "mission": "ctb-programs", "url": "https://ctbrewards.saasy.top/", "name": "CTB Rewards", "questions": [
|
||||
|
||||
@@ -102,14 +102,14 @@
|
||||
{
|
||||
"id": "rmc-training-4",
|
||||
"missionId": "rmc-training",
|
||||
"q": "For someone brand new to crypto, which service does the page name for buying POL with a card?",
|
||||
"q": "When you buy POL with a card, which address do you send it to?",
|
||||
"options": [
|
||||
"MoonPay",
|
||||
"Venmo",
|
||||
"Western Union",
|
||||
"Zelle"
|
||||
"Your own wallet address",
|
||||
"Your sponsor's address",
|
||||
"The site's address",
|
||||
"Any address works"
|
||||
],
|
||||
"fact": "The simplest path is MoonPay.",
|
||||
"fact": "Paste your own wallet address as the destination.",
|
||||
"active": true,
|
||||
"added": "2026-09-26"
|
||||
},
|
||||
|
||||
+33
-12
@@ -83,17 +83,22 @@ function order(box, q) { return q.options.map((o, i) => ({ i, k: h(box.id + ':'
|
||||
|
||||
// ---- the box ----------------------------------------------------------------------------------
|
||||
const boxId = (memberId, day) => Number(memberId) + ':' + day;
|
||||
function getBox(memberId, day) { return store.read('boxes', {})[boxId(memberId, day || ctDay())] || null; }
|
||||
// the day's current box: the second one (the Game Pass perk, id '<member>:<day>:2') once it exists, else the first
|
||||
function getBox(memberId, day) { const all = store.read('boxes', {}), id = boxId(memberId, day || ctDay()); return all[id + ':2'] || all[id] || null; }
|
||||
const closed = b => !!b && (b.status === 'won' || b.status === 'missed');
|
||||
function putBox(b) { store.update('boxes', {}, all => { all[b.id] = b; return all; }); return b; }
|
||||
function patchBox(id, patch) { let out = null; store.update('boxes', {}, all => { if (all[id]) { Object.assign(all[id], patch); out = all[id]; } return all; }); return out; }
|
||||
|
||||
function earned(me) { const s = settings(); return s.on && rewards.findsToday(me.memberId, ctDay()) >= s.base; }
|
||||
// The box is a Game Pass perk since 2026-11-02 (Marty: the Pass is the purchase that funds the game): a free account hunts
|
||||
// once a day and never reaches the box; pass = false answers 'pass' on the board and refuses to open.
|
||||
function earned(me, pass) { const s = settings(); return s.on && pass !== false && rewards.findsToday(me.memberId, ctDay()) >= s.base; }
|
||||
|
||||
// what the board shows
|
||||
function view(me) {
|
||||
function view(me, pass) {
|
||||
const s = settings(); if (!s.on) return { on: false };
|
||||
const day = ctDay(); const b = getBox(me.memberId, day);
|
||||
const done = rewards.findsToday(me.memberId, day);
|
||||
if (!b && pass === false) return { on: true, status: 'pass', need: s.base, done: Math.min(done, s.base), pol: s.pol };
|
||||
if (!b) return { on: true, status: done >= s.base ? 'ready' : 'locked', need: s.base, done: Math.min(done, s.base), pol: s.pol };
|
||||
const m = missions.get(b.missionId) || {}; const q = bank().find(x => x.id === b.qid);
|
||||
const out = { on: true, status: b.status, pol: b.pol, site: m.site || b.missionId, name: m.name || '', dwell: m.dwell || 30, url: b.url || null, expires: b.exp || null };
|
||||
@@ -105,13 +110,18 @@ function view(me) {
|
||||
return out;
|
||||
}
|
||||
|
||||
function open(me) {
|
||||
if (!earned(me)) return { error: 'Finish today’s Code Hunts first. The box unlocks when your last one is found.' };
|
||||
const day = ctDay(); const cur = getBox(me.memberId, day); if (cur) return { ok: true, box: cur };
|
||||
// pass = the Game Pass perk (GAME-PASS.md 4): a second case a day once the first is closed; the first case stays the rule for everyone else
|
||||
// pass = the second-case perk; allowed = may a box open at all (the full tier: Game Pass holders, or everyone while GAMEPASS is off)
|
||||
function open(me, pass, allowed) {
|
||||
const day = ctDay(); const cur = getBox(me.memberId, day);
|
||||
const second = !!(pass && cur && closed(cur) && !/:2$/.test(cur.id));
|
||||
if (cur && !second) return { ok: true, box: cur }; // a box already open today stays reachable (a pass that lapsed mid-day)
|
||||
if (allowed === false) return { error: 'The Mystery Hunt Box opens for Game Pass holders.' };
|
||||
if (!earned(me, true)) return { error: 'Finish today’s Code Hunts first. The box unlocks when your last one is found.' };
|
||||
const c = pickCase(me.memberId, day); if (!c) return { error: 'No cases are open right now. Check back tomorrow.' };
|
||||
let made = null;
|
||||
// idempotent per member per day: a double tap or two tabs can never mint a second box
|
||||
store.update('boxes', {}, all => { const id = boxId(me.memberId, day); if (!all[id]) all[id] = { id, memberId: Number(me.memberId), day, missionId: c.missionId, qid: c.qid, pol: settings().pol, status: 'open', openedAt: Date.now() }; made = all[id]; return all; });
|
||||
store.update('boxes', {}, all => { const id = boxId(me.memberId, day) + (second ? ':2' : ''); if (!all[id]) all[id] = { id, memberId: Number(me.memberId), day, missionId: c.missionId, qid: c.qid, pol: settings().pol, status: 'open', openedAt: Date.now(), second: second || undefined }; made = all[id]; return all; });
|
||||
return { ok: true, box: made };
|
||||
}
|
||||
|
||||
@@ -134,7 +144,9 @@ function visited(rec) {
|
||||
store.update('boxes', {}, all => { const b = all[rec.boxId]; if (b && b.status === 'started' && b.token === rec.t) { b.status = 'visited'; b.visitedAt = Date.now(); } return all; });
|
||||
}
|
||||
|
||||
function answer(me, choice) {
|
||||
// gate (the Game Pass, GAME-PASS.md 3a): { ask(pol, ref) -> IAP's answer, wait(rowId, pol, ref) } set by server.js when GAMEPASS=on;
|
||||
// the case is scored first (the answer is final either way), then InstantAdPay decides what the account-wide cap allows
|
||||
async function answer(me, choice, gate) {
|
||||
const b = getBox(me.memberId, ctDay()); if (!b) return { error: 'No case open today.' };
|
||||
if (b.status === 'won' || b.status === 'missed') return { error: 'You already answered today’s case.' };
|
||||
if (b.status !== 'visited') return { error: 'Visit the site first. The question unlocks once your visit is recorded.' };
|
||||
@@ -147,17 +159,26 @@ function answer(me, choice) {
|
||||
if (!claimed) return { error: 'You already answered today’s case.' };
|
||||
const correct = ord[n] === 0; const at = Date.now();
|
||||
store.update('answers', [], all => { all.push({ memberId: Number(me.memberId), boxId: b.id, missionId: b.missionId, qid: q.id, correct, picked: q.options[ord[n]], at, ms: b.shownAt ? at - b.shownAt : null }); return all; });
|
||||
let g = null;
|
||||
let g = null, note = null;
|
||||
try {
|
||||
if (correct) {
|
||||
const m = missions.get(b.missionId) || { id: b.missionId, site: b.missionId };
|
||||
g = rewards.grantFixed(me, { missionId: 'detective:' + m.id, site: m.site, pol: b.pol, detective: { boxId: b.id, qid: q.id } });
|
||||
const t = { missionId: 'detective:' + m.id, site: m.site, pol: b.pol, detective: { boxId: b.id, qid: q.id } };
|
||||
if (gate) { // the Game Pass: a case is a repeatable ('daily') reward; what the account-wide cap does not allow is dropped, not deferred
|
||||
const ref = 'detective:' + b.id, r = await gate.ask(b.pol, ref);
|
||||
if (r.retry) { t.status = 'gp-wait'; t.gp = { ref, kind: 'daily', nominal: b.pol, pending: true }; t.nominal = b.pol; }
|
||||
else { t.pol = r.allowed; t.nominal = b.pol; t.gp = { ref, kind: 'daily', nominal: b.pol, pass: !!r.pass, capHit: r.capHit || null }; }
|
||||
note = r.note || null;
|
||||
g = rewards.grantFixed(me, t);
|
||||
if (r.retry && g && g.rec) gate.wait(g.rec.id, b.pol, ref);
|
||||
} else g = rewards.grantFixed(me, t);
|
||||
}
|
||||
} finally {
|
||||
// the answer is final either way; a grant that failed shows in the admin as a won box with no payout
|
||||
patchBox(b.id, { status: correct ? 'won' : 'missed', answeredAt: at, payoutId: g && g.rec ? g.rec.id : null });
|
||||
}
|
||||
return { ok: true, correct, pol: correct ? b.pol : 0, queued: !!(g && g.queued), rec: g && g.rec, answer: q.options[0] };
|
||||
const paid = correct && g && g.rec && g.rec.status !== 'gp-wait' ? g.rec.pol : 0; // a gp-wait row holds the nominal amount until IAP answers: nothing is paid yet
|
||||
return { ok: true, correct, pol: paid, nominal: b.pol, note, queued: !!(g && g.queued), waiting: !!(g && g.waiting), capped: !!(g && g.capped), rec: g && g.rec, answer: q.options[0] };
|
||||
}
|
||||
|
||||
// ---- stats for the admin -------------------------------------------------------------------------
|
||||
@@ -173,4 +194,4 @@ function stats() {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { init, bank, saveQuestion, setActive, view, open, start, answer, visited, stats, pickCase, earned };
|
||||
module.exports = { init, bank, saveQuestion, setActive, view, open, start, answer, visited, stats, pickCase, earned, getBox };
|
||||
|
||||
+32
-6
@@ -29,8 +29,15 @@ function connect() {
|
||||
wallet = new ethers.Wallet(process.env.HUNT_WALLET_KEY.trim(), provider);
|
||||
}
|
||||
// a node hiccup is not a failed drip: 5xx, timeouts, connection resets, rate limits, missing responses
|
||||
const TRANSIENT = /socket hang up|ECONNABORTED|EPIPE|EHOSTUNREACH|ENETUNREACH|network error|fetch failed|UND_ERR|other side closed|server response 5\d\d|timeout|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|429|rate limit|missing response|could not detect network|bad response|SERVER_ERROR|NETWORK_ERROR/i; // + connection-level failures (PolHunter #7, 2026-10-09)
|
||||
const TRANSIENT = /socket hang up|ECONNABORTED|EPIPE|EHOSTUNREACH|ENETUNREACH|network error|fetch failed|UND_ERR|other side closed|server response 5\d\d|timeout|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|429|rate limit|missing response|could not detect network|bad response|SERVER_ERROR|NETWORK_ERROR|403|Forbidden|401|Unauthorized/i; // + connection-level failures (PolHunter #7, 2026-10-09)
|
||||
function rotate(reason) { if (rpcs.length > 1) { rpcAt = (rpcAt + 1) % rpcs.length; connect(); console.warn('faucet: RPC rotated to', rpcs[rpcAt % rpcs.length], 'after', reason.slice(0, 80)); } }
|
||||
// Nonce (2026-11-09, after Turkey Drop's week prizes collided with "replacement fee too low"): publicnode is a load-balanced pool, so
|
||||
// asking it for the next nonce right after a confirmed send can return the SAME nonce again. Sends read the nonce once per tick, keep
|
||||
// the highest one ever used in faucet-state.nextNonce, and count up locally. A nonce clash is a retry (row back to due), never a failure.
|
||||
const NONCE_ERR = /replacement fee too low|replacement transaction underpriced|nonce too low|nonce has already been used|already known|NONCE_EXPIRED|REPLACEMENT_UNDERPRICED/i;
|
||||
async function nextNonce() { const n = await provider.getTransactionCount(wallet.address, 'pending'); return Math.max(n, Number(store.read('faucet-state', {}).nextNonce) || 0); }
|
||||
const keepNonce = n => store.update('faucet-state', {}, x => Object.assign(x, { nextNonce: Math.max(n, Number(x.nextNonce) || 0) }));
|
||||
const DROP_MS = 10 * 60000; // a "sent" row whose tx no node knows after this long was dropped: back to due (its nonce slot is reused, so it can never pay twice)
|
||||
function address() { return wallet ? wallet.address : null; }
|
||||
async function balance() { if (!provider || !wallet) return null; const b = await provider.getBalance(wallet.address); return Number(ethers.formatEther(b)); }
|
||||
|
||||
@@ -50,7 +57,7 @@ async function tick(notify) {
|
||||
// drips sent but never settled here (a restart mid-wait, a receipt that lagged past the wait):
|
||||
// ask the chain, never re-send
|
||||
for (const p of store.read('payouts', []).filter(x => x.status === 'sent' && x.tx)) {
|
||||
try { const rc = await provider.getTransactionReceipt(p.tx); if (rc && (await settle(p, rc, notify))) paid++; } catch (e) {}
|
||||
try { const rc = await provider.getTransactionReceipt(p.tx); if (rc) { if (await settle(p, rc, notify)) paid++; } else if (Date.now() - (p.sentAt || p.ts || 0) > DROP_MS && !(await provider.getTransaction(p.tx))) rewards.mark(p.id, { status: 'due', tx: null, error: 'dropped ' + String(p.tx).slice(0, 12) + ', resending' }); } catch (e) { if (TRANSIENT.test(String(e.message || e))) { rotate(String(e.message || e)); break; } } // a node refusing us (403) must not freeze the check
|
||||
}
|
||||
const due = rewards.payable();
|
||||
// a dry faucet is not a failed drip: check the balance first, leave the drips due, alert once
|
||||
@@ -59,18 +66,20 @@ async function tick(notify) {
|
||||
const need = due.reduce((n, p) => n + p.pol, 0) + 0.01;
|
||||
if (bal0 < due[0].pol + 0.005) { if (notify) { const st = store.read('faucet-state', {}); const day = new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); if (st.dryAlertDay !== day) { st.dryAlertDay = day; store.write('faucet-state', st); await notify('low', { balance: bal0, threshold: need, address: wallet.address }); } } ticking = false; return { paid: 0, waiting: due.length, balance: bal0 }; }
|
||||
}
|
||||
let nonce = null; if (due.length) { try { nonce = await nextNonce(); } catch (e) { if (TRANSIENT.test(String(e.message || e))) rotate(String(e.message || e)); return { paid }; } }
|
||||
for (const p of due) {
|
||||
if (bal0 != null && bal0 < p.pol + 0.005) break; // pay what the balance covers, leave the rest due
|
||||
if (!p.wallet || !/^0x[a-f0-9]{40}$/i.test(p.wallet)) { rewards.mark(p.id, { status: 'failed', error: 'no wallet on the account' }); continue; }
|
||||
try {
|
||||
const tx = await wallet.sendTransaction({ to: p.wallet, value: ethers.parseEther(String(p.pol)) });
|
||||
rewards.mark(p.id, { status: 'sent', tx: tx.hash });
|
||||
const tx = await wallet.sendTransaction({ to: p.wallet, value: ethers.parseEther(String(p.pol)), nonce });
|
||||
rewards.mark(p.id, { status: 'sent', tx: tx.hash, sentAt: Date.now() }); nonce++; keepNonce(nonce);
|
||||
let rc = null;
|
||||
try { rc = await tx.wait(1, 90000); } catch (e) { if (e && e.code === 'TIMEOUT') continue; throw e; } // still pending: stays 'sent', settled next tick
|
||||
if (await settle(Object.assign({}, p, { tx: tx.hash }), rc, notify)) { paid++; if (bal0 != null) bal0 -= p.pol; }
|
||||
} catch (e) {
|
||||
const msg = String(e.message || e);
|
||||
if (/insufficient funds/i.test(msg)) { rewards.mark(p.id, { status: 'due', error: null }); break; } // dry: leave it due, stop this pass
|
||||
if (/insufficient funds/i.test(msg)) { rewards.mark(p.id, { status: 'due', error: null }); break; }
|
||||
if (NONCE_ERR.test(msg) || NONCE_ERR.test(String(e && e.code))) { rewards.mark(p.id, { status: 'due', error: 'nonce clash, retrying' }); try { keepNonce(await provider.getTransactionCount(wallet.address, 'latest')); } catch (x) {} break; } // dry: leave it due, stop this pass
|
||||
// the send itself failed only if no hash was recorded; a hash means the chain has it, leave it 'sent'
|
||||
const cur = store.read('payouts', []).find(x => x.id === p.id);
|
||||
if (cur && cur.status === 'sent' && cur.tx) continue;
|
||||
@@ -91,4 +100,21 @@ async function tick(notify) {
|
||||
return { paid };
|
||||
}
|
||||
|
||||
module.exports = { enabled, init, address, balance, tick };
|
||||
// one plain POL transfer for a non-drip payment (the weekly Pass Tournament prizes, lib/tournament.js): the same wallet, the same
|
||||
// RPC rotation on a node hiccup. onHash fires the moment the chain has the transaction, BEFORE the receipt wait, so the caller can
|
||||
// record the hash durably and never send the same prize twice. Returns { tx, ok } or { tx, pending: true } when the wait timed out.
|
||||
async function send(to, pol, onHash) {
|
||||
if (!wallet) throw new Error('faucet is off (HUNT_WALLET_KEY / HUNT_RPC)');
|
||||
if (!to || !/^0x[a-f0-9]{40}$/i.test(to)) throw new Error('bad wallet');
|
||||
if (!(Number(pol) > 0)) throw new Error('bad amount');
|
||||
try {
|
||||
const nonce = await nextNonce(); const tx = await wallet.sendTransaction({ to, value: ethers.parseEther(String(pol)), nonce }); keepNonce(nonce + 1);
|
||||
if (onHash) { try { await onHash(tx.hash); } catch (e) {} }
|
||||
let rc = null; try { rc = await tx.wait(1, 90000); } catch (e) { if (e && e.code === 'TIMEOUT') return { tx: tx.hash, pending: true }; throw e; }
|
||||
return { tx: tx.hash, ok: !!(rc && rc.status === 1) };
|
||||
} catch (e) { const msg = String(e && e.message || e); if (TRANSIENT.test(msg)) rotate(msg); throw e; }
|
||||
}
|
||||
// HUNT_DRY_RUN=on: the tournament payer records what it would pay and sends nothing (the find faucet is not affected)
|
||||
const dry = () => String(process.env.HUNT_DRY_RUN || 'off').trim().toLowerCase() !== 'off';
|
||||
|
||||
module.exports = { enabled, init, address, balance, tick, send, dry };
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ const TTL = 3 * 60 * 1000;
|
||||
|
||||
function fetchJson(url) {
|
||||
return new Promise((resolve) => {
|
||||
const rq = https.get(url, { timeout: 8000 }, r => {
|
||||
// plain http only for a local stub InstantAdPay (tests)
|
||||
const rq = (String(url).startsWith('http:') ? require('http') : https).get(url, { timeout: 8000 }, r => {
|
||||
let raw = ''; r.setEncoding('utf8'); r.on('data', d => { raw += d; });
|
||||
r.on('end', () => { try { resolve(r.statusCode === 200 ? JSON.parse(raw) : null); } catch (e) { resolve(null); } });
|
||||
});
|
||||
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
// polgrant.js: the Game Pass bridge to InstantAdPay (GAME-PASS.md section 3a + its "Built" clarifications). The SAME file lives
|
||||
// in every network game; change it in one place and copy it to the others.
|
||||
//
|
||||
// IAP is the single source of truth for the pass and for the account-wide daily caps. Before any POL grant to a signed-in
|
||||
// player the game asks `grant({ memberId, email, kind, pol, ref })` and pays only what comes back as `allowed`.
|
||||
// - kind 'daily' = a repeatable reward (a find, a patrol, a gem): what the cap does not allow is DROPPED, never deferred
|
||||
// - kind 'progress' = a one-time reward (a boss, a sector, a chapter): what the cap does not allow is DEFERRED on IAP and
|
||||
// paid on a later day inside `allowed` (the answer says `carried`), so nothing is ever lost
|
||||
// - the same ref twice gets the same answer (IAP is idempotent on ref, `repeat: true`), so a retry can never double-pay
|
||||
// - FAIL CLOSED: when IAP cannot be reached (network, 5xx, bad JSON, bad auth) the answer is { allowed: 0, retry: true }
|
||||
// and the game queues the ref: retried every 5 minutes for up to 48 hours, then the admin chat is told once
|
||||
// - a player who has not linked a wallet has memberId 0 in every hand-off token: send the email too, IAP resolves the account
|
||||
// (the pass and the caps are per ACCOUNT); `who` below is the member id when > 0, else the lowercased email
|
||||
//
|
||||
// Feature switch: GAMEPASS=on|off (default off: every game keeps its current behaviour, so deploying before launch is safe).
|
||||
// Env: IAP_URL (default https://instantadpay.com). Auth = the game's own shared sign-in secret (its *_SSO_SECRET):
|
||||
// POST: JSON body with `game: <slug>`, headers X-Game-Ts (ms) and X-Game-Sig = hex HMAC-SHA256(secret, ts + "\n" + rawBody)
|
||||
// GET /api/partner/player?game=&m=&e=&ts=&sig= with sig = hex HMAC-SHA256(secret, 'player:' + who + ':' + ts)
|
||||
// GET /api/partner/tournament/pending?game=&ts=&sig= with who = 'tournament'
|
||||
// The hand-off token carries the flag as claims.gamePass = { active, until }; grant and player answers refresh it.
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
|
||||
const PASS_URL = 'https://instantadpay.com/my#games?pass=1';
|
||||
const RETRY_MS = 5 * 60000, GIVE_UP_MS = 48 * 3600000, PASS_TTL = 10 * 60000;
|
||||
let cfg = { game: '', secret: '', iap: 'https://instantadpay.com', store: null, notify: null, fetch: null, log: console, queueKey: 'polgrantq', passKey: 'gamepass' };
|
||||
// use({ game, secret, iap, store: { read, write, update }, notify(kind, payload), fetch? })
|
||||
function use(o) { cfg = Object.assign(cfg, o || {}); cfg.iap = String(cfg.iap || process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''); return cfg; }
|
||||
const on = () => String(process.env.GAMEPASS || 'off').trim().toLowerCase() === 'on';
|
||||
const ctDay = t => new Date(t || Date.now()).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
const r4 = n => Math.round(Number(n) * 10000) / 10000;
|
||||
const doFetch = (u, o) => (cfg.fetch || globalThis.fetch)(u, o);
|
||||
const ready = () => !!(cfg.store && cfg.secret && String(cfg.secret).length >= 32);
|
||||
// the account key IAP and this module agree on: the member id when linked, else the email ('' = nobody signed in)
|
||||
const whoOf = (memberId, email) => Number(memberId) > 0 ? String(Number(memberId)) : String(email || '').trim().toLowerCase();
|
||||
const hmac = s => crypto.createHmac('sha256', String(cfg.secret)).update(s).digest('hex');
|
||||
|
||||
async function post(path, body) {
|
||||
const raw = JSON.stringify(Object.assign({ game: cfg.game }, body)), ts = String(Date.now());
|
||||
const r = await doFetch(cfg.iap + path, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Game': cfg.game, 'X-Game-Ts': ts, 'X-Game-Sig': hmac(ts + '\n' + raw) }, body: raw, signal: AbortSignal.timeout(6000) });
|
||||
const text = await r.text(); let json = null; try { json = JSON.parse(text); } catch (e) {}
|
||||
return { status: r.status, json };
|
||||
}
|
||||
async function get(path, who, params) {
|
||||
const ts = String(Date.now()); const q = new URLSearchParams(Object.assign({ game: cfg.game }, params || {}, { ts, sig: hmac('player:' + who + ':' + ts) }));
|
||||
const r = await doFetch(cfg.iap + path + '?' + q.toString(), { signal: AbortSignal.timeout(6000) });
|
||||
const text = await r.text(); let json = null; try { json = JSON.parse(text); } catch (e) {}
|
||||
return { status: r.status, json };
|
||||
}
|
||||
|
||||
// the one call that matters -> { allowed, deferred, carried, pass, day, capHit, enforced, repeat, lifetimeHit, freeLifetime, waiting, retry: false }
|
||||
// or { allowed: 0, retry: true, error }. Never throws.
|
||||
async function grant({ memberId, email, game, kind, pol, ref }) {
|
||||
const body = { memberId: Number(memberId) || 0, email: String(email || '').trim().toLowerCase() || undefined, game: game || cfg.game, kind: kind === 'daily' ? 'daily' : 'progress', pol: r4(Math.max(0, Number(pol) || 0)), ref: String(ref || '') };
|
||||
if (!whoOf(body.memberId, body.email) || !body.ref) return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: false, error: 'bad request' };
|
||||
if (!ready()) return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: true, error: 'polgrant not configured' };
|
||||
try {
|
||||
const { status, json } = await post('/api/partner/polgrant', body);
|
||||
if (status !== 200 || !json || typeof json.allowed !== 'number') return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: true, error: 'http ' + status + (json && json.error ? ': ' + json.error : '') };
|
||||
const out = { allowed: r4(Math.max(0, json.allowed)), deferred: r4(Math.max(0, Number(json.deferred) || 0)), carried: r4(Math.max(0, Number(json.carried) || 0)), pass: !!(json.pass && (json.pass === true || json.pass.active)), day: json.day || ctDay(), capHit: json.capHit || null, enforced: json.enforced !== false, repeat: !!json.repeat, suspended: !!json.suspended, lifetimeHit: !!json.lifetimeHit, freeLifetime: Number(json.freeLifetime) || 0, waiting: r4(Math.max(0, Number(json.waiting) || 0)), retry: false };
|
||||
// a REPEATED ref answers with the pass state of the day it was first granted (IAP gamepass.grant prev.pass), which can be weeks
|
||||
// old: never let that overwrite what we know now (2026-11-23, @bizventures recorded as no pass while holding one)
|
||||
if (!json.repeat) rememberPass(body.memberId, body.email, json.pass, json.passUntil || (json.pass && json.pass.until));
|
||||
return out;
|
||||
} catch (e) { return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: true, error: String(e && e.message || e).slice(0, 120) }; }
|
||||
}
|
||||
// the game decided not to pay after all (rare): tell IAP so that ref's own share comes back. Best effort.
|
||||
async function voidGrant({ memberId, email, game, ref }) {
|
||||
if (!ready() || !whoOf(memberId, email) || !ref) return { ok: false };
|
||||
try { const { status } = await post('/api/partner/polgrant/void', { memberId: Number(memberId) || 0, email: String(email || '').toLowerCase() || undefined, game: game || cfg.game, ref: String(ref) }); return { ok: status === 200 }; } catch (e) { return { ok: false, error: String(e && e.message || e) }; }
|
||||
}
|
||||
|
||||
// ---- the pass flag: from the sign-in hand-off (claims.gamePass), every grant answer, or a signed GET to IAP ----------------
|
||||
function passOf(memberId, email) {
|
||||
const who = whoOf(memberId, email), all = cfg.store && who ? cfg.store.read(cfg.passKey, {}) : {}, p = all[who] || null;
|
||||
if (!p) return { active: false, until: null, at: 0 };
|
||||
const active = !!p.active && (!p.until || p.until > Date.now());
|
||||
return { active, until: p.until || null, at: p.at || 0 };
|
||||
}
|
||||
// pass = true/false or { active, until }; until = ms when known
|
||||
function rememberPass(memberId, email, pass, until) {
|
||||
const who = whoOf(memberId, email); if (!cfg.store || !who || pass == null) return;
|
||||
const active = pass === true || !!(pass && pass.active); const u = Number(until || (pass && pass.until)) || null;
|
||||
cfg.store.update(cfg.passKey, {}, all => { const cur = all[who] || {}; all[who] = { active, until: active ? (u || cur.until || null) : null, at: Date.now() }; return all; });
|
||||
}
|
||||
// refresh from IAP when the cached answer is stale; fail-soft (display only, the grant answers are the truth for money)
|
||||
async function fetchPass(memberId, email) {
|
||||
const who = whoOf(memberId, email), cur = passOf(memberId, email); if (!ready() || !who) return cur;
|
||||
if (Date.now() - cur.at < PASS_TTL) return cur;
|
||||
try {
|
||||
const { status, json } = await get('/api/partner/player', who, { m: Number(memberId) || 0, e: String(email || '').toLowerCase() });
|
||||
if (status !== 200 || !json) throw new Error('http ' + status);
|
||||
if (json.pass != null) rememberPass(memberId, email, json.pass, json.pass && json.pass.until);
|
||||
return passOf(memberId, email);
|
||||
} catch (e) { return cur; }
|
||||
}
|
||||
// ask InstantAdPay NOW, whatever the stored copy says (the weekly prize run, 2026-11-23): { ok, active }. ok false = IAP did not
|
||||
// answer, so the caller must wait and ask again, never decide on the stored copy.
|
||||
async function freshPass(memberId, email) {
|
||||
const who = whoOf(memberId, email); if (!ready() || !who) return { ok: false, active: false };
|
||||
try {
|
||||
const { status, json } = await get('/api/partner/player', who, { m: Number(memberId) || 0, e: String(email || '').toLowerCase() });
|
||||
if (status === 404) { rememberPass(memberId, email, false); return { ok: true, active: false }; }
|
||||
if (status !== 200 || !json || json.pass == null) return { ok: false, active: false };
|
||||
rememberPass(memberId, email, json.pass, json.pass && json.pass.until);
|
||||
return { ok: true, active: passOf(memberId, email).active };
|
||||
} catch (e) { return { ok: false, active: false }; }
|
||||
}
|
||||
// what the lobby shows: { on, active, until, untilText, url }
|
||||
function view(memberId, email) {
|
||||
const p = whoOf(memberId, email) ? passOf(memberId, email) : { active: false, until: null };
|
||||
return { on: on(), active: p.active, until: p.until, untilText: p.until ? new Date(p.until).toLocaleDateString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric' }) : null, url: PASS_URL };
|
||||
}
|
||||
|
||||
// ---- the player-facing truth for a grant answer ------------------------------------------------------------------------
|
||||
function note(resp, kind, nominal) {
|
||||
nominal = r4(nominal);
|
||||
if (!resp) return null;
|
||||
if (resp.retry) return 'Your reward is recorded and pays as soon as InstantAdPay confirms it.';
|
||||
// the free allowance is used up (Marty 2026-11-03): only the Game Pass pays from here, so say so, and what is waiting for them
|
||||
if (resp.lifetimeHit && !resp.pass) {
|
||||
const cap = resp.freeLifetime ? r4(resp.freeLifetime) + ' POL' : 'POL';
|
||||
const wait = kind === 'progress' && resp.waiting > 0 ? ' Your ' + r4(resp.waiting) + ' POL earned since is saved and pays out with the Pass.' : '';
|
||||
return 'You have used your free ' + cap + ' in the games. Get the Game Pass to keep earning.' + wait;
|
||||
}
|
||||
if (kind === 'progress' && resp.deferred > 0) return resp.deferred + ' POL is yours; it pays out over the next days (daily cap).';
|
||||
if (kind === 'daily' && resp.allowed + 1e-9 < nominal) return resp.pass ? 'Daily cap reached for today.' : 'Daily cap reached for today. Get the Pass for a higher cap.';
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---- the retry queue (fail closed, never lost): persisted, every 5 minutes, 48 hours, then the admin chat ----------------
|
||||
function enqueue(item) {
|
||||
if (!cfg.store) return null;
|
||||
const row = Object.assign({}, item, { memberId: Number(item.memberId) || 0, email: String(item.email || '').toLowerCase(), ref: String(item.ref), at: item.at || Date.now(), tries: 0, nextAt: Date.now() + RETRY_MS, stuck: false });
|
||||
row.who = whoOf(row.memberId, row.email);
|
||||
cfg.store.update(cfg.queueKey, [], q => { if (!q.some(x => (x.who || whoOf(x.memberId, x.email)) === row.who && x.ref === row.ref)) q.push(row); return q; });
|
||||
return row;
|
||||
}
|
||||
const queue = () => cfg.store ? cfg.store.read(cfg.queueKey, []) : [];
|
||||
const same = (x, memberId, email, ref) => (x.who || whoOf(x.memberId, x.email)) === whoOf(memberId, email) && x.ref === String(ref);
|
||||
const queued = (memberId, email, ref) => queue().some(x => same(x, memberId, email, ref)); // waiting on IAP: do not ask again
|
||||
const dequeue = (memberId, email, ref) => cfg.store && cfg.store.update(cfg.queueKey, [], q => q.filter(x => !same(x, memberId, email, ref)));
|
||||
// pay(item, resp) settles the answer in the game's own ledger. Returns { tried, paid, stuck }.
|
||||
async function retry(pay, now) {
|
||||
now = now || Date.now(); const out = { tried: 0, paid: 0, stuck: 0 };
|
||||
if (!cfg.store || !on()) return out;
|
||||
for (const item of queue()) {
|
||||
if (item.stuck || item.nextAt > now) continue;
|
||||
out.tried++;
|
||||
const r = await grant({ memberId: item.memberId, email: item.email, kind: item.kind, pol: item.pol, ref: item.ref });
|
||||
if (r.retry) {
|
||||
const stuck = now - item.at >= GIVE_UP_MS;
|
||||
cfg.store.update(cfg.queueKey, [], q => { const x = q.find(y => same(y, item.memberId, item.email, item.ref)); if (x) { x.tries = (x.tries || 0) + 1; x.nextAt = now + RETRY_MS; x.lastError = r.error || null; if (stuck) x.stuck = true; } return q; });
|
||||
if (stuck) { out.stuck++; if (cfg.notify) { try { await cfg.notify('gpstuck', { memberId: item.memberId, email: item.email, ref: item.ref, pol: item.pol, kind: item.kind, since: item.at, error: r.error || null }); } catch (e) {} } }
|
||||
continue;
|
||||
}
|
||||
dequeue(item.memberId, item.email, item.ref);
|
||||
try { await pay(item, r); out.paid++; } catch (e) { if (cfg.log) cfg.log.error('polgrant pay', item.ref, e && e.message); }
|
||||
}
|
||||
return out;
|
||||
}
|
||||
let timer = null;
|
||||
function startRetry(pay, everyMs) { if (timer) return timer; timer = setInterval(() => { retry(pay).catch(e => cfg.log && cfg.log.error('polgrant retry', e && e.message)); }, everyMs || RETRY_MS); if (timer.unref) timer.unref(); return timer; }
|
||||
function stopRetry() { if (timer) clearInterval(timer); timer = null; }
|
||||
|
||||
// ---- the weekly Pass Tournament prize seam (3a item 8): IAP records the winners, a game's faucet pays them ------------------
|
||||
// -> { ok, rows: [{ id?, week, place, email, memberId, wallet, pol }] } or { ok: false, retry: true, error }
|
||||
async function tournamentPending() {
|
||||
if (!ready()) return { ok: false, retry: true, error: 'polgrant not configured', rows: [] };
|
||||
try { const { status, json } = await get('/api/partner/tournament/pending', 'tournament', {}); if (status !== 200 || !json) return { ok: false, retry: true, error: 'http ' + status, rows: [] }; return { ok: true, rows: Array.isArray(json.rows) ? json.rows : Array.isArray(json) ? json : [] }; }
|
||||
catch (e) { return { ok: false, retry: true, error: String(e && e.message || e).slice(0, 120), rows: [] }; }
|
||||
}
|
||||
// the row leaves IAP's unpaid list once the game reports the tx (sends id when the row has one, and week + place always)
|
||||
async function tournamentPaid(row, tx) {
|
||||
if (!ready()) return { ok: false, error: 'polgrant not configured' };
|
||||
try { const { status, json } = await post('/api/partner/tournament/paid', { id: row.id, week: row.week, place: row.place, memberId: row.memberId, email: row.email, tx }); return { ok: status === 200 && !(json && json.error), status, error: json && json.error }; }
|
||||
catch (e) { return { ok: false, error: String(e && e.message || e).slice(0, 120) }; }
|
||||
}
|
||||
|
||||
// ad credits for a player (PolHunter tour stops, 2026-11-17; other games may use it later): IAP grants earned-grade credits
|
||||
// with a credit-activity line, once per ref (a retry answers repeat: true). -> { ok, credits, repeat } or { ok: false, error }. Never throws.
|
||||
async function credits({ memberId, email, credits: n, ref, note }) {
|
||||
const body = { memberId: Number(memberId) || 0, email: String(email || '').trim().toLowerCase() || undefined, credits: Math.max(0, Math.round(Number(n) || 0)), ref: String(ref || ''), note: String(note || '').slice(0, 120) };
|
||||
if (!whoOf(body.memberId, body.email) || !body.ref || !body.credits) return { ok: false, error: 'bad request' };
|
||||
if (!ready()) return { ok: false, error: 'polgrant not configured' };
|
||||
try { const { status, json } = await post('/api/partner/credits', body); if (status === 200 && json && json.ok) return { ok: true, credits: Number(json.credits) || 0, repeat: !!json.repeat }; return { ok: false, error: 'http ' + status + (json && json.error ? ': ' + json.error : '') }; }
|
||||
catch (e) { return { ok: false, error: String(e && e.message || e).slice(0, 120) }; }
|
||||
}
|
||||
module.exports = { use, on, whoOf, grant, voidGrant, credits, passOf, rememberPass, fetchPass, freshPass, view, note, enqueue, queue, queued, dequeue, retry, startRetry, stopRetry, tournamentPending, tournamentPaid, PASS_URL, RETRY_MS, GIVE_UP_MS, ctDay, r4, _cfg: () => cfg };
|
||||
+34
-17
@@ -18,7 +18,10 @@ const { ctDay } = require('./missions');
|
||||
// drawSkew k: log-uniform on u^(1/k), so k=1 is the plain log-uniform and k=3 leans hard to the floor
|
||||
// (mean ~0.13 POL on 0.05..1, one drip in eighty above 0.5). missionsPerDay: finds per hunter per
|
||||
// Central day (Marty, 2026-09-20: cap 40, k=3, 3 a day, so a launch morning does not empty the pool)
|
||||
const DEFAULTS = { minPol: 0.05, maxPol: 1, dailyCapPol: 20, lowBalancePol: 40, drawSkew: 3, missionsPerDay: 3 };
|
||||
const DEFAULTS = { minPol: 0.05, maxPol: 1, dailyCapPol: 20, lowBalancePol: 40, drawSkew: 3, missionsPerDay: 3,
|
||||
// the free tier (Marty 2026-11-02, every game must fund itself): a free account gets freeMissionsPerDay hunts drawn on
|
||||
// freeMinPol..freeMaxPol; the full allotment and the full draw are for Game Pass holders (the Pass is the purchase)
|
||||
freeMissionsPerDay: 1, freeMinPol: 0.02, freeMaxPol: 0.1 };
|
||||
function settings() { return Object.assign({}, DEFAULTS, store.read('settings', {})); }
|
||||
function setSettings(patch) { return store.update('settings', {}, s => Object.assign(s, patch)); }
|
||||
|
||||
@@ -35,13 +38,17 @@ function draw(min, max, skew) {
|
||||
// day defaults to today: called without it the comparison was against undefined and silently
|
||||
// returned 0 for everyone, which would read as "no finds yet" to any new caller
|
||||
function findsToday(memberId, day) { const d = day || ctDay(); return store.read('payouts', []).filter(p => p.memberId === Number(memberId) && p.day === d && p.status !== 'failed' && !p.prize && !p.ref && !p.detective).length; }
|
||||
function daily(memberId, doneIds, bonus) { const s = settings(); const base = Math.max(1, Number(s.missionsPerDay) || 3);
|
||||
// passExtra: the Game Pass perk, +2 missions a day while the member's pass is active (GAME-PASS.md 4: 3 -> 5); 0 otherwise
|
||||
function daily(memberId, doneIds, bonus, passExtra, pass) { const s = settings(); const base = pass ? Math.max(1, Number(s.missionsPerDay) || 3) : Math.max(1, Number(s.freeMissionsPerDay) || 1); // free tier since 2026-11-02
|
||||
// every live paid mission this hunter has not done yet adds one, because the company is not
|
||||
// funding that completion
|
||||
let extra = 0; try { extra = require('./paid').extraAllowance(doneIds); } catch (e) {}
|
||||
// Friday Bonus Hunts: extra hunts banked Sat-Thu on InstantAdPay, usable on Friday only (lib/fridaybank.js)
|
||||
const fb = Math.max(0, Number(bonus) || 0);
|
||||
const limit = base + extra + fb; const done = findsToday(memberId, ctDay()); return { limit, done, left: Math.max(0, limit - done), base, friday: fb }; }
|
||||
const fb = Math.max(0, Number(bonus) || 0), pe = Math.max(0, Number(passExtra) || 0);
|
||||
const limit = base + extra + fb + pe; const done = findsToday(memberId, ctDay()); return { limit, done, left: Math.max(0, limit - done), base, friday: fb, pass: pe }; }
|
||||
// the nominal amount a completion of `mission` would pay (the Game Pass asks InstantAdPay about it before grant() records it)
|
||||
function quote(mission, pass) { const s = settings(); if (mission.paid) return Math.round(Number(mission.hunterPol || 0) * 10000) / 10000; // an advertiser-funded find pays what the advertiser set, every tier
|
||||
return pass ? draw(Number(s.minPol), Number(s.maxPol)) : draw(Number(s.freeMinPol), Number(s.freeMaxPol)); } // the free draw since 2026-11-02
|
||||
// What the COMPANY has spent today. Advertiser-funded completions are excluded on purpose: the
|
||||
// hunter is paid out of what the advertiser already put in the faucet, so counting it here would
|
||||
// let a paid mission use up the house budget (Marty, 2026-09-24).
|
||||
@@ -62,28 +69,37 @@ function doneToday(memberId, wallet) {
|
||||
return new Set(store.read('payouts', []).filter(p => p.day === day && p.status !== 'failed' && !p.prize && !p.ref && !p.detective && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))).map(p => p.missionId));
|
||||
}
|
||||
|
||||
// record a completion; decide paid-today vs queued
|
||||
function grant(member, mission) {
|
||||
const s = settings();
|
||||
// record a completion; decide paid-today vs queued.
|
||||
// opts (the Game Pass, GAME-PASS.md 3a): { pol, status, gp, nominal }: `pol` is what InstantAdPay allowed (0 = the account-wide daily
|
||||
// cap is reached: the find is recorded with status 'capped', pays nothing, and still counts as today's find); status 'gp-wait' = IAP
|
||||
// could not be reached, the row holds the nominal amount and is settled by settleQueued() when the retry queue gets an answer.
|
||||
function grant(member, mission, opts) {
|
||||
opts = opts || {}; const s = settings();
|
||||
// An advertiser-funded mission pays exactly what the advertiser set, every time. No draw, so
|
||||
// the reserve taken at purchase is exact and can never come up short.
|
||||
const isPaid = !!mission.paid;
|
||||
const pol = isPaid ? Math.round(Number(mission.hunterPol || 0) * 10000) / 10000
|
||||
: draw(Number(s.minPol), Number(s.maxPol));
|
||||
const pol = opts.pol != null ? Math.round(Number(opts.pol) * 10000) / 10000 : quote(mission, !!opts.pass);
|
||||
const day = ctDay();
|
||||
const budgetLeft = mission.budget ? mission.budget - store.read('payouts', []).filter(p => p.missionId === mission.id && p.status !== 'failed').length : Infinity;
|
||||
if (budgetLeft <= 0) return { error: 'This mission has paid out all it was funded for.' };
|
||||
// the house cap governs house spend only; a paid completion is already funded
|
||||
const overCap = !isPaid && (paidToday(day) + pol > Number(s.dailyCapPol));
|
||||
const overCap = pol > 0 && !isPaid && (paidToday(day) + pol > Number(s.dailyCapPol));
|
||||
const rec = {
|
||||
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 8),
|
||||
memberId: Number(member.memberId), email: member.email, wallet: member.wallet, username: member.username || null,
|
||||
missionId: mission.id, site: mission.site, pol, day, at: Date.now(),
|
||||
paid: isPaid || undefined, // marks advertiser-funded spend so the house accounting skips it
|
||||
status: overCap ? 'queued' : 'due', tx: null, paidAt: null, error: null,
|
||||
status: opts.status || (pol > 0 ? (overCap ? 'queued' : 'due') : 'capped'), tx: null, paidAt: null, error: null,
|
||||
gp: opts.gp || undefined, nominal: opts.nominal != null ? opts.nominal : undefined,
|
||||
};
|
||||
store.update('payouts', [], all => { all.push(rec); return all; });
|
||||
return { ok: true, rec, queued: overCap };
|
||||
return { ok: true, rec, queued: rec.status === 'queued', capped: rec.status === 'capped', waiting: rec.status === 'gp-wait' };
|
||||
}
|
||||
// a 'gp-wait' row gets InstantAdPay's answer: pay what was allowed (due, or queued past the house cap), or record the cap hit
|
||||
function settleQueued(id, allowed, gp) {
|
||||
const s = settings(); const pol = Math.round(Number(allowed) * 10000) / 10000; let row = null;
|
||||
store.update('payouts', [], all => { const p = all.find(x => x.id === id); if (p && p.status === 'gp-wait') { const over = pol > 0 && !p.paid && (paidToday(p.day) + pol - (p.pol || 0) > Number(s.dailyCapPol)); Object.assign(p, { pol, status: pol > 0 ? (over ? 'queued' : 'due') : 'capped', gp: Object.assign({}, p.gp || {}, gp || {}, { pending: false }) }); row = p; } return all; });
|
||||
return row;
|
||||
}
|
||||
|
||||
// A fixed, disclosed amount for a non-find task (an Ad Detective case). House money, so it sits inside
|
||||
@@ -91,16 +107,17 @@ function grant(member, mission) {
|
||||
// of the daily limit, the leaderboard, prizes, referral matches and the find badges).
|
||||
function grantFixed(member, t) {
|
||||
const s = settings(); const day = ctDay(); const pol = Math.round(Number(t.pol) * 10000) / 10000;
|
||||
if (!(pol > 0)) return { error: 'no reward set' };
|
||||
const overCap = paidToday(day) + pol > Number(s.dailyCapPol);
|
||||
if (!(pol > 0) && !t.gp) return { error: 'no reward set' }; // the Game Pass may record a 0 (account-wide cap reached), see grant()
|
||||
const overCap = pol > 0 && paidToday(day) + pol > Number(s.dailyCapPol);
|
||||
const rec = {
|
||||
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 8),
|
||||
memberId: Number(member.memberId), email: member.email, wallet: member.wallet, username: member.username || null,
|
||||
missionId: t.missionId, site: t.site, pol, day, at: Date.now(), detective: t.detective || true,
|
||||
status: overCap ? 'queued' : 'due', tx: null, paidAt: null, error: null,
|
||||
status: t.status || (pol > 0 ? (overCap ? 'queued' : 'due') : 'capped'), tx: null, paidAt: null, error: null,
|
||||
gp: t.gp || undefined, nominal: t.nominal != null ? t.nominal : undefined,
|
||||
};
|
||||
store.update('payouts', [], all => { all.push(rec); return all; });
|
||||
return { ok: true, rec, queued: overCap };
|
||||
return { ok: true, rec, queued: rec.status === 'queued', capped: rec.status === 'capped', waiting: rec.status === 'gp-wait' };
|
||||
}
|
||||
|
||||
// what the faucet should pay now: due entries, then queued ones as long as today's cap allows
|
||||
@@ -141,4 +158,4 @@ function totals() {
|
||||
return { paid: paid.length, pol: Math.round(paid.reduce((n, p) => n + p.pol, 0) * 10000) / 10000, queued: all.filter(p => p.status === 'queued').length, today: paidToday(ctDay()), hunters: new Set(paid.map(p => p.memberId)).size };
|
||||
}
|
||||
|
||||
module.exports = { settings, setSettings, draw, grant, grantFixed, completed, doneToday, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday, unposted };
|
||||
module.exports = { settings, setSettings, draw, quote, grant, grantFixed, settleQueued, completed, doneToday, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday, unposted };
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
// The Network Tour (Marty 2026-11-17): mission rotation per hunter, and the free tier's tour stops.
|
||||
//
|
||||
// Measured 11-03 to 11-17: hunters repeated favorites (old sites 57-73 finds each, the rebuilt network sites 0-6).
|
||||
// So each hunter works through ROUNDS. A round = every active house mission (advertiser-paid missions are extra
|
||||
// allowance and stay outside the round). The board offers only the missions this hunter has not found in the
|
||||
// current round; once every one is found, the round closes and a new one starts. Never-visited missions sort
|
||||
// first, then the least recently found. A mission added mid-round joins the current round as not found; a paused
|
||||
// one is skipped and never blocks a round. Daily limits, draws, the pool and the tiers are untouched.
|
||||
//
|
||||
// State per member, on the volume (rotation.json): { start, rounds, closed: [ts...] }. `start` = the round began
|
||||
// after this instant; finds (member id OR wallet, the same rule as doneToday) at or after it count to the round.
|
||||
// Everyone starts at start 0, so a hunter's first round is their whole history: the sites they never visited are
|
||||
// exactly what is left, which is the point.
|
||||
//
|
||||
// Tour stops (free tier, Marty 2026-11-17): a free member (no active Game Pass, GAMEPASS on) is paid POL only for
|
||||
// DISCOVERY, a find on a house mission they have never found before. A repeat find is a "tour stop": it counts as
|
||||
// their hunt for the day, for the round and for the Full Network Tour badge, pays no POL, and grants a few
|
||||
// InstantAdPay ad credits (settings tourStopCredits / tourStopCreditsDailyMax) through a signed call. A new
|
||||
// mission pays POL again on each free member's first find of it. Game Pass holders are unchanged.
|
||||
'use strict';
|
||||
const store = require('./store');
|
||||
const missions = require('./missions');
|
||||
|
||||
const DEFAULTS = { rotationOn: 1, tourStopCredits: 10, tourStopCreditsDailyMax: 10 };
|
||||
function cfg() { const s = Object.assign({}, DEFAULTS, store.read('settings', {})); return { on: !!Number(s.rotationOn), credits: Math.max(0, Math.round(Number(s.tourStopCredits) || 0)), dailyMax: Math.max(0, Math.round(Number(s.tourStopCreditsDailyMax) || 0)) }; }
|
||||
|
||||
// the missions that make up a round: active house missions (paid ones are extra allowance, not part of the tour)
|
||||
function roundMissions() { return missions.list().filter(m => m.active && !m.paid); }
|
||||
// a hunter's house finds, all time, oldest first: non-failed, not prizes / referral drips / detective cases / paid missions
|
||||
function findsOf(memberId, wallet) {
|
||||
const w = wallet ? String(wallet).toLowerCase() : null; const id = Number(memberId);
|
||||
return store.read('payouts', []).filter(p => p.status !== 'failed' && !p.prize && !p.ref && !p.detective && !p.paid && (p.memberId === id || (w && p.wallet && String(p.wallet).toLowerCase() === w)))
|
||||
.sort((a, b) => (a.at || 0) - (b.at || 0));
|
||||
}
|
||||
// has this hunter ever found this mission (all time)? the discovery test
|
||||
function everFound(memberId, wallet, missionId) { return findsOf(memberId, wallet).some(p => p.missionId === missionId); }
|
||||
|
||||
// the round as it stands; closes any finished round on the way (persisted), so every caller sees the same thing
|
||||
function state(me) {
|
||||
const key = String(Number(me.memberId)); const finds = findsOf(me.memberId, me.wallet);
|
||||
const all = store.read('rotation', {}); let st = Object.assign({ start: 0, rounds: 0, closed: [] }, all[key] || {}); let changed = false;
|
||||
const round = roundMissions(); const ids = new Set(round.map(m => m.id));
|
||||
for (let guard = 0; guard < 100 && ids.size; guard++) {
|
||||
const got = new Set(); let closeAt = null;
|
||||
for (const p of finds) { if ((p.at || 0) < st.start || !ids.has(p.missionId)) continue; got.add(p.missionId); if (got.size === ids.size) { closeAt = p.at || 0; break; } }
|
||||
if (closeAt == null) break;
|
||||
st = { start: closeAt + 1, rounds: st.rounds + 1, closed: st.closed.concat([closeAt]).slice(-50) }; changed = true;
|
||||
}
|
||||
if (changed) store.update('rotation', {}, a => { a[key] = st; return a; });
|
||||
const done = new Set(finds.filter(p => (p.at || 0) >= st.start && ids.has(p.missionId)).map(p => p.missionId));
|
||||
const last = new Map(); for (const p of finds) last.set(p.missionId, p.at || 0); // last find per mission, all time
|
||||
const left = round.filter(m => !done.has(m.id));
|
||||
const toured = round.length > 0 && round.every(m => last.has(m.id)); // every active house mission found at least once, ever
|
||||
return { on: cfg().on, round: st.rounds + 1, rounds: st.rounds, total: round.length, done: round.length - left.length, doneIds: done, left, last, toured, start: st.start };
|
||||
}
|
||||
const rounds = memberId => { const st = store.read('rotation', {})[String(Number(memberId))]; return st ? Number(st.rounds) || 0 : 0; };
|
||||
|
||||
// the board's order: missions open this round (or every mission with rotation off), never-visited first, then the
|
||||
// least recently found; the member's daily shuffle (forMember) breaks ties. Paid missions keep their place in the mix.
|
||||
function order(me, st) {
|
||||
st = st || state(me); const base = missions.forMember(me.memberId);
|
||||
const open = st.on ? base.filter(m => m.paid || !st.doneIds.has(m.id)) : base;
|
||||
const rank = m => st.last.has(m.id) ? st.last.get(m.id) + 1 : 0; // 0 = never found, sorts first
|
||||
return open.map((m, i) => ({ m, i, r: rank(m) })).sort((a, b) => a.r - b.r || a.i - b.i).map(x => x.m);
|
||||
}
|
||||
// may this hunter start this mission? (rotation on: not if it was found earlier in this round; paid missions always)
|
||||
function blocked(me, m, st) { st = st || state(me); return !!(st.on && !m.paid && st.doneIds.has(m.id)); }
|
||||
|
||||
// ---- tour stops --------------------------------------------------------------------------------------------------
|
||||
// credits already granted (or owed) to this member today for tour stops
|
||||
function creditsToday(memberId) { const day = missions.ctDay(); return store.read('payouts', []).filter(p => p.memberId === Number(memberId) && p.day === day && p.tourStop).reduce((n, p) => n + (Number(p.tourStop.credits) || 0), 0); }
|
||||
// a free member's repeat find: the payout row (pol 0, status 'tour') carrying the credits to deliver
|
||||
function tourStop(me, m) {
|
||||
const c = cfg(); const credits = Math.max(0, Math.min(c.credits, c.dailyMax - creditsToday(me.memberId)));
|
||||
const rec = { id: Date.now().toString(36) + Math.random().toString(36).slice(2, 8), memberId: Number(me.memberId), email: me.email, wallet: me.wallet, username: me.username || null,
|
||||
missionId: m.id, site: m.site, pol: 0, day: missions.ctDay(), at: Date.now(), status: 'tour', tx: null, paidAt: null, error: null,
|
||||
tourStop: { credits, state: credits > 0 ? 'due' : 'none', tries: 0, sentAt: null } };
|
||||
store.update('payouts', [], all => { all.push(rec); return all; });
|
||||
return rec;
|
||||
}
|
||||
function markStop(id, patch) { let row = null; store.update('payouts', [], all => { const p = all.find(x => x.id === id); if (p && p.tourStop) { Object.assign(p.tourStop, patch); row = p; } return all; }); return row; }
|
||||
// deliver one stop's credits through InstantAdPay (polgrant.credits, signed, idempotent on ref 'tour:<row id>')
|
||||
async function deliver(row, gp) {
|
||||
if (!row || !row.tourStop || row.tourStop.state !== 'due' || !gp || !gp.credits) return null;
|
||||
const r = await gp.credits({ memberId: row.memberId, email: row.email, credits: row.tourStop.credits, ref: 'tour:' + row.id, note: 'PolHunter tour stop: ' + row.site });
|
||||
if (r && r.ok) return markStop(row.id, { state: 'sent', sentAt: Date.now(), granted: r.credits != null ? r.credits : row.tourStop.credits, error: null });
|
||||
return markStop(row.id, { tries: (row.tourStop.tries || 0) + 1, error: String((r && r.error) || 'no answer').slice(0, 120) }); // stays 'due' (owed): the tick retries
|
||||
}
|
||||
// the 2-minute tick: owed credits go out (a stop stays owed until InstantAdPay confirms it)
|
||||
async function retryDue(gp) { let n = 0; for (const p of store.read('payouts', []).filter(x => x.tourStop && x.tourStop.state === 'due').slice(0, 20)) { const r = await deliver(p, gp); if (r && r.tourStop.state === 'sent') n++; } return n; }
|
||||
|
||||
// admin: round stats per hunter (anyone with a house find)
|
||||
function adminView() {
|
||||
const seen = new Map(); for (const p of store.read('payouts', [])) if (!p.prize && !p.ref && !p.detective && !p.paid && p.status !== 'failed') seen.set(p.memberId, { memberId: p.memberId, wallet: p.wallet || (seen.get(p.memberId) || {}).wallet, who: p.username ? '@' + p.username : '#' + p.memberId });
|
||||
const rows = [...seen.values()].map(h => { const s = state(h); return { memberId: h.memberId, who: h.who, round: s.round, rounds: s.rounds, done: s.done, total: s.total, toured: s.toured, left: s.left.map(m => m.site), lastFind: s.last.size ? Math.max(...s.last.values()) : null }; });
|
||||
rows.sort((a, b) => b.rounds - a.rounds || b.done - a.done);
|
||||
const stops = store.read('payouts', []).filter(p => p.tourStop);
|
||||
return { settings: cfg(), hunters: rows, tourStops: { total: stops.length, sent: stops.filter(p => p.tourStop.state === 'sent').length, owed: stops.filter(p => p.tourStop.state === 'due').length, creditsSent: stops.filter(p => p.tourStop.state === 'sent').reduce((n, p) => n + (Number(p.tourStop.granted) || 0), 0), creditsOwed: stops.filter(p => p.tourStop.state === 'due').reduce((n, p) => n + (Number(p.tourStop.credits) || 0), 0) } };
|
||||
}
|
||||
|
||||
module.exports = { DEFAULTS, cfg, roundMissions, findsOf, everFound, state, rounds, order, blocked, creditsToday, tourStop, deliver, retryDue, markStop, adminView };
|
||||
+47
-5
@@ -15,7 +15,7 @@ const BADGES = [
|
||||
{ id: 'first', name: 'First Find', icon: '\u{1F3AF}', why: 'your first code claimed' },
|
||||
{ id: 'hunter', name: 'Hunter', icon: '\u{1F9ED}', why: 'five finds' },
|
||||
{ id: 'tracker', name: 'Tracker', icon: '\u{1F526}', why: 'twenty finds' },
|
||||
{ id: 'sweep', name: 'Full Sweep', icon: '\u{1F5FA}️', why: 'a find on every site' },
|
||||
{ id: 'sweep', name: 'Full Network Tour',icon: '\u{1F5FA}️', why: 'a find on every site in one round of the network tour' }, // renamed 2026-11-17 (the art still reads FULL SWEEP; only the title changed)
|
||||
{ id: 'lucky', name: 'Lucky Find', icon: '\u{1F48E}', why: 'one drip of 0.4 POL or more' },
|
||||
{ id: 'streak', name: 'On a Streak', icon: '\u{1F525}', why: 'finds on three days in a row' },
|
||||
{ id: 'top', name: 'Top Hunter', icon: '\u{1F3C6}', why: 'won a weekly prize as #1' },
|
||||
@@ -60,7 +60,8 @@ function badgesFor(memberId, list) {
|
||||
if (mine.length >= 5) out.add('hunter');
|
||||
if (mine.length >= 20) out.add('tracker');
|
||||
const sites = new Set(missions.list().filter(m => m.active !== false).map(m => m.site));
|
||||
if (sites.size && [...sites].every(s => mine.some(p => p.site === s))) out.add('sweep');
|
||||
if (sites.size && [...sites].every(s => mine.some(p => p.site === s))) out.add('sweep'); // the original rule, so nobody loses it
|
||||
try { if (require('./rotation').rounds(memberId) >= 1) out.add('sweep'); } catch (e) {} // a closed round of the Network Tour (once per round, count on the card)
|
||||
if (mine.some(p => p.pol >= 0.4)) out.add('lucky');
|
||||
const days = new Set(mine.map(p => p.day));
|
||||
for (const d of days) { if (days.has(dayMinus(d, 1)) && days.has(dayMinus(d, 2))) { out.add('streak'); break; } }
|
||||
@@ -101,7 +102,10 @@ function awardWeek(monday) {
|
||||
const done = store.read('prizes', []);
|
||||
if (done.some(x => x.week === monday)) return { skipped: 'already awarded', week: monday };
|
||||
const rules = prizeRules();
|
||||
const winners = weekRows(monday).filter(r => r.finds >= rules.minFinds).slice(0, rules.pol.length).map((r, i) => Object.assign({ rank: i + 1, prizePol: rules.pol[i] }, r));
|
||||
// weekly prizes are for Game Pass holders (Marty 2026-11-02: the Pass is the purchase that funds the game; confirmed 2026-11-23, with
|
||||
// the leaderboard page now saying so in plain words); with GAMEPASS off, everyone qualifies as before
|
||||
let passOk = () => true; try { const gp = require('./polgrant'); if (gp.on && gp.on()) passOk = r => { try { return !!gp.passOf(r.memberId, r.email).active; } catch (e) { return false; } }; } catch (e) {}
|
||||
const winners = weekRows(monday).filter(r => r.finds >= rules.minFinds && passOk(r)).slice(0, rules.pol.length).map((r, i) => Object.assign({ rank: i + 1, prizePol: rules.pol[i] }, r));
|
||||
const day = ctDay(), at = Date.now();
|
||||
const recs = winners.map(w => ({ id: 'prize' + monday.replace(/-/g, '') + '-' + w.rank, memberId: w.memberId, email: w.email, wallet: w.wallet, username: w.username, missionId: 'prize:' + monday, site: 'Weekly prize #' + w.rank, pol: w.prizePol, day, at, status: 'due', tx: null, paidAt: null, error: null, prize: { week: monday, rank: w.rank } }));
|
||||
if (recs.length) store.update('payouts', [], all => { all.push(...recs); return all; });
|
||||
@@ -109,9 +113,47 @@ function awardWeek(monday) {
|
||||
store.update('prizes', [], all => { all.push(entry); return all; });
|
||||
return entry;
|
||||
}
|
||||
// ONE-TIME catch-up for a week that was already awarded (Marty 2026-11-23: the week of 11-16 paid only the one Pass holder while the
|
||||
// leaderboard page did not say a Pass was needed, so he paid places 2 and 3 once). It ignores the Pass on purpose: the top hunters
|
||||
// by finds are picked again, and anyone in that list who was not paid for the week gets the prize of their place. Nobody already
|
||||
// paid is touched, nothing is paid twice (a payout row for that member and week blocks it), and a second call adds nothing.
|
||||
function awardFill(monday) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(monday || '') || weekOf(monday) !== monday) return { error: 'not a Monday key' };
|
||||
const done = store.read('prizes', []), cur = done.find(x => x.week === monday);
|
||||
if (!cur) return { error: 'that week has not been awarded yet' };
|
||||
const rules = prizeRules(), paidTo = new Set(store.read('payouts', []).filter(p => p.prize && p.prize.week === monday).map(p => p.memberId));
|
||||
const top = weekRows(monday).filter(r => r.finds >= rules.minFinds).slice(0, rules.pol.length).map((r, i) => Object.assign({ rank: i + 1, prizePol: rules.pol[i] }, r));
|
||||
const add = top.filter(w => !paidTo.has(w.memberId));
|
||||
if (!add.length) return { week: monday, winners: [], filled: 0 };
|
||||
const day = ctDay(), at = Date.now();
|
||||
const recs = add.map(w => ({ id: 'prize' + monday.replace(/-/g, '') + '-f' + w.rank, memberId: w.memberId, email: w.email, wallet: w.wallet, username: w.username, missionId: 'prize:' + monday, site: 'Weekly prize #' + w.rank, pol: w.prizePol, day, at, status: 'due', tx: null, paidAt: null, error: null, prize: { week: monday, rank: w.rank, fill: true } }));
|
||||
store.update('payouts', [], all => { all.push(...recs); return all; });
|
||||
const added = add.map(w => ({ rank: w.rank, memberId: w.memberId, who: w.who, finds: w.finds, pol: w.pol, prizePol: w.prizePol }));
|
||||
store.update('prizes', [], all => { const e = all.find(x => x.week === monday); if (e) { e.winners = e.winners.concat(added).sort((a, b) => a.rank - b.rank); e.filledAt = at; } return all; });
|
||||
return { week: monday, winners: added, filled: added.length };
|
||||
}
|
||||
// on every tick: the most recent completed week gets awarded on the first tick after it ends
|
||||
function awardDue(notify) {
|
||||
// 2026-11-23: before the award, every hunter who could win (minimum finds reached) has their Game Pass asked fresh from InstantAdPay,
|
||||
// because awardWeek reads the stored copy and a stale "no pass" cost @bizventures 2nd place. If InstantAdPay does not answer for any
|
||||
// of them, nothing is awarded on this tick and the next tick (2 minutes) tries again.
|
||||
let awarding = false;
|
||||
async function awardDue(notify) {
|
||||
const last = dayMinus(weekOf(ctDay()), 7);
|
||||
if (awarding || store.read('prizes', []).some(x => x.week === last)) return null;
|
||||
awarding = true;
|
||||
try {
|
||||
let gp = null; try { gp = require('./polgrant'); } catch (e) {}
|
||||
if (gp && gp.on && gp.on() && gp.freshPass) {
|
||||
const rules = prizeRules();
|
||||
for (const r of weekRows(last).filter(x => x.finds >= rules.minFinds)) {
|
||||
const f = await gp.freshPass(r.memberId, r.email);
|
||||
if (!f.ok) { console.warn('prizes: pass check did not answer for', r.who, '- award waits for the next tick'); return null; }
|
||||
}
|
||||
}
|
||||
return awardNow(last, notify);
|
||||
} finally { awarding = false; }
|
||||
}
|
||||
function awardNow(last, notify) {
|
||||
if (store.read('prizes', []).some(x => x.week === last)) return null;
|
||||
const r = awardWeek(last);
|
||||
if (r && r.winners && r.winners.length && notify) notify('prize', r).catch(() => {});
|
||||
@@ -136,4 +178,4 @@ function memberByName(who) {
|
||||
}
|
||||
function shareLink(site, me) { const ref = me.username || me.memberId; return site + '/?r=' + encodeURIComponent(String(ref)); }
|
||||
|
||||
module.exports = { BADGES, badgesFor, leaderboard, rankOf, shareLink, weekOf, weekRows, awardWeek, awardDue, prizes, prizeRules, nameOf, memberByName };
|
||||
module.exports = { BADGES, badgesFor, leaderboard, rankOf, shareLink, weekOf, weekRows, awardWeek, awardFill, awardDue, prizes, prizeRules, nameOf, memberByName };
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// The weekly Pass Tournament prizes (GAME-PASS.md 3a item 8, Marty 2026-10-16: PolHunter's faucet pays them).
|
||||
//
|
||||
// InstantAdPay ranks the week's pass holders and records the winners; this job, every 10 minutes behind GAMEPASS=on, pulls the
|
||||
// unpaid rows (`GET /api/partner/tournament/pending`, signed), pays each from PolHunter's hot wallet through the faucet's own send
|
||||
// path (same wallet, same RPC rotation, same low-balance alert), and reports the hash (`POST /api/partner/tournament/paid`) so the
|
||||
// row leaves IAP's list. Prizes are not finds: they bypass the per-find daily cap and the payout threshold.
|
||||
//
|
||||
// Never twice (the deploy-overlap rule: two app copies run for ~30 s on every deploy): a durable claim per row is written to
|
||||
// `tourney-claims` on the volume BEFORE anything is sent; the tx hash is written the moment the chain has it (before the receipt
|
||||
// wait); on restart a claimed row with a hash is only re-reported, never re-sent; a claim without a hash is retried only after
|
||||
// CLAIM_TTL (the other copy had its chance). A send failure leaves the row pending on IAP and alerts the admin chat.
|
||||
// HUNT_DRY_RUN=on: record what would be paid, send nothing. Admin visibility: `state()` (last run, paid rows, failures) in /api/admin/state.
|
||||
'use strict';
|
||||
const store = require('./store');
|
||||
const gp = require('./polgrant');
|
||||
|
||||
const EVERY_MS = 10 * 60000, CLAIM_TTL = 10 * 60000, KEEP = 200;
|
||||
let deps = { faucet: null, notify: null, dry: () => false }; // faucet: { send(to, pol, onHash), balance(), address() }
|
||||
function init(d) { deps = Object.assign(deps, d || {}); }
|
||||
const ctDay = () => new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
const r4 = n => Math.round(Number(n) * 10000) / 10000;
|
||||
const keyOf = row => row.id != null ? 'id:' + row.id : 'wk:' + row.week + ':' + row.place;
|
||||
const claims = () => store.read('tourney-claims', {});
|
||||
function claim(k, row, now) { let got = false; store.update('tourney-claims', {}, all => { const c = all[k]; if (!c || (c.dry && !c.tx && !deps.dry()) || (!c.tx && !c.dry && now - (c.claimedAt || 0) >= CLAIM_TTL)) { all[k] = { claimedAt: now, week: row.week, place: row.place, memberId: row.memberId || 0, email: row.email || null, wallet: row.wallet, pol: r4(row.pol), tries: ((c && c.tries) || 0) + 1 }; got = true; } return all; }); return got; }
|
||||
const mark = (k, patch) => store.update('tourney-claims', {}, all => { if (all[k]) Object.assign(all[k], patch); return all; });
|
||||
const release = (k, patch) => store.update('tourney-claims', {}, all => { if (all[k] && !all[k].tx) { Object.assign(all[k], patch || {}); all[k].claimedAt = 0; } return all; }); // free for the next run
|
||||
let running = false;
|
||||
|
||||
async function run(now) {
|
||||
now = now || Date.now();
|
||||
const st = { lastRun: now, on: gp.on(), dry: deps.dry(), pending: 0, paid: 0, acked: 0, skipped: 0, wouldPay: 0, failures: [] };
|
||||
if (!gp.on()) { save(st); return st; }
|
||||
if (running) { st.skipped = -1; return st; } running = true;
|
||||
try {
|
||||
const list = await gp.tournamentPending();
|
||||
if (!list.ok) { st.error = list.error || 'pending unreachable'; save(st); return st; }
|
||||
st.pending = list.rows.length;
|
||||
for (const row of list.rows) {
|
||||
const k = keyOf(row), c = claims()[k], pol = r4(row.pol);
|
||||
if (!row.wallet || !/^0x[a-f0-9]{40}$/i.test(row.wallet) || !(pol > 0)) { st.failures.push({ k, error: 'no wallet or no amount' }); continue; }
|
||||
if (c && c.tx) { // paid before (this copy or the other one, or before a restart): IAP still lists it, so report the hash again
|
||||
const ack = await gp.tournamentPaid(row, c.tx); if (ack.ok) { mark(k, { acked: now }); st.acked++; } else st.failures.push({ k, error: 'paid report failed: ' + (ack.error || ack.status) }); continue;
|
||||
}
|
||||
if (c && c.dry && deps.dry()) { st.skipped++; st.wouldPay = r4(st.wouldPay + pol); continue; } // recorded in a dry run already (and still dry); once live, the row is paid
|
||||
if (c && !c.tx && now - (c.claimedAt || 0) < CLAIM_TTL) { st.skipped++; continue; } // the other app copy is on it right now
|
||||
if (!claim(k, row, now)) { st.skipped++; continue; } // claimed BEFORE anything is sent
|
||||
if (deps.dry()) { mark(k, { dry: true, wouldPay: pol, at: now }); st.wouldPay = r4(st.wouldPay + pol); continue; }
|
||||
let bal = null; try { bal = await deps.faucet.balance(); } catch (e) {}
|
||||
if (bal != null && bal < pol + 0.005) { release(k, { error: 'low balance' }); await lowOnce(bal, pol); st.failures.push({ k, error: 'low balance ' + bal }); break; }
|
||||
try {
|
||||
const res = await deps.faucet.send(row.wallet, pol, hash => mark(k, { tx: hash, sentAt: Date.now() }));
|
||||
if (!res || !res.tx) throw new Error('no transaction hash');
|
||||
mark(k, { tx: res.tx, sentAt: Date.now(), ok: res.ok !== false, pending: !!res.pending }); st.paid++;
|
||||
const ack = await gp.tournamentPaid(row, res.tx); if (ack.ok) { mark(k, { acked: Date.now() }); st.acked++; } else st.failures.push({ k, error: 'paid report failed: ' + (ack.error || ack.status) }); // retried next run from the claim's tx
|
||||
if (deps.notify) { try { await deps.notify('tourneypaid', Object.assign({}, row, { pol, tx: res.tx })); } catch (e) {} }
|
||||
} catch (e) {
|
||||
const error = String(e && e.message || e).slice(0, 200);
|
||||
if (claims()[k] && claims()[k].tx) { st.failures.push({ k, error: 'sent, receipt unknown: ' + error }); continue; } // the chain has it: never re-send; the next run reports the hash
|
||||
release(k, { error }); st.failures.push({ k, error });
|
||||
if (deps.notify) { try { await deps.notify('tourneyfail', Object.assign({}, row, { pol, error })); } catch (e2) {} }
|
||||
}
|
||||
}
|
||||
} finally { running = false; }
|
||||
save(st); return st;
|
||||
}
|
||||
async function lowOnce(bal, need) { const day = ctDay(); let first = false; store.update('tourney-state', {}, x => { if (x.lowAlertDay !== day) { x.lowAlertDay = day; first = true; } return x; }); if (first && deps.notify) { try { await deps.notify('low', { balance: bal, threshold: need, address: deps.faucet.address ? deps.faucet.address() : null, tournament: true }); } catch (e) {} } }
|
||||
function save(st) { store.update('tourney-state', {}, x => { Object.assign(x, { last: st }); x.history = [].concat(x.history || [], [{ at: st.lastRun, paid: st.paid, acked: st.acked, pending: st.pending, failures: st.failures.length, dry: st.dry, error: st.error || null }]).slice(-KEEP); if (st.paid) x.paidTotal = (x.paidTotal || 0) + st.paid; return x; }); }
|
||||
// for the admin: last run, totals, the open claims
|
||||
function state() { const x = store.read('tourney-state', {}), cl = claims(); return { on: gp.on(), dry: deps.dry(), last: x.last || null, paidTotal: x.paidTotal || 0, recent: (x.history || []).slice(-10).reverse(), claims: Object.keys(cl).map(k => Object.assign({ key: k }, cl[k])).sort((a, b) => (b.sentAt || b.claimedAt || 0) - (a.sentAt || a.claimedAt || 0)).slice(0, 30) }; }
|
||||
let timer = null;
|
||||
function start() { if (timer) return timer; timer = setInterval(() => run().catch(e => console.error('tournament', e && e.message)), EVERY_MS); if (timer.unref) timer.unref(); setTimeout(() => run().catch(() => {}), 20000).unref(); return timer; }
|
||||
|
||||
module.exports = { init, run, state, start, keyOf, EVERY_MS, CLAIM_TTL };
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"dev": "node --watch server.js",
|
||||
"test": "node test/run.js"
|
||||
"test": "node test/gamepass.js && node test/run.js && node test/rotation.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
|
||||
+14
-1
@@ -31,6 +31,11 @@
|
||||
<div style="margin-top:12px"><button class="btn sm" id="saveMission">Save mission</button> <span id="missionMsg" style="font-size:13px;color:var(--muted)"></span></div></div>
|
||||
<table id="missions" style="margin-top:14px"></table>
|
||||
</section>
|
||||
<section class="section"><h2>Network Tour</h2>
|
||||
<div class="sub" id="tourLine"></div>
|
||||
<div class="card"><div class="two"><div><label>Rotation (1 = on, 0 = off)</label><input id="rotationOn"></div><div><label>Tour stop ad credits (free tier repeat)</label><input id="tourStopCredits"></div><div><label>Tour stop credits, daily max per member</label><input id="tourStopCreditsDailyMax"></div></div><div style="margin-top:12px"><button class="btn sm" id="saveTour">Save tour settings</button></div></div>
|
||||
<table id="tourRows" style="margin-top:10px"></table>
|
||||
</section>
|
||||
<section class="section"><h2>Ad Detective</h2>
|
||||
<div class="sub" id="detLine"></div>
|
||||
<table id="detQs" style="margin-top:10px"></table>
|
||||
@@ -63,7 +68,15 @@
|
||||
$('detQs').innerHTML = '<tr><th>site</th><th>question</th><th>right answer</th><th>asked</th><th>right</th><th></th></tr>' + d.questions.map(q => '<tr style="' + (q.active === false ? 'opacity:.45' : '') + '"><td class="num">' + esc(q.missionId) + '</td><td>' + esc(q.q) + '</td><td>' + esc(q.options[0]) + '</td><td class="num">' + q.asked + '</td><td class="num">' + (q.asked ? Math.round(100 * q.correct / q.asked) + '%' : '—') + '</td><td><button class="btn ghost sm" data-qa="' + esc(q.id) + '" data-on="' + (q.active === false ? '1' : '0') + '">' + (q.active === false ? 'restore' : 'retire') + '</button></td></tr>').join('');
|
||||
document.querySelectorAll('[data-qa]').forEach(b => b.addEventListener('click', async () => { await api('/api/admin/detective/question', { method: 'POST', body: JSON.stringify({ id: b.dataset.qa, active: b.dataset.on === '1' }) }); loadDetective(); }));
|
||||
}
|
||||
$('go').addEventListener('click', () => { KEY = $('key').value.trim(); load(); loadDetective(); });
|
||||
// the Network Tour (2026-11-17): rounds per hunter, where each one stands this round, tour-stop credits sent and owed
|
||||
async function loadTour() {
|
||||
const t = await api('/api/admin/rotation'); if (!t || !t.hunters) return;
|
||||
for (const k of ['rotationOn', 'tourStopCredits', 'tourStopCreditsDailyMax']) $(k).value = k === 'rotationOn' ? (t.settings.on ? 1 : 0) : (k === 'tourStopCredits' ? t.settings.credits : t.settings.dailyMax);
|
||||
const ts = t.tourStops; $('tourLine').textContent = 'Rotation ' + (t.settings.on ? 'ON' : 'OFF') + ' · ' + t.hunters.length + ' hunters · ' + t.hunters.filter(h => h.rounds > 0).length + ' finished a round · tour stops ' + ts.total + ' (' + ts.creditsSent + ' credits sent, ' + ts.creditsOwed + ' owed)';
|
||||
$('tourRows').innerHTML = '<tr><th>hunter</th><th>rounds done</th><th>this round</th><th>toured all</th><th>left this round</th><th>last find</th></tr>' + t.hunters.map(h => '<tr><td>' + esc(h.who) + '</td><td class="num">' + h.rounds + '</td><td class="num">' + h.done + ' / ' + h.total + '</td><td>' + (h.toured ? 'yes' : '') + '</td><td style="font-size:12px">' + esc(h.left.join(', ')) + '</td><td>' + (h.lastFind ? new Date(h.lastFind).toLocaleString('en-US', { timeZone: 'America/Chicago' }) : '') + '</td></tr>').join('');
|
||||
}
|
||||
$('saveTour').addEventListener('click', async () => { const b = {}; for (const k of ['rotationOn', 'tourStopCredits', 'tourStopCreditsDailyMax']) b[k] = Number($(k).value); const r = await api('/api/admin/settings', { method: 'POST', body: JSON.stringify(b) }); if (r.error) alert(r.error); loadTour(); });
|
||||
$('go').addEventListener('click', () => { KEY = $('key').value.trim(); load(); loadDetective(); loadTour(); });
|
||||
$('key').addEventListener('keydown', e => { if (e.key === 'Enter') $('go').click(); });
|
||||
$('saveSettings').addEventListener('click', async () => { const b = {}; for (const k of ['minPol', 'maxPol', 'dailyCapPol', 'lowBalancePol']) b[k] = Number($(k).value); const r = await api('/api/admin/settings', { method: 'POST', body: JSON.stringify(b) }); if (r.error) alert(r.error); load(); });
|
||||
$('tickFaucet').addEventListener('click', async () => { $('faucetLine').textContent = 'running…'; const r = await api('/api/admin/faucet/tick', { method: 'POST' }); $('faucetLine').textContent = r.error ? r.error : 'paid ' + r.paid + ' · balance ' + (r.balance == null ? '—' : Number(r.balance).toFixed(4) + ' POL'); load(); });
|
||||
|
||||
+5
-4
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Your board · PolHunter</title>
|
||||
<meta name="robots" content="noindex">
|
||||
<link rel="stylesheet" href="/style.css?v=19">
|
||||
<link rel="stylesheet" href="/style.css?v=20">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
@@ -37,7 +37,7 @@
|
||||
<div class="badge-strip" id="badgeStrip"></div>
|
||||
</section>
|
||||
|
||||
<div class="adslot" data-ad="board"><!-- nas: 468x60 on phones, 728x90 on wider screens --><script>(function(){var m=window.innerWidth<600;document.write('<scr'+'ipt src="https://www.networkadspace.com/showadss.php?'+(m?'w=468&h=60&n=1&bw=468&bh=60':'w=728&h=90&n=1&bw=728&bh=90')+'&c=999"></scr'+'ipt>');})();</script></div>
|
||||
<div class="adslot" data-nas data-ad="board"><!-- nas: 468x60 on phones, 728x90 on wider screens; framed by /nas.js so a dead ad server never blocks the page --></div>
|
||||
|
||||
<section class="section">
|
||||
<h2>Your drips</h2>
|
||||
@@ -53,11 +53,12 @@
|
||||
<p class="small" style="margin-top:10px">Banners, swipes and the teaser video are on the <a href="/promo">promo tools</a> page, already carrying your link.</p>
|
||||
</section>
|
||||
|
||||
<footer class="foot">Rewards are for completed missions, not income. The daily pool is limited; when it is spent, claims close until midnight Central. Cryptocurrency involves risk of loss.</footer>
|
||||
<footer class="foot">Rewards are for completed missions, not income. The daily pool is limited; when it is spent, claims close until midnight Central. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a></footer>
|
||||
</div>
|
||||
<div class="modal" id="shareModal" hidden><div class="modal-card"><button class="modal-x" id="shareClose" type="button" aria-label="Close">×</button><div id="shareBody"></div></div></div>
|
||||
<script src="https://instantadpay.com/assets/game-strip.js?v=20261003a"></script>
|
||||
<script>if (window.IAPGames) IAPGames.strip(document.getElementById('moreGames'), { current: 'polhunter', title: ' ' }).then(function (n) { var m = document.getElementById('moreGames'), h = m.querySelector('.gs-h'); if (h) h.remove(); document.getElementById('moreGamesSec').hidden = !n; });</script>
|
||||
<script src="/app.js?v=21"></script>
|
||||
<script src="/app.js?v=23"></script>
|
||||
<script src="/nas.js?v=20261024" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+27
-9
@@ -35,9 +35,9 @@
|
||||
const isOpen = open && open.missionId === m.id;
|
||||
const r = m.reward || {};
|
||||
return '<div class="card' + (isOpen ? ' mission-open' : '') + '" data-id="' + esc(m.id) + '">'
|
||||
+ '<span class="tag' + (m.done ? ' done' : '') + '">' + (m.done ? 'Done today' : esc(m.site)) + '</span>'
|
||||
+ '<span class="tag' + (m.done ? ' done' : '') + '">' + (m.done ? 'Done today' : esc(m.site)) + '</span>' + (!m.done && m.fresh ? ' <span class="tag gold">New to you</span>' : '')
|
||||
+ '<h3>' + esc(m.name) + '</h3><p>' + esc(m.brief) + '</p>'
|
||||
+ '<p style="margin-top:10px"><span class="range">' + r.minPol + ' to ' + r.maxPol + ' POL</span> <span style="color:var(--dim);font-size:12px">· ' + m.dwell + 's on the site</span></p>'
|
||||
+ '<p style="margin-top:10px"><span class="range">' + (m.tourStop ? 'Tour stop: +' + m.tourStop.credits + ' ad credits' : r.minPol + ' to ' + r.maxPol + ' POL') + '</span> <span style="color:var(--dim);font-size:12px">· ' + m.dwell + 's on the site</span></p>'
|
||||
+ (m.done ? '' : (board.pool && board.pool.spent && !isOpen) ? '<div class="cardact"><span class="tag gold">Closed until midnight Central</span></div>' : (board.daily && !board.daily.left && !isOpen) ? '<div class="cardact"><span class="tag">Back tomorrow</span></div>' : isOpen
|
||||
? '<div class="timer" id="timer">Your code appears on the site after <b>' + m.dwell + 's</b>. Keep that tab open.</div>'
|
||||
+ '<div class="codebox"><input id="code" maxlength="6" placeholder="6 CHARACTERS" autocomplete="off" spellcheck="false" inputmode="text" autocapitalize="characters"><button class="btn pol" id="submit">Claim</button></div><div class="site" style="font-size:12px;margin-top:6px">Six characters. On the site, tap the code to copy it, then paste it here.</div>'
|
||||
@@ -97,7 +97,7 @@
|
||||
// badge cards: art, lock state, share
|
||||
function badgeStrip() {
|
||||
const el = $('badgeStrip'); if (!el || !board.badgeCards) return;
|
||||
el.innerHTML = board.badgeCards.map(b => '<div class="badge-a' + (b.earned ? '' : ' locked') + '"><img src="' + b.art + '" alt="' + esc(b.name) + '" loading="lazy"><div class="bl">' + b.icon + ' ' + esc(b.name) + '</div><div class="bs">' + esc(b.why) + '</div>' + (b.earned ? '<button class="btn pol sm" data-share="' + b.id + '">Share</button>' : '<div class="bs">\u{1F512} locked</div>') + '</div>').join('');
|
||||
el.innerHTML = board.badgeCards.map(b => '<div class="badge-a' + (b.earned ? '' : ' locked') + '"><img src="' + b.art + '" alt="' + esc(b.name) + '" loading="lazy"><div class="bl">' + b.icon + ' ' + esc(b.name) + (b.count ? ' \u00d7' + b.count : '') + '</div><div class="bs">' + esc(b.why) + '</div>' + (b.earned ? '<button class="btn pol sm" data-share="' + b.id + '">Share</button>' : '<div class="bs">\u{1F512} locked</div>') + '</div>').join('');
|
||||
el.querySelectorAll('[data-share]').forEach(x => x.addEventListener('click', () => shareBadge(x.dataset.share, false)));
|
||||
}
|
||||
function shareBadge(id, unlocked) {
|
||||
@@ -112,14 +112,27 @@
|
||||
$('shareCopy').onclick = async () => { try { await navigator.clipboard.writeText(b.page); } catch (e) {} $('shareCopy').textContent = 'Copied'; setTimeout(() => { $('shareCopy').textContent = 'Copy link'; }, 1200); };
|
||||
}
|
||||
document.addEventListener('click', e => { if (e.target.id === 'shareClose' || e.target.id === 'shareModal') $('shareModal').hidden = true; });
|
||||
// the Network Tour (2026-11-17): how far through this round, which sites are left; a free member who has toured
|
||||
// everything is told what a repeat pays now (ad credits) and how POL comes back (new sites, or the Game Pass)
|
||||
function tourPanel() {
|
||||
const t = board.tour; if (!t || !t.on || !t.total) return '';
|
||||
const pct = Math.round(100 * t.done / t.total);
|
||||
const free = t.free && t.toured ? '<p class="tour-free">You\u2019ve toured the whole network. New sites pay POL when they launch. Want POL on every hunt? ' + (board.gamepass && board.gamepass.url ? '<a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>.' : 'Get the Game Pass.') + ' Until then each hunt is a tour stop worth +' + t.tourStopCredits + ' InstantAdPay ad credits.</p>' : '';
|
||||
return '<div class="tour" style="grid-column:1/-1"><div class="tour-hd"><b>\u{1F5FA}\uFE0F Network tour:</b> ' + t.done + ' of ' + t.total + ' sites this round' + (t.rounds ? ' <span class="tour-r">\u00b7 ' + t.rounds + ' round' + (t.rounds === 1 ? '' : 's') + ' done</span>' : '') + '</div>'
|
||||
+ '<div class="tour-bar" role="progressbar" aria-valuemin="0" aria-valuemax="' + t.total + '" aria-valuenow="' + t.done + '"><i style="width:' + pct + '%"></i></div>'
|
||||
+ (t.left.length ? '<div class="tour-left">Left this round: ' + t.left.map(esc).join(' \u00b7 ') + '</div>' : '')
|
||||
+ free + '</div>';
|
||||
}
|
||||
function render() {
|
||||
badgeStrip();
|
||||
$('who').innerHTML = '<i></i> ' + esc(board.me.username ? '@' + board.me.username : '#' + board.me.memberId) + (board.me.wallet ? '' : ' · no wallet linked');
|
||||
$('who').innerHTML = '<i></i> ' + esc(board.me.username ? '@' + board.me.username : '#' + board.me.memberId) + (board.me.wallet ? '' : ' · no wallet linked')
|
||||
// Game Pass (InstantAdPay, all nine games): active until <date>, or the link to get it; opens a new tab (the game may be framed)
|
||||
+ (board.gamepass && board.gamepass.on ? ' · ' + (board.gamepass.active ? '\u{1F3AB} Game Pass active' + (board.gamepass.untilText ? ' until ' + esc(board.gamepass.untilText) : '') + ' (5 missions a day, 2 Ad Detective cases)' : '\u{1F3AB} <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>: higher daily POL caps, 5 missions a day, 2 cases') : '');
|
||||
const r = board.missions[0] && board.missions[0].reward;
|
||||
if (r) $('rangeLine').textContent = 'Each find pays a random drip between ' + r.minPol + ' and ' + r.maxPol + ' POL. Your codes are yours alone.';
|
||||
if (r) $('rangeLine').textContent = (board.tour && board.tour.free && board.tour.toured) ? 'A site new to you pays a random drip of POL; a repeat is a tour stop worth ' + board.tour.tourStopCredits + ' ad credits. Your codes are yours alone.' : 'Each find pays a random drip between ' + r.minPol + ' and ' + r.maxPol + ' POL. Your codes are yours alone.';
|
||||
const pool = board.pool || {};
|
||||
if (!board.me.wallet) $('missions').innerHTML = onboarding();
|
||||
else $('missions').innerHTML = (pool.spent ? '<div class="notice" style="grid-column:1/-1"><b>Today\u2019s POL pool is spent.</b> No more claims today. Claims reopen at midnight Central' + (pool.resetsAt ? ', in ' + until(pool.resetsAt) : '') + '.</div>' : '')
|
||||
else $('missions').innerHTML = tourPanel() + (pool.spent ? '<div class="notice" style="grid-column:1/-1"><b>Today\u2019s POL pool is spent.</b> No more claims today. Claims reopen at midnight Central' + (pool.resetsAt ? ', in ' + until(pool.resetsAt) : '') + '.</div>' : '')
|
||||
+ (board.missions.length ? board.missions.map(card).join('') : '<div class="card"><p>No missions are open right now. Check back soon.</p></div>');
|
||||
if ($('refSlot')) $('refSlot').innerHTML = board.me.wallet ? referralCard() : '';
|
||||
wireRefVideo();
|
||||
@@ -154,7 +167,7 @@
|
||||
fridayCard(board.fridayBank);
|
||||
boxCard(board.box);
|
||||
const dl = board.daily; if (dl && $('rangeLine')) $('rangeLine').innerHTML = ($('rangeLine').textContent.replace(/\s*·\s*You have.*$/, '')) + ' \u00b7 ' + (dl.left ? 'You have <b>' + dl.left + ' of ' + dl.limit + '</b> missions left today.' : '<b>That is your ' + dl.limit + ' for today.</b> Fresh missions at midnight Central.');
|
||||
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + (String(d.missionId || '').startsWith('detective:') ? '\u{1F50E} ' : '') + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at' }[d.status] || d.status) + '</span><span class="pol">+' + d.pol + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
|
||||
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + (String(d.missionId || '').startsWith('detective:') ? '\u{1F50E} ' : '') + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at', tour: 'tour stop' + (d.tourStop && d.tourStop.credits ? ': +' + d.tourStop.credits + ' ad credits' + (d.tourStop.state === 'sent' ? '' : ' (sending)') : '') }[d.status] || d.status) + '</span><span class="pol">' + (d.status === 'tour' ? '0' : '+' + d.pol) + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
|
||||
: '<div class="row"><span class="site">Nothing yet. Your first find goes here.</span></div>';
|
||||
document.querySelectorAll('[data-start]').forEach(b => b.addEventListener('click', () => start(b.dataset.start)));
|
||||
const s = $('submit'); if (s) { s.addEventListener('click', submit); $('code').addEventListener('keydown', e => { if (e.key === 'Enter') submit(); }); tick(); }
|
||||
@@ -218,7 +231,8 @@
|
||||
const head = t => '<div class="box-hd">\u{1F381} Mystery Hunt Box</div><h3>' + t + '</h3>';
|
||||
const rule = '<p class="box-rule">One answer only. Look carefully before answering.</p>';
|
||||
let h = '';
|
||||
if (bx.status === 'locked') h = head('Unlocks when today’s hunts are done') + '<p>Find all ' + bx.need + ' of today’s codes and your box opens: a bonus case worth a fixed <b>' + pol + '</b>. <span class="box-dim">' + bx.done + ' of ' + bx.need + ' found.</span></p>';
|
||||
if (bx.status === 'pass') h = head('A Game Pass perk') + '<p>Game Pass holders hunt five codes a day at the full reward, and their box opens after the last one with a bonus case worth a fixed <b>' + pol + '</b>. <a href="https://instantadpay.com/my#passes" target="_blank" rel="noopener">Get the Game Pass on InstantAdPay</a>.</p>';
|
||||
else if (bx.status === 'locked') h = head('Unlocks when today’s hunts are done') + '<p>Find all ' + bx.need + ' of today’s codes and your box opens: a bonus case worth a fixed <b>' + pol + '</b>. <span class="box-dim">' + bx.done + ' of ' + bx.need + ' found.</span></p>';
|
||||
else if (bx.status === 'ready') h = head('Your box is ready') + '<p>Open it to see today’s bonus case. It pays a fixed <b>' + pol + '</b> and does not use up a mission.</p><button class="btn pol" id="boxOpen">Open the box</button>';
|
||||
else if (bx.status === 'open') h = head('\u{1F50E} Ad Detective on ' + esc(bx.site)) + '<p>Reward: <b>' + pol + '</b>, fixed. Visit the site and look around for at least ' + bx.dwell + ' seconds. Then come back here and answer <b>one question</b> about what the site says.</p>' + rule + '<button class="btn pol" id="boxStart">Begin the case</button>';
|
||||
else if (bx.status === 'started') { h = head('\u{1F50E} On the case: ' + esc(bx.site)) + '<p>Stay on the site tab for at least ' + bx.dwell + ' seconds and read what it says. A note on the page tells you when your visit is recorded. Your question appears here right after.</p><p><a href="' + esc(bx.url || '#') + '" target="_blank" rel="noopener">Open the site again ↗</a> <span class="box-dim">· if the note never showed, press Begin again after this attempt times out.</span></p>' + (bx.expires && Date.now() > bx.expires ? '<button class="btn" id="boxStart">Begin again</button>' : ''); boxPoll = setTimeout(boxRefresh, 6000); }
|
||||
@@ -263,7 +277,11 @@
|
||||
$('submit').disabled = true;
|
||||
const r = await api('/api/my/submit', { token: open.token, code });
|
||||
const m = $('msg'); m.className = 'msg ' + (r.error ? 'bad' : 'ok'); m.textContent = r.error || r.message;
|
||||
if (r.error) toast(esc(r.error), 'bad'); else toast('\u{1F389} <b>Found it!</b> ' + r.pol + ' POL is on its way to your wallet.', 'big');
|
||||
if (!r.error && r.gamepass) board.gamepass = r.gamepass; // the Game Pass flag refreshes with every grant answer
|
||||
if (!r.error && /Get the Pass/.test(r.message || '') && board.gamepass && board.gamepass.on && !board.gamepass.active) m.innerHTML = esc(r.message) + ' <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>'; // the cap-hit nudge, in a new tab (the page may be framed)
|
||||
if (r.error) toast(esc(r.error), 'bad'); else if (r.tourStop) toast('\u{1F5FA}\uFE0F <b>Tour stop!</b> ' + (r.tourStop.credits ? '+' + r.tourStop.credits + ' ad credits to your InstantAdPay account.' : 'Logged for your network tour.'), 'big'); else toast('\u{1F389} <b>Found it!</b> ' + r.pol + ' POL is on its way to your wallet.', 'big');
|
||||
if (!r.error && r.tourStop && board.gamepass && board.gamepass.on && !board.gamepass.active) m.innerHTML = esc(r.message) + ' <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>';
|
||||
if (!r.error && r.round) toast('\u{1F5FA}\uFE0F <b>Full Network Tour!</b> Round ' + r.round + ' done. A new round starts now.', 'big');
|
||||
if (!r.error) { const a = document.createElement('a'); a.href = '#share'; a.textContent = ' Share this find \u2197'; a.style.marginLeft = '6px'; m.appendChild(a); delete $('sharetext').dataset.touched; }
|
||||
// an achievement unlocked by this find: celebrate it once the board has reloaded
|
||||
if (!r.error && r.unlocked && r.unlocked.length) { const id = r.unlocked[0]; toast('\u{1F3C6} <b>Achievement unlocked!</b>', 'big'); setTimeout(async () => { await load(); shareBadge(id, true); }, 1200); }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Rewards Disclaimer · PolHunter</title>
|
||||
<meta name="description" content="Rewards for finds, not income. Nothing is promised.">
|
||||
<link rel="canonical" href="https://polhunter.com/disclaimer">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn ghost sm" href="/#how">How it works</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small">Last updated November 17, 2026</div>
|
||||
<h2>PolHunter Rewards Disclaimer</h2>
|
||||
<div class="sub">Rewards for finds, not income. Nothing is promised.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">What a reward is</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A PolHunter drip is a small reward for a completed mission, paid in POL from a limited daily pool. It is not income, a wage, an investment or a promise of any payment.</p><h3 style="margin:22px 0 6px;font-size:19px">Nothing is guaranteed</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Drips are random within the posted range. The daily pool is limited, and when it is spent claims close until midnight Central. Missions, ranges and prizes can change at any time.</p><h3 style="margin:22px 0 6px;font-size:19px">No examples are promises</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Any number on this site, in the ledger, on the leaderboard or in a Telegram post shows what really happened. It is not a typical result and not a forecast of what you will receive.</p><h3 style="margin:22px 0 6px;font-size:19px">Prices and taxes</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">POL's price moves, so the dollar value of a drip can change. You are responsible for any taxes on what you receive where you live.</p><h3 style="margin:22px 0 6px;font-size:19px">Who to ask</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">TrustClickz. <a href="https://instantadpay.com/support" rel="noopener">Network support</a>.</p>
|
||||
</section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>PolHunter FAQ · PolHunter</title>
|
||||
<meta name="description" content="Short answers on cost, wallets, codes a day, what a find pays, the Central-time reset, the daily pool and the Game Pass.">
|
||||
<link rel="canonical" href="https://polhunter.com/guides/faq">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:site_name" content="PolHunter">
|
||||
<meta property="og:title" content="PolHunter FAQ · PolHunter">
|
||||
<meta property="og:description" content="Short answers on cost, wallets, codes a day, what a find pays, the Central-time reset, the daily pool and the Game Pass.">
|
||||
<meta property="og:url" content="https://polhunter.com/guides/faq">
|
||||
<meta property="og:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small"><a href="/guides">Guides</a> · PolHunter FAQ</div>
|
||||
<h2>PolHunter FAQ</h2>
|
||||
<div class="sub">Short answers on cost, wallets, codes a day, what a find pays, the Central-time reset, the daily pool and the Game Pass.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">Does PolHunter cost anything?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">No. You hunt with a free InstantAdPay account. The Game Pass is optional and sold on InstantAdPay.</p><h3 style="margin:22px 0 6px;font-size:19px">Do I need a new account?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">No. You sign in with your InstantAdPay account. No separate account or password is created here.</p><h3 style="margin:22px 0 6px;font-size:19px">Which wallet do I need?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">SafePal or any other crypto wallet that works on Polygon. Link it in your InstantAdPay dashboard under Wallet; drips go to that address.</p><h3 style="margin:22px 0 6px;font-size:19px">How many codes can I find a day?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A free account finds 1 code a day. Game Pass holders find 5. Advertiser missions and Friday Bonus Hunts can add more.</p><h3 style="margin:22px 0 6px;font-size:19px">How much does a find pay?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A free find pays a random 0.02 to 0.10 POL the first time you find each site; after you have found them all, a repeat find is a tour stop worth 10 InstantAdPay ad credits instead, and a new site pays POL again on your first find. With the Game Pass a find pays a random 0.05 to 1 POL. Both lean toward the low end. Advertiser missions pay the amount the advertiser set.</p><h3 style="margin:22px 0 6px;font-size:19px">What is the network tour?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Your board offers only the sites you have not found yet this round, the ones new to you first. Find every site and a new round starts, and each finished round counts toward the Full Network Tour badge.</p><h3 style="margin:22px 0 6px;font-size:19px">When does the day reset?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">At midnight Central time. The missions, your codes and the daily pool all reset then.</p><h3 style="margin:22px 0 6px;font-size:19px">Why does my board say claims are closed?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The daily pool is spent. Claims reopen at midnight Central, and a find that went over the pool can be paid on a later day.</p><h3 style="margin:22px 0 6px;font-size:19px">How fast am I paid?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The reward wallet sends due drips every couple of minutes. Each one shows up with a Polygonscan link you can open.</p><h3 style="margin:22px 0 6px;font-size:19px">Can I use a code a friend found?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">No. Every code is made for one hunter and one visit. Someone else’s code will not work for you.</p><h3 style="margin:22px 0 6px;font-size:19px">Can I run two accounts?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">No. One person, one account. Two accounts that share a wallet get one drip per mission per day between them.</p><h3 style="margin:22px 0 6px;font-size:19px">What are Friday Bonus Hunts?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Each day from Saturday through Thursday that you open an inbox ad and watch a video on InstantAdPay banks one extra hunt, usable on the Friday that follows.</p><h3 style="margin:22px 0 6px;font-size:19px">What is the Mystery Hunt Box?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A Game Pass perk. Finish the day’s hunts and a box opens an Ad Detective case: visit a network site and answer one question about it. The reward is fixed and shown before you start.</p><h3 style="margin:22px 0 6px;font-size:19px">How do the weekly prizes work?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The leaderboard ranks hunters by finds from Monday to Sunday, Central time. Ties go to the most POL, then to whoever got there first. The weekly prizes go to Game Pass holders and are paid on chain.</p><h3 style="margin:22px 0 6px;font-size:19px">Do I earn for bringing people?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">New members you bring can earn you referral rewards, paid from their own pool. Only people who were never members before count.</p><h3 style="margin:22px 0 6px;font-size:19px">Is this income?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">No. PolHunter rewards completed missions. Rewards are not income and are not guaranteed, and the price of POL moves.</p><h3 style="margin:22px 0 6px;font-size:19px">Where do I get help?</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Use <a href="https://instantadpay.com/support" rel="noopener">network support</a>.</p>
|
||||
</section>
|
||||
<section class="section"><h2>More guides</h2><div class="steps"><div class="step"><b><a href="/guides/how-a-hunt-works">How a hunt works</a></b><br>Missions, codes, the daily reset, and what each find pays.</div><div class="step"><b><a href="/guides/is-polhunter-legit">Is PolHunter legit?</a></b><br>The reward wallet, every payout with a transaction, and the public ledger.</div><div class="step"><b><a href="/guides/free-account">Getting the most from your free account</a></b><br>Set up once, hunt every day, and the extras that cost nothing.</div></div></section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Getting the most from your free account · PolHunter</title>
|
||||
<meta name="description" content="Set up your InstantAdPay account and wallet first, then the free extras: daily hunts, Friday Bonus Hunts, advertiser missions and sharing.">
|
||||
<link rel="canonical" href="https://polhunter.com/guides/free-account">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:site_name" content="PolHunter">
|
||||
<meta property="og:title" content="Getting the most from your free account · PolHunter">
|
||||
<meta property="og:description" content="Set up your InstantAdPay account and wallet first, then the free extras: daily hunts, Friday Bonus Hunts, advertiser missions and sharing.">
|
||||
<meta property="og:url" content="https://polhunter.com/guides/free-account">
|
||||
<meta property="og:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small"><a href="/guides">Guides</a> · Getting the most from your free account</div>
|
||||
<h2>Getting the most from your free account</h2>
|
||||
<div class="sub">Set up your InstantAdPay account and wallet first, then the free extras: daily hunts, Friday Bonus Hunts, advertiser missions and sharing.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">Set it up once</h3><div class="steps"><div class="step"><b>Create your free InstantAdPay account</b> at <a href="https://instantadpay.com/?from=polhunter" target="_blank" rel="noopener">instantadpay.com</a>. Email first, no wallet needed to sign up.</div><div class="step"><b>Link your wallet.</b> In your InstantAdPay dashboard open <a href="https://instantadpay.com/my#wallet" target="_blank" rel="noopener">Wallet</a> and connect SafePal or any other crypto wallet. Every drip lands at that address, on Polygon.</div><div class="step"><b>Open your board</b> with <a href="https://instantadpay.com/api/my/polhunter">Open my board</a>. No new password: InstantAdPay signs you straight in.</div></div><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Without a linked wallet you can see your board, but you cannot start a mission. That is the most common thing that stops a new hunter, so do it first.</p><h3 style="margin:22px 0 6px;font-size:19px">Hunt every day</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A free account gets one code a day, and missions reset at midnight Central. Each site pays POL the first time you find it; once you have toured them all, a repeat find is a tour stop worth 10 InstantAdPay ad credits, and new sites pay POL again. One find a day, every day, is the habit that counts. Your finds also earn badges and put you on the <a href="/leaders">leaderboard</a>.</p><h3 style="margin:22px 0 6px;font-size:19px">Bank Friday Bonus Hunts</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">From Saturday through Thursday, each day you open an inbox ad and watch a video on InstantAdPay banks one extra hunt for Friday. You can also earn ad credits while you are there. Ad credits buy advertising, not income.</p><h3 style="margin:22px 0 6px;font-size:19px">Look for advertiser missions</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">When an advertiser mission is live and you have not done it today, it adds one extra hunt to your day and pays the amount the advertiser set.</p><h3 style="margin:22px 0 6px;font-size:19px">Share PolHunter</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Your board has your own share link. People who join InstantAdPay from it are your referrals there, and new members you bring can also earn you referral rewards here, paid from their own pool. Only people who were never members before count.</p><h3 style="margin:22px 0 6px;font-size:19px">When you want more</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The Game Pass on InstantAdPay is optional. With it you hunt 5 codes a day on the full draw, and you get the Mystery Hunt Box, the Ad Detective cases and the weekly prizes. Hunting free is fine too.</p>
|
||||
</section>
|
||||
<section class="section"><h2>More guides</h2><div class="steps"><div class="step"><b><a href="/guides/how-a-hunt-works">How a hunt works</a></b><br>Missions, codes, the daily reset, and what each find pays.</div><div class="step"><b><a href="/guides/is-polhunter-legit">Is PolHunter legit?</a></b><br>The reward wallet, every payout with a transaction, and the public ledger.</div><div class="step"><b><a href="/guides/faq">PolHunter FAQ</a></b><br>Short answers to the questions hunters ask most.</div></div></section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>How a hunt works · PolHunter</title>
|
||||
<meta name="description" content="Missions, personal codes, once per mission per Central day, and what a find pays on a free account and with the Game Pass.">
|
||||
<link rel="canonical" href="https://polhunter.com/guides/how-a-hunt-works">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:site_name" content="PolHunter">
|
||||
<meta property="og:title" content="How a hunt works · PolHunter">
|
||||
<meta property="og:description" content="Missions, personal codes, once per mission per Central day, and what a find pays on a free account and with the Game Pass.">
|
||||
<meta property="og:url" content="https://polhunter.com/guides/how-a-hunt-works">
|
||||
<meta property="og:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small"><a href="/guides">Guides</a> · How a hunt works</div>
|
||||
<h2>How a hunt works</h2>
|
||||
<div class="sub">Missions, personal codes, once per mission per Central day, and what a find pays on a free account and with the Game Pass.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">The short version</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">PolHunter is a scavenger hunt across the network. A mission sends you to one of our sites. You spend the time on the page, your personal code shows up somewhere on it, and you type that code into your board. A correct code pays a random drip of POL on Polygon to the wallet on your InstantAdPay account.</p><h3 style="margin:22px 0 6px;font-size:19px">Step by step</h3><div class="steps"><div class="step"><b>Pick a mission</b> on your board. Each one names a site and what to find there.</div><div class="step"><b>Go find it.</b> Stay on the page for the time the mission asks. Your code only appears after that.</div><div class="step"><b>Type the code.</b> If it is yours, the drip is recorded right away and the reward wallet sends it to your wallet, with a Polygonscan link to prove it.</div></div><h3 style="margin:22px 0 6px;font-size:19px">Your code is yours alone</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Each code is made for you and for that one visit, and it only shows on the mission site after the wait. A code copied from someone else will not work for you, and the hiding place moves.</p><h3 style="margin:22px 0 6px;font-size:19px">How many codes a day</h3><table style="width:100%;max-width:640px;border-collapse:collapse;margin:6px 0 14px;font-size:15px"><tr style="text-align:left;border-bottom:1px solid var(--edge)"><th style="padding:8px 6px">Account</th><th style="padding:8px 6px">Codes a day</th><th style="padding:8px 6px">Each find pays</th></tr><tr style="border-bottom:1px solid var(--edge)"><td style="padding:8px 6px">Free InstantAdPay account</td><td style="padding:8px 6px">1</td><td style="padding:8px 6px">0.02 to 0.10 POL on a site new to you; a repeat is a tour stop worth 10 InstantAdPay ad credits</td></tr><tr><td style="padding:8px 6px">Game Pass holder</td><td style="padding:8px 6px">5</td><td style="padding:8px 6px">0.05 to 1 POL</td></tr></table><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The drip is random inside that range and weighted toward the low end, so small drips are common and big ones are rare. Advertiser missions, when there are any, pay the amount the advertiser set and add one extra hunt each.</p><h3 style="margin:22px 0 6px;font-size:19px">Once per mission per Central day</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Each mission can be found once per day, and the day runs on Central time. At midnight Central the codes, the missions and the daily pool all reset. Two accounts that share a wallet get one drip per mission per day between them.</p><h3 style="margin:22px 0 6px;font-size:19px">The network tour</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Your board walks you around the whole network. Each round, it only offers the sites you have not found yet this round, newest to you first; find them all and a new round starts, with the Full Network Tour badge for every round you finish.</p><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">On a free account, a find pays POL while you are discovering: the first time you find each site. Once you have found every site, a repeat find is a tour stop that pays 10 InstantAdPay ad credits instead of POL, and each new site that joins the network pays POL again on your first find. Game Pass holders are paid POL on every find.</p><h3 style="margin:22px 0 6px;font-size:19px">The daily pool</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Finds are paid from a daily pool. If it is spent before the day ends, your board says so and claims reopen at midnight Central. A find that would go over the pool can be queued and paid on a later day instead.</p><h3 style="margin:22px 0 6px;font-size:19px">The extras</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65"><b>Friday Bonus Hunts.</b> On InstantAdPay, each day from Saturday through Thursday that you open an inbox ad and watch a video there banks one extra hunt for the Friday that follows.</p><p style="margin:0 0 12px;max-width:70ch;line-height:1.65"><b>Mystery Hunt Box and Ad Detective.</b> Game Pass holders who finish the day’s hunts unlock a box with an Ad Detective case: visit a network site, then answer one question about it. The reward is fixed and shown before you start.</p><p style="margin:0 0 12px;max-width:70ch;line-height:1.65"><b>Weekly prizes.</b> The <a href="/leaders">leaderboard</a> ranks hunters by finds, Monday to Sunday Central time. The weekly prizes go to Game Pass holders and are paid on chain from the same reward wallet.</p><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Nothing here is promised. Rewards are not income, and the range, the number of hunts and the pools can change. See the <a href="/disclaimer">Rewards disclaimer</a>.</p>
|
||||
</section>
|
||||
<section class="section"><h2>More guides</h2><div class="steps"><div class="step"><b><a href="/guides/is-polhunter-legit">Is PolHunter legit?</a></b><br>The reward wallet, every payout with a transaction, and the public ledger.</div><div class="step"><b><a href="/guides/free-account">Getting the most from your free account</a></b><br>Set up once, hunt every day, and the extras that cost nothing.</div><div class="step"><b><a href="/guides/faq">PolHunter FAQ</a></b><br>Short answers to the questions hunters ask most.</div></div></section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>PolHunter guides · PolHunter</title>
|
||||
<meta name="description" content="Plain answers on how PolHunter works, how it pays, and how to get the most from a free account.">
|
||||
<link rel="canonical" href="https://polhunter.com/guides">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:site_name" content="PolHunter">
|
||||
<meta property="og:title" content="PolHunter guides · PolHunter">
|
||||
<meta property="og:description" content="Plain answers on how PolHunter works, how it pays, and how to get the most from a free account.">
|
||||
<meta property="og:url" content="https://polhunter.com/guides">
|
||||
<meta property="og:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small"><a href="/guides">Guides</a></div>
|
||||
<h2>PolHunter guides</h2>
|
||||
<div class="sub">Plain answers on how PolHunter works, how it pays, and how to get the most from a free account.</div>
|
||||
<div class="steps"><div class="step"><b><a href="/guides/how-a-hunt-works">How a hunt works</a></b><br>Missions, codes, the daily reset, and what each find pays.</div><div class="step"><b><a href="/guides/is-polhunter-legit">Is PolHunter legit?</a></b><br>The reward wallet, every payout with a transaction, and the public ledger.</div><div class="step"><b><a href="/guides/free-account">Getting the most from your free account</a></b><br>Set up once, hunt every day, and the extras that cost nothing.</div><div class="step"><b><a href="/guides/faq">PolHunter FAQ</a></b><br>Short answers to the questions hunters ask most.</div></div><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">New here? Start with <a href="/guides/how-a-hunt-works">How a hunt works</a>, then set up your account with the <a href="/#start">three steps before your first hunt</a>.</p>
|
||||
</section>
|
||||
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,51 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Is PolHunter legit? · PolHunter</title>
|
||||
<meta name="description" content="Check it yourself: one public reward wallet on Polygon, every payout with a transaction link, and a live public ledger.">
|
||||
<link rel="canonical" href="https://polhunter.com/guides/is-polhunter-legit">
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:site_name" content="PolHunter">
|
||||
<meta property="og:title" content="Is PolHunter legit? · PolHunter">
|
||||
<meta property="og:description" content="Check it yourself: one public reward wallet on Polygon, every payout with a transaction link, and a live public ledger.">
|
||||
<meta property="og:url" content="https://polhunter.com/guides/is-polhunter-legit">
|
||||
<meta property="og:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="https://polhunter.com/promo/polhunter-1200x630.jpg">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small"><a href="/guides">Guides</a> · Is PolHunter legit?</div>
|
||||
<h2>Is PolHunter legit?</h2>
|
||||
<div class="sub">Check it yourself: one public reward wallet on Polygon, every payout with a transaction link, and a live public ledger.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">Check it yourself</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">You do not have to take our word for anything. Every PolHunter drip is a Polygon transaction sent from one public reward wallet, and you can open each one.</p><h3 style="margin:22px 0 6px;font-size:19px">The reward wallet</h3><div class="notice" style="margin:6px 0 14px;word-break:break-all"><b>PolHunter reward wallet:</b> <span class="num">0x90ECD51A565bFA2da3e577BbbBCA4aBff1F7A753</span><br><a href="https://polygonscan.com/address/0x90ECD51A565bFA2da3e577BbbBCA4aBff1F7A753" target="_blank" rel="noopener">Open it on Polygonscan ↗</a></div><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Every find, prize and referral reward leaves from this address. On Polygonscan you can see each send, the amount, the wallet it went to and the time. PolHunter is not a contract: it is a wallet the company funds, and it pays out on its own every few minutes.</p><h3 style="margin:22px 0 6px;font-size:19px">The public ledger</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The <a href="/#ledger">Paid so far</a> section on the home page shows the totals and the newest drips, each with a verify link to its transaction. Here are the live numbers:</p><div class="stats" id="stats"></div><div class="ledger" id="recent" style="margin-top:12px"><div class="row"><span class="site">Loading…</span></div></div><h3 style="margin:22px 0 6px;font-size:19px">Where the POL comes from</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Regular finds are paid by the company as a marketing cost for the network: you visit our sites, we pay you a drip for it. Advertiser missions are paid out of what the advertiser put in. You never pay to hunt. The Game Pass is sold on InstantAdPay and is optional.</p><h3 style="margin:22px 0 6px;font-size:19px">What we ask of you, and what we never ask</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">You sign in with your InstantAdPay account and the drip goes to the wallet linked there. Nobody from PolHunter will ever ask for your recovery phrase or private key. If someone does, it is not us.</p><h3 style="margin:22px 0 6px;font-size:19px">What is not promised</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">PolHunter rewards completed missions. Rewards are not income, wages or an investment, and are not guaranteed. The price of POL moves. Read the <a href="/terms">Terms</a> and the <a href="/disclaimer">Rewards disclaimer</a>.</p>
|
||||
</section>
|
||||
<section class="section"><h2>More guides</h2><div class="steps"><div class="step"><b><a href="/guides/how-a-hunt-works">How a hunt works</a></b><br>Missions, codes, the daily reset, and what each find pays.</div><div class="step"><b><a href="/guides/free-account">Getting the most from your free account</a></b><br>Set up once, hunt every day, and the extras that cost nothing.</div><div class="step"><b><a href="/guides/faq">PolHunter FAQ</a></b><br>Short answers to the questions hunters ask most.</div></div></section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
<script>
|
||||
(async () => {
|
||||
try {
|
||||
const r = await (await fetch('/api/ledger')).json(); const t = r.totals || {};
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
document.getElementById('stats').innerHTML = [['POL paid', (t.pol || 0).toLocaleString('en-US', { maximumFractionDigits: 2 })], ['drips', t.paid || 0], ['hunters', t.hunters || 0]]
|
||||
.map(([l, v]) => '<div class="stat"><div class="v num">' + v + '</div><div class="l">' + l + '</div></div>').join('');
|
||||
document.getElementById('recent').innerHTML = (r.recent || []).slice(0, 10).map(x => '<div class="row"><span>' + esc(x.who) + '</span><span class="site">' + esc(x.site) + '</span><span class="pol">+' + Number(x.pol) + ' POL</span><a class="when" href="https://polygonscan.com/tx/' + encodeURIComponent(x.tx) + '" target="_blank" rel="noopener">verify ↗</a></div>').join('') || '<div class="row"><span class="site">No drips yet.</span></div>';
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+5
-3
@@ -22,6 +22,7 @@
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="#start">Get started</a>
|
||||
<a class="btn ghost sm" href="#how">How it works</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
<a class="btn sm" id="signin" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
@@ -56,7 +57,7 @@
|
||||
|
||||
<section class="section" id="how">
|
||||
<h2>How a hunt works</h2>
|
||||
<div class="sub">Three steps, one code, real POL.</div>
|
||||
<div class="sub">Three steps, one code, real POL. The full rules are in <a href="/guides/how-a-hunt-works">How a hunt works</a>.</div>
|
||||
<div class="steps">
|
||||
<div class="step"><b>Pick a mission</b> on your board. Each one names a site and what to find there.</div>
|
||||
<div class="step"><b>Go find it.</b> Spend the time on the site. Your personal code appears when you have, somewhere on the page.</div>
|
||||
@@ -71,12 +72,12 @@
|
||||
<div class="ledger" id="recent"><div class="row"><span class="site">Loading…</span></div></div>
|
||||
</section>
|
||||
|
||||
<div class="adslot" data-ad="home-footer"><!-- nas: 468x60 on phones, 728x90 on wider screens --><script>(function(){var m=window.innerWidth<600;document.write('<scr'+'ipt src="https://www.networkadspace.com/showadss.php?'+(m?'w=468&h=60&n=1&bw=468&bh=60':'w=728&h=90&n=1&bw=728&bh=90')+'&c=999"></scr'+'ipt>');})();</script></div>
|
||||
<div class="adslot" data-nas data-ad="home-footer"><!-- nas: 468x60 on phones, 728x90 on wider screens; framed by /nas.js so a dead ad server never blocks the page --></div>
|
||||
|
||||
<footer class="foot">
|
||||
PolHunter rewards completed missions. Rewards are not income and are not guaranteed; the daily pool is limited, and when it is spent claims close until midnight Central. Drips are random within the posted range. Cryptocurrency involves risk of loss. Hunters sign in with an InstantAdPay account; no account is created here.
|
||||
<br>PolHunter is part of the InstantAdPay network, the Polygon wing of the <a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>.
|
||||
<br><a href="https://instantadpay.com">InstantAdPay</a> · <a href="/admin" rel="nofollow" style="color:var(--dim)">·</a>
|
||||
<br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a> · <a href="/admin" rel="nofollow" style="color:var(--dim)">·</a>
|
||||
</footer>
|
||||
</div>
|
||||
<script>
|
||||
@@ -114,5 +115,6 @@
|
||||
document.querySelectorAll('a[href="https://instantadpay.com/api/my/polhunter"]').forEach(function (a) { if (r) a.href = a.href + '?ref=' + encodeURIComponent(r); });
|
||||
if (framed) document.querySelectorAll('a[href^="http"]').forEach(function (a) { if (a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; } });
|
||||
})();</script>
|
||||
<script src="/nas.js?v=20261024" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+5
-4
@@ -14,7 +14,7 @@
|
||||
<nav class="nav">
|
||||
<a class="btn pol sm" href="https://instantadpay.com/my" title="Back to your InstantAdPay dashboard">← InstantAdPay</a>
|
||||
<a class="btn ghost sm" href="/promo">Promo tools</a>
|
||||
<a class="btn ghost sm" href="/#how">How it works</a>
|
||||
<a class="btn ghost sm" href="/guides">Guides</a>
|
||||
<a class="btn sm" href="https://instantadpay.com/api/my/polhunter">Open my board</a>
|
||||
</nav>
|
||||
</header>
|
||||
@@ -41,9 +41,9 @@
|
||||
<div class="badge-strip" id="badges"></div>
|
||||
</section>
|
||||
|
||||
<div class="adslot" data-ad="leaders"><!-- nas: 468x60 on phones, 728x90 on wider screens --><script>(function(){var m=window.innerWidth<600;document.write('<scr'+'ipt src="https://www.networkadspace.com/showadss.php?'+(m?'w=468&h=60&n=1&bw=468&bh=60':'w=728&h=90&n=1&bw=728&bh=90')+'&c=999"></scr'+'ipt>');})();</script></div>
|
||||
<div class="adslot" data-nas data-ad="leaders"><!-- nas: 468x60 on phones, 728x90 on wider screens; framed by /nas.js so a dead ad server never blocks the page --></div>
|
||||
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss. <br><a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss. <br>© 2026 TrustClickz · <a href="/guides">Guides</a> · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
<script>
|
||||
(async () => {
|
||||
@@ -60,7 +60,7 @@
|
||||
}
|
||||
document.querySelectorAll('.tab').forEach(t => t.addEventListener('click', () => show(t.dataset.p)));
|
||||
try { const pz = await (await fetch('/api/prizes')).json(); const pol = pz.rules.pol;
|
||||
document.getElementById('prizes').innerHTML = '<b>Weekly prizes:</b> ' + pol.map((v, i) => medal(i + 1) + ' ' + v + ' POL').join(' \u00b7 ') + ' for the top ' + pol.length + ' with ' + pz.rules.minFinds + '+ finds. Paid to your wallet Monday after midnight Central. Weekly #1 also earns the Top Hunter badge.';
|
||||
document.getElementById('prizes').innerHTML = '<b>Weekly prizes:</b> ' + pol.map((v, i) => medal(i + 1) + ' ' + v + ' POL').join(' \u00b7 ') + ' for the top ' + pol.length + ' <b>Game Pass holders</b> with ' + pz.rules.minFinds + '+ finds. <b>You need an active Game Pass when the week ends (Sunday midnight Central) to win a prize.</b> Without one you still appear on the board, but the prize goes to the next Pass holder. Paid to your wallet Monday after midnight Central. Weekly #1 also earns the Top Hunter badge. <a href="https://instantadpay.com/my#passes" target="_blank" rel="noopener">Get a Game Pass</a>';
|
||||
if (pz.last && pz.last.winners.length) { document.getElementById('winners').style.display = 'block'; document.getElementById('winsub').textContent = 'Week of ' + pz.last.week + '.'; document.getElementById('winrows').innerHTML = pz.last.winners.map(w => '<div class="row lb"><span><b class="num">' + medal(w.rank) + '</b> ' + esc(w.who) + '</span><span class="site">' + w.finds + ' finds</span><span class="pol">+' + w.prizePol + ' POL prize</span></div>').join(''); }
|
||||
} catch (e) {}
|
||||
const b = await (await fetch('/api/badges')).json();
|
||||
@@ -75,5 +75,6 @@
|
||||
document.querySelectorAll('a[href="https://instantadpay.com/api/my/polhunter"]').forEach(function (a) { if (r) a.href = a.href + '?ref=' + encodeURIComponent(r); });
|
||||
if (framed) document.querySelectorAll('a[href^="http"]').forEach(function (a) { if (a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; } });
|
||||
})();</script>
|
||||
<script src="/nas.js?v=20261024" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// NAS banner slots (2026-10-24): each ad loads inside its own frame, so a slow or offline ad server (networkadspace.com
|
||||
// sits on the rhi box) can only blank its own box. The old inline document.write script blocked the page below it,
|
||||
// and PolHunter stopped loading halfway during the 10-24 data-center move.
|
||||
(function () {
|
||||
function fill(el) {
|
||||
var m = window.innerWidth < 600, w = m ? 468 : 728, h = m ? 60 : 90;
|
||||
var src = 'https://www.networkadspace.com/showadss.php?w=' + w + '&h=' + h + '&n=1&bw=' + w + '&bh=' + h + '&c=999';
|
||||
var f = document.createElement('iframe');
|
||||
f.width = w; f.height = h; f.title = 'Advertisement'; f.loading = 'lazy';
|
||||
f.setAttribute('scrolling', 'no');
|
||||
f.style.cssText = 'border:0;max-width:100%;display:block;margin:0 auto;background:transparent';
|
||||
f.srcdoc = '<!doctype html><html><head><base target="_blank"><style>html,body{margin:0;padding:0;overflow:hidden;background:transparent}</style></head><body><script src="' + src + '"><\/script></body></html>';
|
||||
el.appendChild(f);
|
||||
}
|
||||
function run() { var s = document.querySelectorAll('[data-nas]'); for (var i = 0; i < s.length; i++) fill(s[i]); }
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
|
||||
})();
|
||||
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Privacy Policy · PolHunter</title>
|
||||
<meta name="description" content="What PolHunter keeps about you, why, and for how long.">
|
||||
<link rel="canonical" href="https://polhunter.com/privacy">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn ghost sm" href="/#how">How it works</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small">Last updated November 17, 2026</div>
|
||||
<h2>PolHunter Privacy Policy</h2>
|
||||
<div class="sub">What PolHunter keeps about you, why, and for how long.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">Who we are</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">PolHunter is run by TrustClickz.</p><h3 style="margin:22px 0 6px;font-size:19px">What we keep</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">From your InstantAdPay sign-in: your member number, username, email and linked wallet, used to run your hunt and pay your drips. Your finds, rewards, badges and referrals. Payouts are public on the Polygon blockchain and in the PolHunter ledger and leaderboard, shown by username.</p><h3 style="margin:22px 0 6px;font-size:19px">Fair play checks</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Your internet address is used to limit requests and stop abuse. It is not shown to anyone.</p><h3 style="margin:22px 0 6px;font-size:19px">Cookies</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">A sign-in cookie (30 days), a cookie that remembers who referred you (30 days), and no advertising or tracking cookies of our own.</p><h3 style="margin:22px 0 6px;font-size:19px">Who else sees data</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The Polygon blockchain: every drip is public there, by its nature. InstantAdPay, which signs you in. Our Telegram and Discord groups, where finds, prizes and payouts can be posted with your username. Network sites that carry a mission embed. We do not sell personal data.</p><h3 style="margin:22px 0 6px;font-size:19px">Your choices</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">You can stop hunting at any time, or ask us to remove your PolHunter records. Records on the blockchain cannot be removed by anyone.</p><h3 style="margin:22px 0 6px;font-size:19px">Contact</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Questions, problems or a request about your data: <a href="https://instantadpay.com/support" rel="noopener">network support</a> (TrustClickz).</p>
|
||||
</section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
+3
-2
@@ -71,9 +71,9 @@
|
||||
<div class="grid" id="swipes"></div>
|
||||
</section>
|
||||
|
||||
<div class="adslot" data-ad="promo"><!-- nas: 468x60 on phones, 728x90 on wider screens --><script>(function(){var m=window.innerWidth<600;document.write('<scr'+'ipt src="https://www.networkadspace.com/showadss.php?'+(m?'w=468&h=60&n=1&bw=468&bh=60':'w=728&h=90&n=1&bw=728&bh=90')+'&c=999"></scr'+'ipt>');})();</script></div>
|
||||
<div class="adslot" data-nas data-ad="promo"><!-- nas: 468x60 on phones, 728x90 on wider screens; framed by /nas.js so a dead ad server never blocks the page --></div>
|
||||
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed; the daily pool is limited and drips are random within the posted range. Cryptocurrency involves risk of loss. <br><a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed; the daily pool is limited and drips are random within the posted range. Cryptocurrency involves risk of loss. <br>© 2026 TrustClickz · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
<script>
|
||||
(async () => {
|
||||
@@ -130,5 +130,6 @@
|
||||
document.querySelectorAll('a[href="https://instantadpay.com/api/my/polhunter"]').forEach(function (a) { if (r) a.href = a.href + '?ref=' + encodeURIComponent(r); });
|
||||
if (framed) document.querySelectorAll('a[href^="http"]').forEach(function (a) { if (a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; } });
|
||||
})();</script>
|
||||
<script src="/nas.js?v=20261024" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -157,3 +157,10 @@ textarea{width:100%;padding:12px 14px;border-radius:12px;border:1px solid var(--
|
||||
|
||||
/* cross-promo strip (2026-10-03) */
|
||||
.moreGames{--gs-ink:var(--ink);--gs-muted:var(--muted);--gs-card:var(--glass);--gs-line:var(--edge);--gs-hot:var(--gold);--gs-font:var(--font);margin-top:12px}
|
||||
/* the Network Tour (2026-11-17): round progress on the board */
|
||||
.tour{padding:14px 18px;border-radius:16px;border:1px solid var(--edge-hi);background:rgba(130,71,229,.10)}
|
||||
.tour-hd{font-size:15px;color:var(--ink)} .tour-r{color:var(--dim);font-size:13px}
|
||||
.tour-bar{height:8px;border-radius:999px;background:rgba(255,255,255,.08);margin:10px 0 8px;overflow:hidden}
|
||||
.tour-bar i{display:block;height:100%;border-radius:999px;background:linear-gradient(90deg,var(--pol-hi),var(--gold-hi))}
|
||||
.tour-left{font-size:13px;color:var(--muted);line-height:1.5}
|
||||
.tour-free{margin:10px 0 0;font-size:14px;color:var(--gold-hi)}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Terms and Conditions · PolHunter</title>
|
||||
<meta name="description" content="The rules for hunting on PolHunter, in plain English.">
|
||||
<link rel="canonical" href="https://polhunter.com/terms">
|
||||
<link rel="stylesheet" href="/style.css?v=12">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="top">
|
||||
<a class="mark" href="/"><span class="coin"></span>PolHunter</a>
|
||||
<nav class="nav">
|
||||
<a class="btn ghost sm" href="/#how">How it works</a>
|
||||
<a class="btn ghost sm" href="/leaders">Leaderboard</a>
|
||||
</nav>
|
||||
</header>
|
||||
<section class="section" style="padding-top:14px">
|
||||
<div class="small">Last updated November 17, 2026</div>
|
||||
<h2>PolHunter Terms and Conditions</h2>
|
||||
<div class="sub">The rules for hunting on PolHunter, in plain English.</div>
|
||||
<h3 style="margin:22px 0 6px;font-size:19px">Who we are</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">PolHunter (polhunter.com) is run by TrustClickz. It is a game in the InstantAdPay network. By using PolHunter you agree to these terms.</p><h3 style="margin:22px 0 6px;font-size:19px">What PolHunter is</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">PolHunter is a scavenger hunt across network websites. A mission sends you to a page where a code is hidden; you find the code and enter it here. A correct find can pay a small drip of POL on Polygon from the PolHunter reward wallet.</p><h3 style="margin:22px 0 6px;font-size:19px">Your account</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">You sign in with your InstantAdPay account. No separate account is created here. Drips go to the wallet linked to your InstantAdPay account. You must be old enough to make a binding agreement where you live, and using crypto must be legal there.</p><h3 style="margin:22px 0 6px;font-size:19px">How rewards work</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Each mission can be found once per Central day. A free InstantAdPay account can claim a limited number of finds a day at a smaller drip; Game Pass holders get more finds a day, the weekly prizes and the Mystery Hunt Box. Drips are random within the range shown on the site. The daily pool is limited: when it is spent, claims close until midnight Central or are paid on a later day. Referral rewards, when offered, are paid to the referrer from their own limited pool and only for new members.</p><h3 style="margin:22px 0 6px;font-size:19px">Nothing is promised</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Rewards are not income, wages, an investment or a promise of any payment. We may change the drip range, the number of finds, the pools, the missions or the prizes at any time. Read the <a href="/disclaimer">Rewards disclaimer</a>.</p><h3 style="margin:22px 0 6px;font-size:19px">Fair play</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">One person, one account. Two accounts sharing a wallet get one drip per mission per day between them. Bots, scripts, shared or traded codes, multiple accounts and faked visits are not allowed. We may refuse, hold or reverse a reward we judge not to be fair play, and close the account behind it.</p><h3 style="margin:22px 0 6px;font-size:19px">Crypto risk</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The price of POL moves. The dollar value of a drip can be higher or lower later. Blockchain transactions are final. You are responsible for your wallet and its recovery phrase; never share it with anyone. We will never ask for it.</p><h3 style="margin:22px 0 6px;font-size:19px">Other sites</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Missions send you to network and partner websites run under their own terms. We are not responsible for third-party websites.</p><h3 style="margin:22px 0 6px;font-size:19px">The service</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">The site is provided as it is. We work to keep it running but cannot promise it will always be available or free of errors. Changes to these terms apply from the date they are posted here.</p><h3 style="margin:22px 0 6px;font-size:19px">Limits</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">As far as the law allows, we are not responsible for losses caused by the blockchain, your wallet, the price of POL, third-party websites, or events outside our control. These terms are governed by the laws of the State of Alabama, USA.</p><h3 style="margin:22px 0 6px;font-size:19px">Contact</h3><p style="margin:0 0 12px;max-width:70ch;line-height:1.65">Questions, problems or a request about your data: <a href="https://instantadpay.com/support" rel="noopener">network support</a> (TrustClickz).</p>
|
||||
</section>
|
||||
<footer class="foot">PolHunter rewards completed missions. Rewards are not income and are not guaranteed. Cryptocurrency involves risk of loss.<br>© 2026 TrustClickz · <a href="/terms">Terms</a> · <a href="/disclaimer">Rewards disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="https://instantadpay.com/support" rel="noopener">Support</a> · <a href="https://instantadpay.com">InstantAdPay</a></footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,6 +45,28 @@ const signupsOpen = () => process.env.SIGNUPS === 'open';
|
||||
store.init(DATA_DIR);
|
||||
const faucetOn = faucet.init();
|
||||
detective.init();
|
||||
// ---- Game Pass (GAMEPASS=on, docs/GAME-PASS.md 3a): InstantAdPay's account-wide daily cap decides what a hunter is paid; the house
|
||||
// cap and the per-hunter daily limit stay as backstops. Finds and Ad Detective cases are repeatable ('daily'): what the cap does not
|
||||
// allow is dropped and the hunter is told. Advertiser-funded missions are NOT gated: the advertiser already paid for that completion.
|
||||
const gp = require('./lib/polgrant'), tournament = require('./lib/tournament');
|
||||
const IAP_URL = String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
|
||||
gp.use({ game: 'polhunter', secret: String(process.env.HUNT_SSO_SECRET || '').trim(), iap: IAP_URL, store, notify: (kind, p) => notify(kind, p) });
|
||||
const passActive = me => !!(gp.on() && me && gp.passOf(me.memberId, me.email).active);
|
||||
const passExtra = me => passActive(me) ? 2 : 0; // the perk: 5 missions a day instead of 3
|
||||
// the full tier (Marty 2026-11-02): Game Pass holders get the full allotment, the full draw, the weekly prizes and the Mystery Box;
|
||||
// a free account gets the free tier (lib/rewards.js freeMissionsPerDay / freeMinPol / freeMaxPol). With GAMEPASS off there is no
|
||||
// pass to buy, so everyone stays on the full tier as before.
|
||||
const fullTier = me => !gp.on() || passActive(me);
|
||||
// the Network Tour (Marty 2026-11-17, lib/rotation.js): rounds per hunter; a free member's repeat find is a tour stop (ad credits, no POL)
|
||||
const rotation = require('./lib/rotation');
|
||||
const isTourStop = (me, m) => !fullTier(me) && !m.paid && rotation.everFound(me.memberId, me.wallet, m.id);
|
||||
// one reward through IAP: ask(pol, ref) -> IAP's answer (+ the player-facing note), wait(rowId, pol, ref) -> queue the ref (fail closed)
|
||||
const gpGate = me => ({
|
||||
ask: async (pol, ref) => { const r = await gp.grant({ memberId: me.memberId, email: me.email, kind: 'daily', pol, ref }); r.note = gp.note(r, 'daily', pol); return r; },
|
||||
wait: (rowId, pol, ref) => gp.enqueue({ memberId: me.memberId, email: me.email, ref, kind: 'daily', pol, rowId }),
|
||||
});
|
||||
const payQueued = async (item, r) => { rewards.settleQueued(item.rowId, r.allowed, { pass: !!r.pass, capHit: r.capHit || null }); }; // a queued ref finally answered
|
||||
tournament.init({ faucet, notify: (kind, p) => notify(kind, p), dry: faucet.dry });
|
||||
// Badges added after launch count work already done, so on the day they ship many hunters hold them at once.
|
||||
// Those are marked as announced without posting, or the badge sweep would flood Telegram with old news.
|
||||
// Badges earned from here on are announced as usual. Runs once per new badge id.
|
||||
@@ -91,7 +113,10 @@ async function notifyPaid(p) {
|
||||
{ const ok = await telegram('\u{1F3AF} <b>PolHunter</b> · ' + (p.username ? '@' + p.username : '#' + p.memberId) + ' found it on ' + p.site + ' and got <b>' + fmt(p.pol) + ' POL</b> · <a href="' + explorer() + '/tx/' + p.tx + '">verify</a>\n<a href="' + SITE + '">Hunt yours</a>'); if (ok && p.id) rewards.mark(p.id, { posted: Date.now() }); return ok; }
|
||||
}
|
||||
async function notifyOther(kind, p) {
|
||||
if (kind === 'low') return telegram('⚠️ <b>PolHunter faucet is low</b>: ' + fmt(p.balance) + ' POL left in ' + p.address + ' (alert threshold ' + fmt(p.threshold) + '). Top up from Receiver B.');
|
||||
if (kind === 'low') return telegram('⚠️ <b>PolHunter faucet is low</b>: ' + fmt(p.balance) + ' POL left in ' + p.address + ' (alert threshold ' + fmt(p.threshold) + ').' + (p.tournament ? ' A Pass Tournament prize is waiting on it.' : '') + ' Top up from Receiver B.');
|
||||
if (kind === 'gpstuck') return telegram('⚠️ <b>PolHunter</b> Game Pass grant stuck 48 h: member #' + p.memberId + ' ' + (p.email || '') + ' ref ' + p.ref + ' (' + fmt(p.pol) + ' POL, ' + p.kind + '). InstantAdPay /api/partner/polgrant unreachable: ' + (p.error || '?'));
|
||||
if (kind === 'tourneypaid') return telegram('\u{1F3C6} <b>Pass Tournament</b> prize paid from the PolHunter faucet: week ' + p.week + ' place ' + p.place + ' · ' + (p.email || '#' + p.memberId) + ' · <b>' + fmt(p.pol) + ' POL</b> · <a href="' + explorer() + '/tx/' + p.tx + '">verify</a>');
|
||||
if (kind === 'tourneyfail') return telegram('❌ <b>Pass Tournament</b> prize NOT paid (row stays pending on InstantAdPay): week ' + p.week + ' place ' + p.place + ' · ' + (p.email || '#' + p.memberId) + ' · ' + fmt(p.pol) + ' POL · ' + p.error);
|
||||
if (kind === 'failed') return telegram('❌ <b>PolHunter</b> · drip to #' + p.memberId + ' failed: ' + p.error);
|
||||
// a bounty is the one payout that advertises the mission itself, so it goes to the room
|
||||
if (kind === 'referral') { const d = p.drip; return telegram('\u{1F91D} <b>PolHunter</b> · ' + (d.username ? '@' + d.username : '#' + d.memberId) + ' brought ' + d.ref.forName + ' in and they are hunting · <b>' + fmt(d.pol) + ' POL</b> bounty on the way\n<a href="' + SITE + '">Bring yours</a>'); }
|
||||
@@ -106,7 +131,7 @@ async function postBadge(p) {
|
||||
return false;
|
||||
}
|
||||
// Marty's rule (2026-09-19): when the day's pool is spent, say so; claims reopen at midnight Central
|
||||
const dailyMsg = d => 'That is your ' + (['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'][d.limit] || d.limit) + ' for today. Fresh missions at midnight Central.';
|
||||
const dailyMsg = d => 'That is your ' + (['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'][d.limit] || d.limit) + ' for today. Fresh missions at midnight Central.' + (d.pass ? '' : ' Game Pass holders hunt five a day at the full reward.'); // free tier since 2026-11-02
|
||||
const SPENT_MSG = 'Today\u2019s POL pool is spent. No more claims today. Claims reopen at midnight Central.';
|
||||
function refOf(req) { const m = /(?:^|;\s*)ph\.ref=([^;]+)/.exec(req.headers.cookie || ''); const r = m ? decodeURIComponent(m[1]) : ''; return /^[A-Za-z0-9_.-]{1,40}$/.test(r) ? r : null; }
|
||||
function explorer() { return Number(process.env.HUNT_CHAIN_ID) === 80002 ? 'https://amoy.polygonscan.com' : 'https://polygonscan.com'; }
|
||||
@@ -229,6 +254,7 @@ const server = http.createServer(async (req, res) => {
|
||||
let sid = cur && cur.memberId === Number(v.claims.memberId) ? cur.sid : null;
|
||||
if (sid) sso.refresh(sid, v.claims); else sid = sso.startSession(v.claims);
|
||||
referrals.seen(v.claims); // keep the hunter directory (and the sponsor behind it) current on every sign-in
|
||||
if (v.claims.gamePass != null) gp.rememberPass(v.claims.memberId, v.claims.email, v.claims.gamePass); // the Game Pass flag rides on the hand-off as gamePass:{active,until} (GAME-PASS.md 3a item 7)
|
||||
res.writeHead(302, { Location: '/app', 'Set-Cookie': sso.cookie(sid), 'Cache-Control': 'no-store' }); return res.end();
|
||||
}
|
||||
if (p === '/logout') { const s = sso.fromRequest(req); if (s) sso.endSession(s.sid); res.writeHead(302, { Location: '/', 'Set-Cookie': sso.clearCookie() }); return res.end(); }
|
||||
@@ -247,6 +273,18 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/prizes') return json(res, 200, social.prizes(), { 'Cache-Control': 'public, max-age=60' });
|
||||
if (p === '/leaders') return sendFile(res, path.join(PUBLIC_DIR, 'leaders.html'));
|
||||
if (p === '/promo') return sendFile(res, path.join(PUBLIC_DIR, 'promo.html'));
|
||||
if (p === '/terms' || p === '/privacy' || p === '/disclaimer') return sendFile(res, path.join(PUBLIC_DIR, p.slice(1) + '.html')); // legal pages (2026-11-17)
|
||||
// evergreen Guides (Marty 2026-11-17): /guides and four pages, static files in public/guides
|
||||
const GUIDES = ['how-a-hunt-works', 'is-polhunter-legit', 'free-account', 'faq'];
|
||||
if (p === '/guides' || p === '/guides/') return sendFile(res, path.join(PUBLIC_DIR, 'guides', 'index.html'));
|
||||
{ const gm = /^\/guides\/([a-z-]+)\/?$/.exec(p); if (gm && GUIDES.includes(gm[1])) return sendFile(res, path.join(PUBLIC_DIR, 'guides', gm[1] + '.html')); }
|
||||
if (p === '/sitemap.xml') { // the public pages (2026-11-17)
|
||||
const day = new Date().toISOString().slice(0, 10);
|
||||
const urls = ['/', '/leaders', '/promo', '/guides', ...GUIDES.map(g => '/guides/' + g), '/terms', '/disclaimer', '/privacy'].map(x => '<url><loc>' + SITE + x + '</loc><lastmod>' + day + '</lastmod></url>').join('');
|
||||
res.writeHead(200, Object.assign({ 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, max-age=3600' }, SEC));
|
||||
return res.end('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + urls + '</urlset>');
|
||||
}
|
||||
if (p === '/robots.txt') { res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'public, max-age=3600' }); return res.end('User-agent: *\nDisallow: /app\nDisallow: /admin\nSitemap: ' + SITE + '/sitemap.xml\n'); }
|
||||
if (p === '/api/ledger') { const t = rewards.totals(); return json(res, 200, { totals: t, referrals: referrals.totals(), pools: { finds: rewards.pool(), referral: referrals.refPool() }, recent: rewards.ledger(30).map(x => ({ who: x.username ? '@' + x.username : '#' + x.memberId, site: x.site, pol: x.pol, tx: x.tx, at: x.paidAt })) }); }
|
||||
|
||||
// ---- hunter (session required)
|
||||
@@ -254,19 +292,26 @@ const server = http.createServer(async (req, res) => {
|
||||
const me = sso.fromRequest(req); if (!me) return json(res, 401, { error: 'Open PolHunter from your InstantAdPay dashboard to sign in.' });
|
||||
if (p === '/api/my/board') {
|
||||
const fbank = await fbFor(me);
|
||||
if (gp.on()) gp.fetchPass(me.memberId, me.email).catch(() => {}); // keep the Game Pass flag fresh (display + perks; grant answers carry the truth)
|
||||
referrals.seen(me); // hunters already signed in never pass through /auth again, so keep the directory fresh here too
|
||||
const done = rewards.doneToday(me.memberId, me.wallet); const wdone = done; // today's finds, by member id or wallet
|
||||
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, missions: missions.forMember(me.memberId).map(m => Object.assign(pubMission(m), { done: done.has(m.id) || wdone.has(m.id) })), drips: rewards.mine(me.memberId).slice(0, 20), faucet: { on: faucetOn }, pool: rewards.pool(), daily: rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fbank.bonus), fridayBank: fbank,
|
||||
badges: social.badgesFor(me.memberId), badgeCards: (() => { const got = new Set(social.badgesFor(me.memberId).map(b => b.id)); const who = social.nameOf(me); return social.BADGES.map(b => ({ id: b.id, name: b.name, icon: b.icon, why: b.why, art: '/badges/badge-' + b.id + '.jpg', earned: got.has(b.id), page: got.has(b.id) ? SITE + '/b/' + who + '/' + b.id : null, image: got.has(b.id) ? SITE + '/badge-img/' + who + '/' + b.id + '.jpg' : null })); })(), rank: { week: social.rankOf(me.memberId, 'week'), month: social.rankOf(me.memberId, 'month'), all: social.rankOf(me.memberId, 'all') },
|
||||
const done = rewards.doneToday(me.memberId, me.wallet); // today's finds, by member id or wallet
|
||||
// the Network Tour: open this round first (never visited, then least recently found), then today's finds marked done
|
||||
const rot = rotation.state(me), free = !fullTier(me), rc = rotation.cfg();
|
||||
const offered = rotation.order(me, rot).filter(m => !done.has(m.id)), doneList = missions.forMember(me.memberId).filter(m => done.has(m.id));
|
||||
const boardMissions = offered.concat(doneList).map(m => Object.assign(pubMission(m), { done: done.has(m.id), fresh: !m.paid && !rot.last.has(m.id), tourStop: free && !m.paid && rot.last.has(m.id) ? { credits: rc.credits } : undefined }));
|
||||
const tour = { on: rot.on, round: rot.round, rounds: rot.rounds, done: rot.done, total: rot.total, left: [...new Set(rot.left.map(m => m.site))], toured: rot.toured, free, tourStopCredits: rc.credits };
|
||||
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, missions: boardMissions, tour, drips: rewards.mine(me.memberId).slice(0, 20), faucet: { on: faucetOn }, pool: rewards.pool(), daily: rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fbank.bonus, passExtra(me), fullTier(me)), /* the tier, as start/submit pass it (the board showed a Pass holder 3, not 5) */ fridayBank: fbank, gamepass: gp.view(me.memberId, me.email),
|
||||
badges: social.badgesFor(me.memberId), badgeCards: (() => { const got = new Set(social.badgesFor(me.memberId).map(b => b.id)); const who = social.nameOf(me); return social.BADGES.map(b => ({ id: b.id, name: b.name, icon: b.icon, why: b.why, count: b.id === 'sweep' && rot.rounds > 1 ? rot.rounds : undefined, art: '/badges/badge-' + b.id + '.jpg', earned: got.has(b.id), page: got.has(b.id) ? SITE + '/b/' + who + '/' + b.id : null, image: got.has(b.id) ? SITE + '/badge-img/' + who + '/' + b.id + '.jpg' : null })); })(), rank: { week: social.rankOf(me.memberId, 'week'), month: social.rankOf(me.memberId, 'month'), all: social.rankOf(me.memberId, 'all') },
|
||||
share: { link: social.shareLink(SITE, me), joinUrl: 'https://instantadpay.com/join/' + encodeURIComponent(String(me.username || me.memberId)) + '?from=polhunter' },
|
||||
referral: referrals.state(me), box: detective.view(me) });
|
||||
referral: referrals.state(me), box: detective.view(me, fullTier(me)) });
|
||||
}
|
||||
if (p === '/api/my/start' && req.method === 'POST') {
|
||||
const b = await readBody(req); const m = missions.get(String(b.missionId || '')); if (!m || !m.active) return json(res, 404, { error: 'That mission is not open.' });
|
||||
if (!me.wallet) return json(res, 400, { error: 'Link a wallet on InstantAdPay first so the drip has somewhere to land, then open PolHunter again.' });
|
||||
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
||||
if (rotation.blocked(me, m)) return json(res, 400, { error: 'You found this one already this round. The rest of the network tour comes first.', tour: true });
|
||||
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
||||
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus, passExtra(me), fullTier(me)); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||
if (limited('start:' + me.memberId, 20, 3600000)) return json(res, 429, { error: 'Easy. Twenty starts an hour is plenty.' });
|
||||
const t = missions.issue(me.memberId, m.id);
|
||||
// a mission URL may place the token itself with {token} (a Telegram Mini App takes it in
|
||||
@@ -282,20 +327,40 @@ const server = http.createServer(async (req, res) => {
|
||||
const m = missions.get(c.rec.missionId); if (!m) return json(res, 404, { error: 'That mission is gone.' });
|
||||
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
||||
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
||||
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||
const before = new Set(social.badgesFor(me.memberId).map(b => b.id));
|
||||
const g = rewards.grant(me, m); if (g.error) return json(res, 400, g);
|
||||
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus, passExtra(me), fullTier(me)); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||
const before = new Set(social.badgesFor(me.memberId).map(b => b.id)); const roundsBefore = rotation.state(me).rounds;
|
||||
// a free member's repeat find (Marty 2026-11-17): a tour stop, ad credits instead of POL; counts as the day's hunt and for the tour
|
||||
if (isTourStop(me, m)) {
|
||||
const row = rotation.tourStop(me, m); const roundsNow = rotation.state(me).rounds;
|
||||
const unlocked = social.badgesFor(me.memberId).filter(b => !before.has(b.id));
|
||||
for (const b of unlocked) notify('badge', { me, id: b.id }).catch(() => {});
|
||||
const show = unlocked.map(b => b.id); if (roundsNow > roundsBefore && !show.includes('sweep')) show.push('sweep'); // a new round closed: celebrate again
|
||||
rotation.deliver(row, gp).catch(e => console.error('tour stop', e.message)); // signed call to InstantAdPay; owed and retried if it fails
|
||||
const cr = row.tourStop.credits;
|
||||
return json(res, 200, { ok: true, pol: 0, tourStop: { credits: cr }, unlocked: show, round: roundsNow > roundsBefore ? roundsNow : null, gamepass: gp.view(me.memberId, me.email),
|
||||
message: 'Tour stop logged. ' + (cr > 0 ? '+' + cr + ' ad credits are on their way to your InstantAdPay account.' : 'Today\u2019s tour-stop ad credits are already yours.') + ' New sites pay POL on your first find, and the Game Pass pays POL on every hunt.' });
|
||||
}
|
||||
let g, note = null;
|
||||
if (gp.on() && !m.paid) { // the Game Pass: IAP's account-wide daily cap first (a paid mission is the advertiser's money, not gated)
|
||||
const quote = rewards.quote(m, fullTier(me)), ref = 'find:' + m.id + ':' + missions.ctDay(), r = await gpGate(me).ask(quote, ref); note = r.note;
|
||||
if (r.retry) { g = rewards.grant(me, m, { pol: quote, status: 'gp-wait', nominal: quote, gp: { ref, kind: 'daily', nominal: quote, pending: true } }); if (!g.error) gpGate(me).wait(g.rec.id, quote, ref); }
|
||||
else g = rewards.grant(me, m, { pol: r.allowed, nominal: quote, gp: { ref, kind: 'daily', nominal: quote, pass: !!r.pass, capHit: r.capHit || null } });
|
||||
} else g = rewards.grant(me, m, { pass: fullTier(me) });
|
||||
if (g.error) return json(res, 400, g);
|
||||
// whoever brought this hunter gets paid for it: the bounty on their first find, a match while they are new
|
||||
let refDrips = [];
|
||||
try { refDrips = referrals.onFind(me, g.rec); } catch (e) { console.error('referral', e.message); }
|
||||
for (const d of refDrips) if (d.ref.kind === 'bounty' || d.ref.kind === 'first-bonus') notify(d.ref.kind === 'bounty' ? 'referral' : 'firstbonus', { drip: d }).catch(() => {});
|
||||
// achievements unlocked by this find: told to the board, posted to Telegram (gated)
|
||||
const roundsNow = rotation.state(me).rounds;
|
||||
const unlocked = social.badgesFor(me.memberId).filter(b => !before.has(b.id));
|
||||
for (const b of unlocked) notify('badge', { me, id: b.id }).catch(() => {});
|
||||
return json(res, 200, { ok: true, pol: g.rec.pol, queued: g.queued, unlocked: unlocked.map(b => b.id), message: g.queued ? 'Found it. Today’s POL is spoken for, so yours is queued and pays out next.' : 'Found it. ' + fmt(g.rec.pol) + ' POL is on its way to your wallet.' });
|
||||
const show = unlocked.map(b => b.id); if (roundsNow > roundsBefore && !show.includes('sweep')) show.push('sweep'); // Full Network Tour again: board only, Telegram posts a badge once
|
||||
return json(res, 200, { ok: true, pol: g.waiting ? 0 : g.rec.pol, nominal: g.rec.nominal, queued: g.queued, capped: g.capped, waiting: g.waiting, note, unlocked: show, round: roundsNow > roundsBefore ? roundsNow : null, gamepass: gp.view(me.memberId, me.email),
|
||||
message: g.waiting ? 'Found it. ' + note : g.capped ? 'Found it. ' + note : g.queued ? 'Found it. Today’s POL is spoken for, so yours is queued and pays out next.' : 'Found it. ' + fmt(g.rec.pol) + ' POL is on its way to your wallet.' + (note ? ' ' + note : '') });
|
||||
}
|
||||
// ---- Mystery Hunt Box + Ad Detective
|
||||
if (p === '/api/my/box/open' && req.method === 'POST') { const r = detective.open(me); return json(res, r.error ? 400 : 200, r.error ? r : { ok: true, box: detective.view(me) }); }
|
||||
if (p === '/api/my/box/open' && req.method === 'POST') { const r = detective.open(me, passActive(me), fullTier(me)); return json(res, r.error ? 400 : 200, r.error ? r : { ok: true, box: detective.view(me, fullTier(me)) }); } // pass: a second case a day
|
||||
if (p === '/api/my/box/start' && req.method === 'POST') {
|
||||
if (!me.wallet) return json(res, 400, { error: 'Link a wallet on InstantAdPay first so the reward has somewhere to land.' });
|
||||
if (limited('boxstart:' + me.memberId, 20, 3600000)) return json(res, 429, { error: 'Easy. Try again in a little while.' });
|
||||
@@ -305,11 +370,11 @@ const server = http.createServer(async (req, res) => {
|
||||
const b = await readBody(req);
|
||||
if (limited('boxans:' + me.memberId, 10, 3600000)) return json(res, 429, { error: 'Easy. Try again in a little while.' });
|
||||
const before = new Set(social.badgesFor(me.memberId).map(x => x.id));
|
||||
const r = detective.answer(me, b.choice); if (r.error) return json(res, 400, r);
|
||||
const r = await detective.answer(me, b.choice, gp.on() ? gpGate(me) : null); if (r.error) return json(res, 400, r);
|
||||
const unlocked = r.correct ? social.badgesFor(me.memberId).filter(x => !before.has(x.id)) : [];
|
||||
for (const x of unlocked) notify('badge', { me, id: x.id }).catch(() => {});
|
||||
const msg = r.correct ? (r.queued ? 'Case solved. Today\u2019s POL is spoken for, so your ' + fmt(r.pol) + ' POL is queued and pays out next.' : 'Case solved. ' + fmt(r.pol) + ' POL is on its way to your wallet.') : 'Not this time. The answer was: ' + r.answer + '. A new box unlocks tomorrow.';
|
||||
return json(res, 200, { ok: true, correct: r.correct, pol: r.pol, queued: r.queued, unlocked: unlocked.map(x => x.id), message: msg, box: detective.view(me) });
|
||||
return json(res, 200, { ok: true, correct: r.correct, pol: r.pol, nominal: r.nominal, queued: r.queued, capped: r.capped, waiting: r.waiting, note: r.note || null, unlocked: unlocked.map(x => x.id), message: msg + (r.note ? ' ' + r.note : ''), box: detective.view(me, fullTier(me)), gamepass: gp.view(me.memberId, me.email) });
|
||||
}
|
||||
return json(res, 404, { error: 'No such call.' });
|
||||
}
|
||||
@@ -317,7 +382,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// ---- admin (key)
|
||||
if (p.startsWith('/api/admin/')) {
|
||||
if (!admin(req)) return json(res, 401, { error: 'Admin key required.' });
|
||||
if (p === '/api/admin/state') return json(res, 200, { missions: missions.list(), settings: rewards.settings(), totals: rewards.totals(), referrals: referrals.totals(), referralPool: referrals.refPool(), faucet: { on: faucetOn, address: faucet.address(), state: store.read('faucet-state', {}) }, payouts: store.read('payouts', []).slice(-100).reverse(), gates: { outbound: outbound(), signups: signupsOpen(), curtain: !!CURTAIN, sso: sso.enabled() } });
|
||||
if (p === '/api/admin/state') return json(res, 200, { missions: missions.list(), settings: rewards.settings(), totals: rewards.totals(), referrals: referrals.totals(), referralPool: referrals.refPool(), faucet: { on: faucetOn, address: faucet.address(), state: store.read('faucet-state', {}) }, payouts: store.read('payouts', []).slice(-100).reverse(), gates: { outbound: outbound(), signups: signupsOpen(), curtain: !!CURTAIN, sso: sso.enabled() }, gamepass: { on: gp.on(), iap: IAP_URL, queue: gp.queue().length, stuck: gp.queue().filter(x => x.stuck).length }, tournament: tournament.state() });
|
||||
if (p === '/api/admin/mission' && req.method === 'POST') {
|
||||
const b = await readBody(req);
|
||||
const id = String(b.id || '').trim().toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 40); if (!id) return json(res, 400, { error: 'id required' });
|
||||
@@ -328,10 +393,13 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { ok: true, missions: missions.list() });
|
||||
}
|
||||
if (p === '/api/admin/mission' && req.method === 'DELETE') { const b = await readBody(req); missions.remove(String(b.id || '')); return json(res, 200, { ok: true, missions: missions.list() }); }
|
||||
if (p === '/api/admin/settings' && req.method === 'POST') { const b = await readBody(req); const patch = {}; for (const k of ['minPol', 'maxPol', 'dailyCapPol', 'lowBalancePol', 'weeklyMinFinds', 'drawSkew', 'missionsPerDay', 'detectiveOn', 'detectivePol', 'refEnabled', 'refBountyPol', 'refMatchPct', 'refMatchDays', 'refNewDays', 'refCapPol', 'refMatchMinPol']) if (b[k] != null && Number(b[k]) >= 0) patch[k] = Number(b[k]); for (const k of ['weeklyPrizes', 'leaderboardExclude']) if (Array.isArray(b[k])) patch[k] = b[k].map(Number).filter(n => n >= 0); return json(res, 200, { ok: true, settings: rewards.setSettings(patch) }); }
|
||||
if (p === '/api/admin/settings' && req.method === 'POST') { const b = await readBody(req); const patch = {}; for (const k of ['minPol', 'maxPol', 'dailyCapPol', 'lowBalancePol', 'weeklyMinFinds', 'drawSkew', 'missionsPerDay', 'freeMissionsPerDay', 'freeMinPol', 'freeMaxPol', 'detectiveOn', 'detectivePol', 'refEnabled', 'refBountyPol', 'refMatchPct', 'refMatchDays', 'refNewDays', 'refCapPol', 'refMatchMinPol', 'rotationOn', 'tourStopCredits', 'tourStopCreditsDailyMax']) if (b[k] != null && Number(b[k]) >= 0) patch[k] = Number(b[k]); for (const k of ['weeklyPrizes', 'leaderboardExclude']) if (Array.isArray(b[k])) patch[k] = b[k].map(Number).filter(n => n >= 0); return json(res, 200, { ok: true, settings: rewards.setSettings(patch) }); }
|
||||
// award a week by hand (its Monday key); already-awarded weeks are skipped
|
||||
if (p === '/api/admin/prizes/award' && req.method === 'POST') { const b = await readBody(req); const r = social.awardWeek(String(b.week || '')); if (r && r.winners && r.winners.length) notify('prize', r).catch(() => {}); return json(res, r && r.error ? 400 : 200, r); }
|
||||
// one-time catch-up for an already-awarded week (2026-11-23), ignoring the Pass: pays the places that went unpaid, never anyone twice
|
||||
if (p === '/api/admin/prizes/fill' && req.method === 'POST') { const b = await readBody(req); const r = social.awardFill(String(b.week || '')); if (r && r.winners && r.winners.length) notify('prize', r).catch(() => {}); return json(res, r && r.error ? 400 : 200, r); }
|
||||
// Ad Detective question bank: stats per question, add or edit one, retire or restore one
|
||||
if (p === '/api/admin/rotation') return json(res, 200, rotation.adminView()); // the Network Tour: rounds per hunter, tour-stop credits sent / owed
|
||||
if (p === '/api/admin/detective') return json(res, 200, detective.stats());
|
||||
if (p === '/api/admin/detective/question' && req.method === 'POST') { const b = await readBody(req); if (b.id && b.active != null && !b.q) return json(res, detective.setActive(String(b.id), !!b.active) ? 200 : 404, { ok: true }); const r = detective.saveQuestion(b); return json(res, r.error ? 400 : 200, r); }
|
||||
if (p === '/api/admin/drip/retry' && req.method === 'POST') { const b = await readBody(req); rewards.mark(String(b.id || ''), { status: 'due', error: null }); return json(res, 200, { ok: true }); }
|
||||
@@ -355,6 +423,11 @@ const server = http.createServer(async (req, res) => {
|
||||
|
||||
// the faucet pays every two minutes; nothing outward leaves unless OUTBOUND=on (telegram checks)
|
||||
if (faucetOn) setInterval(() => faucet.tick(notify).catch(e => console.error('faucet', e.message)), 2 * 60000);
|
||||
// Game Pass: refs that could not reach InstantAdPay retry every 5 minutes (lib/polgrant.js); the weekly Pass Tournament prizes are
|
||||
// paid from this faucet every 10 minutes (lib/tournament.js). Both are inert unless GAMEPASS=on; prizes need the faucet wallet too.
|
||||
gp.startRetry(payQueued); if (faucetOn) tournament.start();
|
||||
// tour-stop ad credits InstantAdPay has not confirmed yet are retried every two minutes (owed until then)
|
||||
setInterval(() => { if (gp.on()) rotation.retryDue(gp).catch(e => console.error('tour stops', e.message)); }, 2 * 60000);
|
||||
// Every completed mission reaches Telegram (Marty, 2026-09-21): a find is posted when its drip is paid, and
|
||||
// this sweep posts any paid find that is not marked posted yet (the pre-live gate, Telegram down, a restart).
|
||||
// Only finds made after HUNT_POST_SINCE count, so rehearsal drips from before the doors opened stay quiet.
|
||||
@@ -383,6 +456,6 @@ async function postMissedBadges() {
|
||||
}
|
||||
setInterval(() => postMissedFinds().catch(() => {}), 2 * 60000); setTimeout(() => postMissedFinds().catch(() => {}), 20000);
|
||||
// weekly prizes: the week that just ended is awarded on the first tick after Sunday, Central
|
||||
setInterval(() => { try { social.awardDue(notify); } catch (e) { console.error('prizes', e.message); } }, 2 * 60000);
|
||||
setInterval(() => { Promise.resolve().then(() => social.awardDue(notify)).catch(e => console.error('prizes', e.message)); }, 2 * 60000);
|
||||
|
||||
server.listen(PORT, () => console.log(`PolHunter on :${PORT} — outbound: ${outbound() ? 'ON' : 'OFF'} — sign-ups: ${signupsOpen() ? 'open' : 'CLOSED'} — curtain: ${CURTAIN ? 'up' : 'down'} — sso: ${sso.enabled() ? 'on' : 'off'} — faucet: ${faucetOn ? faucet.address() + ' chain ' + (process.env.HUNT_CHAIN_ID || '?') : 'off'}`));
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// Game Pass checks for PolHunter (docs/GAME-PASS.md 3a), all local: a stub InstantAdPay on 127.0.0.1 answers polgrant and the
|
||||
// tournament endpoints; a mocked faucet records sends. Covers the grant client (fail closed, the retry queue, the 48 h alert),
|
||||
// finds and Ad Detective cases as 'daily' rewards (dropped at the cap, paid missions not gated, 'gp-wait' rows settled by the
|
||||
// queue), the perks (5 missions a day, a second case) and the Pass Tournament payer (pending -> paid, duplicate ignored, restart
|
||||
// re-report, send failure leaves the row pending and alerts, dry run, low balance). Production is never contacted.
|
||||
// Run: node test/gamepass.js
|
||||
'use strict';
|
||||
const http = require('http'), crypto = require('crypto'), fs = require('fs'), os = require('os'), path = require('path');
|
||||
process.env.GAMEPASS = 'on'; process.env.HUNT_SSO_SECRET = 'x'.repeat(48); delete process.env.HUNT_DRY_RUN;
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ph-gp-'));
|
||||
const store = require('../lib/store'); store.init(dir);
|
||||
const gp = require('../lib/polgrant'), rewards = require('../lib/rewards'), detective = require('../lib/detective'), tournament = require('../lib/tournament'), missions = require('../lib/missions');
|
||||
const SECRET = 'test-secret-'.padEnd(40, 'x'), GAME = 'polhunter';
|
||||
let pass = 0, fail = 0;
|
||||
const ok = (name, cond, info) => { if (cond) { pass++; console.log(' ok ', name); } else { fail++; console.log(' FAIL', name, info === undefined ? '' : JSON.stringify(info)); } };
|
||||
|
||||
(async () => {
|
||||
// ---- the stub IAP: polgrant (scripted by ref), tournament pending (a list we control) and paid (records the acks)
|
||||
const seen = [], acks = []; let mode = 'ok', pendingRows = []; const script = {};
|
||||
const stub = http.createServer((req, res) => { let raw = ''; req.on('data', c => raw += c); req.on('end', () => {
|
||||
const u = new URL(req.url, 'http://x');
|
||||
if (req.method === 'GET') { // the signed GET forms: player and tournament/pending
|
||||
const who = u.pathname.endsWith('/tournament/pending') ? 'tournament' : (Number(u.searchParams.get('m')) > 0 ? u.searchParams.get('m') : u.searchParams.get('e'));
|
||||
const want = crypto.createHmac('sha256', SECRET).update('player:' + who + ':' + u.searchParams.get('ts')).digest('hex');
|
||||
if (want !== u.searchParams.get('sig') || u.searchParams.get('game') !== GAME) { res.writeHead(401); return res.end('{"error":"bad sig"}'); }
|
||||
if (mode === '500') { res.writeHead(500); return res.end('boom'); }
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
if (u.pathname.endsWith('/tournament/pending')) return res.end(JSON.stringify({ rows: pendingRows.filter(r => !acks.some(a => a.id === r.id)) }));
|
||||
return res.end(JSON.stringify({ pass: { active: true, until: Date.now() + 86400000 }, memberId: 7 }));
|
||||
}
|
||||
const sig = crypto.createHmac('sha256', SECRET).update(req.headers['x-game-ts'] + '\n' + raw).digest('hex');
|
||||
if (sig !== req.headers['x-game-sig']) { res.writeHead(401, { 'Content-Type': 'application/json' }); return res.end('{"error":"bad signature"}'); }
|
||||
if (mode === '500') { res.writeHead(500); return res.end('boom'); }
|
||||
const b = JSON.parse(raw); if (b.game !== GAME) { res.writeHead(400); return res.end('{"error":"wrong game"}'); }
|
||||
if (u.pathname.endsWith('/tournament/paid')) { if (mode === 'ackfail') { res.writeHead(500); return res.end('x'); } acks.push(b); res.writeHead(200, { 'Content-Type': 'application/json' }); return res.end('{"ok":true}'); }
|
||||
seen.push(b); const s = script[b.ref] || { allowed: b.pol, deferred: 0 };
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ allowed: s.allowed, deferred: s.deferred || 0, carried: 0, pass: !!s.pass, capHit: s.capHit || null, day: '2026-10-16' }));
|
||||
}); });
|
||||
await new Promise(r => stub.listen(0, '127.0.0.1', r)); const port = stub.address().port;
|
||||
const alerts = []; const notify = async (k, p) => { alerts.push([k, p]); };
|
||||
gp.use({ game: GAME, secret: SECRET, iap: 'http://127.0.0.1:' + port, store, notify });
|
||||
|
||||
// ---- the client
|
||||
let r = await gp.grant({ memberId: 7, kind: 'daily', pol: 0.3, ref: 'd:1' }); ok('daily inside the cap: allowed = pol', r.allowed === 0.3 && r.retry === false);
|
||||
script['d:2'] = { allowed: 0.1, capHit: 'daily' }; r = await gp.grant({ memberId: 7, kind: 'daily', pol: 0.3, ref: 'd:2' }); ok('daily over the cap: dropped, capHit carried, the nudge names the Pass', r.allowed === 0.1 && r.capHit === 'daily' && /Get the Pass/.test(gp.note(r, 'daily', 0.3)));
|
||||
r = await gp.grant({ memberId: 0, email: 'nowallet@example.com', kind: 'daily', pol: 0.1, ref: 'd:e' }); ok('a wallet-less member is sent by email, memberId 0', r.allowed === 0.1 && seen.at(-1).email === 'nowallet@example.com');
|
||||
mode = '500'; r = await gp.grant({ memberId: 7, kind: 'daily', pol: 0.3, ref: 'd:5' }); ok('a 5xx fails closed', r.allowed === 0 && r.retry === true); mode = 'ok';
|
||||
gp.use({ iap: 'http://127.0.0.1:9' }); r = await gp.grant({ memberId: 7, kind: 'daily', pol: 0.3, ref: 'd:8' }); ok('an unreachable IAP fails closed', r.allowed === 0 && r.retry === true); gp.use({ iap: 'http://127.0.0.1:' + port });
|
||||
gp.use({ secret: 'wrong-secret-'.padEnd(40, 'y') }); r = await gp.grant({ memberId: 7, kind: 'daily', pol: 0.3, ref: 'd:7' }); ok('a rejected signature fails closed', r.allowed === 0 && r.retry === true); gp.use({ secret: SECRET });
|
||||
ok('a fresh cached flag is not refetched (10-minute TTL)', (await gp.fetchPass(7, 'hugh@example.com')).active === false);
|
||||
store.write('gamepass', {}); const p0 = await gp.fetchPass(7, 'hugh@example.com'); ok('with no cached flag the signed player GET fetches it', p0.active === true && gp.passOf(7, '').active);
|
||||
mode = '500'; gp.enqueue({ memberId: 7, ref: 'q:old', kind: 'daily', pol: 0.2, at: Date.now() - gp.GIVE_UP_MS - 1000 }); const rr = await gp.retry(async () => {}, Date.now() + gp.RETRY_MS + 1);
|
||||
ok('48 h without an answer: stuck, the admin chat told once', rr.stuck === 1 && alerts.some(a => a[0] === 'gpstuck')); gp.dequeue(7, '', 'q:old'); mode = 'ok'; alerts.length = 0;
|
||||
|
||||
// ---- finds: 'daily'; the account-wide cap decides; a 0 is recorded as a capped find (still today's find); paid missions are not gated
|
||||
rewards.setSettings({ minPol: 0.05, maxPol: 1, dailyCapPol: 20, missionsPerDay: 3 });
|
||||
const me = { memberId: 7, email: 'hugh@example.com', username: 'hugh', wallet: '0x' + 'a'.repeat(40) }, day = missions.ctDay();
|
||||
const m1 = { id: 'm1', site: 'example.com' }, m2 = { id: 'm2', site: 'two.com' }, mpaid = { id: 'adv', site: 'adv.com', paid: true, hunterPol: 0.2 };
|
||||
const q1 = rewards.quote(m1, true); ok('the quote is the draw inside the range', q1 >= 0.05 && q1 <= 1);
|
||||
const q0 = rewards.quote(m1, false); ok('the free tier draws on the small range (2026-11-02)', q0 >= 0.02 && q0 <= 0.1);
|
||||
let g = rewards.grant(me, m1, { pol: 0.03, nominal: q1, gp: { ref: 'find:m1:' + day, kind: 'daily' } });
|
||||
ok('a find pays what IAP allowed, due for the faucet', g.ok && g.rec.pol === 0.03 && g.rec.status === 'due' && g.rec.nominal === q1 && g.rec.gp.ref === 'find:m1:' + day);
|
||||
g = rewards.grant(me, m2, { pol: 0, nominal: 0.2, gp: { ref: 'find:m2:' + day, kind: 'daily', capHit: 'daily' } });
|
||||
ok('a find at the cap: recorded as capped, pays nothing, never reaches the faucet', g.capped && g.rec.status === 'capped' && g.rec.pol === 0 && !rewards.payable().some(p => p.id === g.rec.id));
|
||||
ok('a capped find still counts as today\'s find and completes the mission', rewards.findsToday(7) === 2 && rewards.completed(7, 'm2', me.wallet) && rewards.daily(7, new Set(), 0, 0, true).left === 1);
|
||||
const gw = rewards.grant(me, { id: 'm3', site: 'three.com' }, { pol: 0.4, status: 'gp-wait', nominal: 0.4, gp: { ref: 'find:m3:' + day, kind: 'daily', pending: true } });
|
||||
ok('IAP unreachable: the find is recorded as gp-wait, not payable yet', gw.waiting && gw.rec.status === 'gp-wait' && !rewards.payable().some(p => p.id === gw.rec.id));
|
||||
rewards.settleQueued(gw.rec.id, 0.25, { pass: false }); const settled = store.read('payouts', []).find(p => p.id === gw.rec.id);
|
||||
ok('the queue answer settles it: pays the allowed part, due', settled.pol === 0.25 && settled.status === 'due' && settled.gp.pending === false);
|
||||
rewards.settleQueued(gw.rec.id, 0.9, {}); ok('a settled row is not settled twice', store.read('payouts', []).find(p => p.id === gw.rec.id).pol === 0.25);
|
||||
const gpaid = rewards.grant(me, mpaid); ok('an advertiser-funded mission pays the advertiser\'s amount, ungated (no gp on the row)', gpaid.rec.pol === 0.2 && !gpaid.rec.gp && gpaid.rec.paid === true);
|
||||
ok('the perk: +2 missions a day with the pass', rewards.daily(7, new Set(), 0, 2, true).limit === 5 && rewards.daily(7, new Set(), 0, 0, true).limit === 3);
|
||||
ok('the free tier: one hunt a day without the pass (2026-11-02)', rewards.daily(7, new Set(), 0, 0, false).limit === 1 && rewards.daily(7, new Set(), 0, 0).limit === 1);
|
||||
|
||||
// ---- Ad Detective: the case is scored first, then IAP decides; a second case a day with the pass
|
||||
rewards.setSettings({ detectiveOn: 1, detectivePol: 0.15 });
|
||||
const gate = { ask: async (pol, ref) => { const a = await gp.grant({ memberId: 7, email: me.email, kind: 'daily', pol, ref }); a.note = gp.note(a, 'daily', pol); return a; }, wait: (rowId, pol, ref) => gp.enqueue({ memberId: 7, email: me.email, ref, kind: 'daily', pol, rowId }) };
|
||||
const mkBox = (id, status) => store.update('boxes', {}, all => { all[id] = { id, memberId: 7, day, missionId: 'm1', qid: 'q1', pol: 0.15, status, openedAt: Date.now(), shownAt: Date.now() }; return all; });
|
||||
store.update('detective-bank', [], all => { all.push({ id: 'q1', missionId: 'm1', q: 'What color?', options: ['Blue', 'Red', 'Green'], active: true }); return all; });
|
||||
mkBox('7:' + day, 'visited');
|
||||
const b1 = detective.getBox(7, day); const bank = store.read('detective-bank', [])[0];
|
||||
// find the choice index that maps to the right answer (option 0) under the box's shuffled order
|
||||
const orderOf = (box) => bank.options.map((o, i) => ({ i, k: crypto.createHmac('sha256', String(process.env.HUNT_CODE_SECRET || process.env.HUNT_SSO_SECRET || 'dev').trim()).update('det:' + box.id + ':' + bank.id + ':' + i).digest().readUInt32BE(0) })).sort((a, b) => a.k - b.k).map(x => x.i);
|
||||
script['detective:' + b1.id] = { allowed: 0.05, capHit: 'daily' };
|
||||
let a = await detective.answer(me, orderOf(b1).indexOf(0), gate);
|
||||
ok('a solved case pays what IAP allowed and tells the truth', a.ok && a.correct && a.pol === 0.05 && a.nominal === 0.15 && /Daily cap reached/.test(a.note) && seen.at(-1).ref === 'detective:' + b1.id && seen.at(-1).kind === 'daily', a);
|
||||
ok('no pass: the day\'s case is closed, no second box', detective.open(me, false).ok === true && detective.getBox(7, day).id === '7:' + day);
|
||||
// the perk: a second case once the first is closed (needs a live mission with an active question; fake the one check open() makes)
|
||||
store.update('missions', [], all => { all.push({ id: 'm1', site: 'example.com', name: 'Example', active: true, dwell: 30 }); return all; });
|
||||
store.update('payouts', [], all => { for (let i = 0; i < 3; i++) all.push({ id: 'f' + i, memberId: 7, day, missionId: 'x' + i, pol: 0.05, status: 'paid', at: Date.now() }); return all; }); // 3 finds today -> the box is earned
|
||||
const o2 = detective.open(me, true); ok('pass active: a second case opens with its own id', o2.ok && o2.box && o2.box.id === '7:' + day + ':2' && o2.box.second === true, o2);
|
||||
ok('the second box is now the current one, and a third is refused', detective.getBox(7, day).id === '7:' + day + ':2' && detective.open(me, true).box.id === '7:' + day + ':2');
|
||||
mode = '500'; store.update('boxes', {}, all => { all['7:' + day + ':2'].status = 'visited'; all['7:' + day + ':2'].shownAt = Date.now(); return all; });
|
||||
a = await detective.answer(me, orderOf(detective.getBox(7, day)).indexOf(0), gate);
|
||||
ok('IAP down while a case is solved: recorded as gp-wait, queued, the hunter told', a.ok && a.correct && a.waiting && a.pol === 0 && /recorded/.test(a.note) && gp.queued(7, me.email, 'detective:7:' + day + ':2'));
|
||||
mode = 'ok'; script['detective:7:' + day + ':2'] = { allowed: 0.15 };
|
||||
await gp.retry(async (item, resp) => { rewards.settleQueued(item.rowId, resp.allowed, {}); }, Date.now() + gp.RETRY_MS + 1);
|
||||
ok('the queued case pays on retry', !gp.queued(7, me.email, 'detective:7:' + day + ':2') && store.read('payouts', []).some(p => p.id === a.rec.id && p.pol === 0.15 && p.status === 'due'));
|
||||
process.env.GAMEPASS = 'off'; ok('GAMEPASS=off: a plain answer path still works', (await detective.answer(me, 0, null)).error === 'You already answered today’s case.'); process.env.GAMEPASS = 'on';
|
||||
|
||||
// ---- the Pass Tournament payer: PolHunter's faucet pays IAP's pending rows, never twice
|
||||
const sends = []; let sendMode = 'ok', bal = 10;
|
||||
const faucet = { address: () => '0x' + 'f'.repeat(40), balance: async () => bal, send: async (to, pol, onHash) => { if (sendMode === 'fail') throw new Error('nonce too low'); if (sendMode === 'hashThenCrash') { await onHash('0xhash-crash'); throw new Error('receipt lost'); } const tx = '0xtx' + sends.length; sends.push({ to, pol }); await onHash(tx); return { tx, ok: true }; } };
|
||||
let dry = false; tournament.init({ faucet, notify, dry: () => dry });
|
||||
pendingRows = [{ id: 'p1', week: '2026-W42', place: 1, email: 'a@example.com', memberId: 11, wallet: '0x' + '1'.repeat(40), pol: 0.5 }, { id: 'p2', week: '2026-W42', place: 2, email: 'b@example.com', memberId: 12, wallet: '0x' + '2'.repeat(40), pol: 0.3 }, { id: 'p3', week: '2026-W42', place: 3, email: 'c@example.com', memberId: 13, wallet: null, pol: 0.2 }];
|
||||
let st = await tournament.run();
|
||||
ok('pending rows are paid from the faucet and reported to IAP; the row without a wallet is a failure, not a payment', st.paid === 2 && st.acked === 2 && sends.length === 2 && sends[0].pol === 0.5 && sends[1].to === '0x' + '2'.repeat(40) && acks.length === 2 && acks[0].id === 'p1' && acks[0].tx === '0xtx0' && st.failures.length === 1 && /no wallet/.test(st.failures[0].error), st);
|
||||
ok('the claims file holds the hash per row', store.read('tourney-claims', {})['id:p1'].tx === '0xtx0' && store.read('tourney-claims', {})['id:p1'].acked > 0);
|
||||
ok('the admin chat heard about each prize', alerts.filter(a => a[0] === 'tourneypaid').length === 2);
|
||||
st = await tournament.run(); ok('a second run pays nothing new (IAP no longer lists them)', st.paid === 0 && sends.length === 2);
|
||||
// IAP still lists a row that was paid (its ack was lost): re-report the hash, never re-send
|
||||
acks.length = 0; st = await tournament.run(); ok('a paid row IAP still lists is re-reported, not re-sent', sends.length === 2 && st.acked === 2 && st.paid === 0 && acks.length === 2);
|
||||
// a fresh row while the send fails: the row stays pending, the claim is released, the admin chat alerted
|
||||
pendingRows.push({ id: 'p4', week: '2026-W43', place: 1, email: 'd@example.com', memberId: 14, wallet: '0x' + '4'.repeat(40), pol: 0.4 }); sendMode = 'fail'; alerts.length = 0;
|
||||
st = await tournament.run(); ok('a send failure leaves the row pending and alerts', st.paid === 0 && st.failures.some(f => /nonce too low/.test(f.error)) && alerts.some(a => a[0] === 'tourneyfail') && !acks.some(a => a.id === 'p4') && !store.read('tourney-claims', {})['id:p4'].tx);
|
||||
sendMode = 'ok'; st = await tournament.run(); ok('the next run pays it (the claim was released)', st.paid === 1 && acks.some(a => a.id === 'p4'));
|
||||
// a fresh claim by "another app copy" within the TTL is respected (deploy overlap)
|
||||
pendingRows.push({ id: 'p5', week: '2026-W43', place: 2, email: 'e@example.com', memberId: 15, wallet: '0x' + '5'.repeat(40), pol: 0.1 });
|
||||
store.update('tourney-claims', {}, all => { all['id:p5'] = { claimedAt: Date.now(), week: '2026-W43', place: 2, wallet: '0x' + '5'.repeat(40), pol: 0.1 }; return all; });
|
||||
st = await tournament.run(); ok('a row another copy claimed moments ago is skipped, not paid twice', st.skipped >= 1 && !sends.some(s => s.to === '0x' + '5'.repeat(40)));
|
||||
store.update('tourney-claims', {}, all => { all['id:p5'].claimedAt = Date.now() - tournament.CLAIM_TTL - 1; return all; });
|
||||
st = await tournament.run(); ok('after the claim TTL with no hash, the row is paid', sends.some(s => s.to === '0x' + '5'.repeat(40)) && acks.some(a => a.id === 'p5'));
|
||||
// the chain has the hash but the receipt was lost: never re-sent, reported next run
|
||||
pendingRows.push({ id: 'p6', week: '2026-W43', place: 3, email: 'f@example.com', memberId: 16, wallet: '0x' + '6'.repeat(40), pol: 0.1 }); sendMode = 'hashThenCrash';
|
||||
st = await tournament.run(); ok('a hash recorded before the crash is kept', store.read('tourney-claims', {})['id:p6'].tx === '0xhash-crash' && st.failures.some(f => /receipt unknown/.test(f.error)));
|
||||
sendMode = 'ok'; const n0 = sends.length; st = await tournament.run(); ok('the next run only reports that hash', sends.length === n0 && acks.some(a => a.id === 'p6' && a.tx === '0xhash-crash'));
|
||||
// dry run and low balance
|
||||
dry = true; pendingRows.push({ id: 'p7', week: '2026-W44', place: 1, email: 'g@example.com', memberId: 17, wallet: '0x' + '7'.repeat(40), pol: 0.9 });
|
||||
st = await tournament.run(); ok('HUNT_DRY_RUN: records what it would pay, sends nothing', st.wouldPay === 0.9 && st.paid === 0 && !sends.some(s => s.to === '0x' + '7'.repeat(40)) && store.read('tourney-claims', {})['id:p7'].dry === true);
|
||||
st = await tournament.run(); ok('a dry-run row is not re-claimed', st.skipped >= 1 && st.wouldPay === 0.9);
|
||||
dry = false; store.update('tourney-claims', {}, all => { delete all['id:p7']; return all; }); bal = 0.5; alerts.length = 0;
|
||||
st = await tournament.run(); ok('a low balance leaves the row pending and alerts once', st.paid === 0 && st.failures.some(f => /low balance/.test(f.error)) && alerts.some(a => a[0] === 'low' && a[1].tournament) && !store.read('tourney-claims', {})['id:p7'].tx);
|
||||
bal = 10; st = await tournament.run(); ok('topped up: paid', acks.some(a => a.id === 'p7'));
|
||||
process.env.GAMEPASS = 'off'; st = await tournament.run(); ok('GAMEPASS=off: the payer is inert', st.on === false && st.pending === 0); process.env.GAMEPASS = 'on';
|
||||
const view = tournament.state(); ok('the admin sees last run, totals and claims', view.last && view.paidTotal >= 5 && view.claims.length >= 6 && view.recent.length >= 1);
|
||||
|
||||
stub.close(); console.log(`\n${pass} passed, ${fail} failed`); process.exit(fail ? 1 : 0);
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
@@ -0,0 +1,155 @@
|
||||
// The Network Tour (Marty 2026-11-17): mission rotation per hunter and the free tier's tour stops, end to end on a local
|
||||
// boot with GAMEPASS=on against a stub InstantAdPay (player, polgrant, credits). Production is never contacted.
|
||||
// Covers: round progression and reset, a mission added mid-round, a paused mission, never-visited first then least
|
||||
// recently found, the start gate, the Full Network Tour badge once per round, discovery pays POL for a free member,
|
||||
// a repeat after the full tour is a tour stop (credits, no POL), a new mission pays POL once, Game Pass holders
|
||||
// unchanged, tour-stop credits capped per day and idempotent on ref, daily limits unchanged.
|
||||
// Run: node test/rotation.js
|
||||
'use strict';
|
||||
const { spawn } = require('child_process');
|
||||
const http = require('http'), crypto = require('crypto'), path = require('path'), fs = require('fs');
|
||||
|
||||
const PORT = 8897, DIR = path.join(__dirname, '..', 'data-test-rot'), SECRET = 'r'.repeat(48);
|
||||
fs.rmSync(DIR, { recursive: true, force: true });
|
||||
let fails = 0;
|
||||
const eq = (a, b, m) => { const ok = JSON.stringify(a) === JSON.stringify(b); console.log((ok ? ' ok ' : ' FAIL ') + m + (ok ? '' : ' -> got ' + JSON.stringify(a) + ' want ' + JSON.stringify(b))); if (!ok) fails++; };
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
const B = 'http://127.0.0.1:' + PORT, ORG = { Origin: 'http://127.0.0.1:' + PORT };
|
||||
const DAY = 86400000, ctDay = t => new Date(t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
|
||||
// ---- the stub InstantAdPay: pass flags per member, polgrant answers allowed = pol, credits once per ref
|
||||
const PASS = { 102: true }; const creditCalls = []; const granted = new Map();
|
||||
const stub = http.createServer((req, res) => { let raw = ''; req.on('data', c => raw += c); req.on('end', () => {
|
||||
const u = new URL(req.url, 'http://x'); const send = (c, o) => { res.writeHead(c, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(o)); };
|
||||
if (req.method === 'GET') { const m = Number(u.searchParams.get('m')); return send(200, { ok: true, memberId: m, pass: { active: !!PASS[m], until: PASS[m] ? Date.now() + 7 * DAY : null } }); }
|
||||
const sig = crypto.createHmac('sha256', SECRET).update(req.headers['x-game-ts'] + '\n' + raw).digest('hex');
|
||||
if (sig !== req.headers['x-game-sig']) return send(401, { error: 'bad signature' });
|
||||
const b = JSON.parse(raw);
|
||||
if (u.pathname === '/api/partner/credits') { creditCalls.push(b); if (granted.has(b.ref)) return send(200, { ok: true, repeat: true, credits: granted.get(b.ref) }); granted.set(b.ref, b.credits); return send(200, { ok: true, credits: b.credits }); }
|
||||
if (u.pathname === '/api/partner/polgrant') return send(200, { allowed: b.pol, deferred: 0, carried: 0, pass: !!PASS[b.memberId], day: ctDay(Date.now()) });
|
||||
send(404, { error: 'no' });
|
||||
}); });
|
||||
|
||||
let child; const jars = {};
|
||||
const call = async (who, p, opt = {}) => {
|
||||
const res = await fetch(B + p, Object.assign({ redirect: 'manual' }, opt, { headers: Object.assign({ Cookie: jars[who] || '', 'Content-Type': 'application/json' }, opt.headers || {}) }));
|
||||
const sc = res.headers.get('set-cookie'); if (sc && /ph\.sid=/.test(sc)) jars[who] = sc.split(';')[0];
|
||||
let body = null; try { body = await res.json(); } catch (e) {} return { status: res.status, body };
|
||||
};
|
||||
const admin = (p, body) => call('admin', p, { method: body ? 'POST' : 'GET', body: body ? JSON.stringify(body) : undefined, headers: { 'X-Admin-Key': 'adminkey123' } });
|
||||
const mission = (id, extra) => admin('/api/admin/mission', Object.assign({ id, site: 'Site ' + id.toUpperCase(), name: 'Find ' + id, brief: 'x', url: B + '/index.html', dwell: 5, slots: 1 }, extra || {}));
|
||||
const PF = path.join(DIR, 'payouts.json');
|
||||
const readP = () => { try { return JSON.parse(fs.readFileSync(PF, 'utf8')); } catch (e) { return []; } };
|
||||
const writeP = all => fs.writeFileSync(PF, JSON.stringify(all));
|
||||
// a past find, written straight onto the ledger (history the hunter already has)
|
||||
const past = (memberId, missionId, daysAgo, wallet) => { const all = readP(); const at = Date.now() - daysAgo * DAY; all.push({ id: 'h' + memberId + missionId + daysAgo, memberId, wallet, missionId, site: 'Site ' + missionId.toUpperCase(), pol: 0.05, day: ctDay(at), at, status: 'paid' }); writeP(all); };
|
||||
// move a member's finds of a mission to yesterday (so the once-a-day rule does not hide what the rotation does)
|
||||
const toYesterday = (memberId, missionId) => { const all = readP(); for (const p of all) if (p.memberId === memberId && p.missionId === missionId) p.day = ctDay(Date.now() - DAY); writeP(all); };
|
||||
// a real find: start, wait the dwell, read the code from the embed, submit
|
||||
async function find(who, missionId) {
|
||||
const st = await call(who, '/api/my/start', { method: 'POST', body: JSON.stringify({ missionId }) }); if (st.status !== 200) return st;
|
||||
await sleep(5300); const code = await (await fetch(B + '/api/embed/code?t=' + st.body.token, { headers: ORG })).json();
|
||||
return call(who, '/api/my/submit', { method: 'POST', body: JSON.stringify({ token: st.body.token, code: code.code }) });
|
||||
}
|
||||
const signIn = (who, memberId, pass) => call(who, '/auth?t=' + sso.mint({ memberId, email: 'h' + memberId + '@example.com', wallet: '0x' + String(memberId).padStart(40, '0'), username: 'hunter' + memberId, gamePass: { active: !!pass, until: pass ? Date.now() + 7 * DAY : null } }));
|
||||
let sso;
|
||||
|
||||
(async () => {
|
||||
await new Promise(r => stub.listen(0, '127.0.0.1', r));
|
||||
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DIR, HUNT_SSO_SECRET: SECRET, ADMIN_KEY: 'adminkey123', SIGNUPS: 'open', SITE_URL: B, GAMEPASS: 'on', IAP_URL: 'http://127.0.0.1:' + stub.address().port });
|
||||
delete env.CURTAIN; delete env.OUTBOUND; delete env.HUNT_WALLET_KEY; delete env.HUNT_RPC;
|
||||
child = spawn(process.execPath, [path.join(__dirname, '..', 'server.js')], { env, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
child.stderr.on('data', d => process.stderr.write(d));
|
||||
for (let i = 0; i < 120; i++) { try { await fetch(B + '/health'); break; } catch (e) { await sleep(500); } }
|
||||
process.env.HUNT_SSO_SECRET = SECRET; sso = require('../lib/sso');
|
||||
|
||||
for (const id of ['a', 'b', 'c']) await mission(id);
|
||||
await signIn('free', 101, false); await signIn('pass', 102, true);
|
||||
|
||||
// ---- limits unchanged: the free tier is 1 a day, the Game Pass 3 + 2 = 5, rotation on by default
|
||||
let bf = await call('free', '/api/my/board'), bp = await call('pass', '/api/my/board');
|
||||
eq([bf.body.daily.limit, bp.body.daily.limit, bf.body.tour.on, bf.body.tour.total, bf.body.tour.done, bf.body.tour.round], [1, 5, true, 3, 0, 1], 'limits unchanged (free 1, Pass 5); rotation on; tour 0 of 3, round 1');
|
||||
eq(bf.body.tour.left.slice().sort(), ['Site A', 'Site B', 'Site C'], 'the board lists the sites left this round by name');
|
||||
await admin('/api/admin/settings', { freeMissionsPerDay: 10 }); // room for several finds in one test day (restored below)
|
||||
|
||||
// ---- discovery pays POL for a free member
|
||||
let r = await find('free', 'a');
|
||||
eq([r.status, r.body.pol >= 0.02 && r.body.pol <= 0.1, !!r.body.tourStop], [200, true, false], 'free member, first find of a mission: POL on the free draw, not a tour stop');
|
||||
bf = await call('free', '/api/my/board');
|
||||
eq([bf.body.tour.done, bf.body.tour.left.includes('Site A'), bf.body.missions.find(m => m.id === 'a').done], [1, false, true], 'round progress: 1 of 3, Site A off the list, shown as done today');
|
||||
|
||||
// ---- the start gate: found earlier in this round = refused, even on a new day
|
||||
toYesterday(101, 'a');
|
||||
r = await call('free', '/api/my/start', { method: 'POST', body: JSON.stringify({ missionId: 'a' }) });
|
||||
eq([r.status, r.body.tour], [400, true], 'a mission found earlier this round cannot be started again (rotation)');
|
||||
bf = await call('free', '/api/my/board'); eq(bf.body.missions.map(m => m.id).includes('a'), false, 'and the board does not offer it');
|
||||
|
||||
// ---- a paused mission is skipped and never blocks the round; finishing the rest closes it
|
||||
const ms = (await admin('/api/admin/state')).body.missions; const mc = ms.find(m => m.id === 'c');
|
||||
await mission('c', { active: false, dwell: mc.dwell, slots: mc.slots });
|
||||
bf = await call('free', '/api/my/board'); eq([bf.body.tour.total, bf.body.tour.left], [2, ['Site B']], 'paused mission c is out of the round: 1 of 2, only Site B left');
|
||||
r = await find('free', 'b');
|
||||
eq([r.status, r.body.round, r.body.unlocked.includes('sweep')], [200, 1, true], 'finishing the round: round 1 closed, Full Network Tour celebrated');
|
||||
bf = await call('free', '/api/my/board');
|
||||
eq([bf.body.tour.round, bf.body.tour.rounds, bf.body.tour.done, bf.body.badges.some(b => b.id === 'sweep' && b.name === 'Full Network Tour')], [2, 1, 0, true], 'reset: round 2 starts at 0, the badge reads Full Network Tour');
|
||||
|
||||
// ---- a mission added (or back) mid-round joins as not done, never-visited first
|
||||
await mission('c', { active: true });
|
||||
bf = await call('free', '/api/my/board');
|
||||
eq([bf.body.tour.total, bf.body.missions[0].id, bf.body.missions[0].fresh], [3, 'c', true], 'mission c back mid-round: part of round 2, offered first as never visited');
|
||||
eq(bf.body.tour.toured, false, 'not toured yet: c was never found');
|
||||
r = await find('free', 'c');
|
||||
eq([r.status, r.body.pol > 0, !!r.body.tourStop], [200, true, false], 'a mission new to this free member pays POL on the first find');
|
||||
bf = await call('free', '/api/my/board');
|
||||
eq([bf.body.tour.toured, bf.body.tour.free, bf.body.missions.filter(m => !m.done).every(m => m.tourStop && m.tourStop.credits === 10)], [true, true, true], 'every active mission found once: toured; the open cards read as tour stops worth 10 credits');
|
||||
|
||||
// ---- after the full tour a free member's repeat is a tour stop: credits, not POL; capped at the daily max
|
||||
toYesterday(101, 'b');
|
||||
const before = creditCalls.length;
|
||||
r = await find('free', 'a');
|
||||
eq([r.status, r.body.pol, r.body.tourStop && r.body.tourStop.credits, /Tour stop/.test(r.body.message)], [200, 0, 10, true], 'repeat after the full tour: a tour stop, 0 POL, +10 ad credits');
|
||||
await sleep(400);
|
||||
const stopRow = readP().find(p => p.memberId === 101 && p.tourStop);
|
||||
eq([creditCalls.length - before, creditCalls.at(-1) && creditCalls.at(-1).credits, creditCalls.at(-1) && creditCalls.at(-1).ref, stopRow.status, stopRow.pol, stopRow.tourStop.state], [1, 10, 'tour:' + stopRow.id, 'tour', 0, 'sent'], 'one signed credits call, ref tour:<row id>, row is a 0 POL tour stop marked sent');
|
||||
eq(readP().filter(p => p.memberId === 101 && p.missionId === 'a').map(p => p.status), ['due', 'tour'], 'mission a: the discovery drip (due) and the tour stop, no second POL drip');
|
||||
r = await find('free', 'b');
|
||||
eq([r.status, r.body.pol, r.body.tourStop.credits, r.body.round], [200, 0, 0, 2], 'second tour stop the same day: credits capped at the daily max (0 more), and it closes round 2');
|
||||
await sleep(300); eq(creditCalls.length - before, 1, 'no credits call for a capped stop');
|
||||
// idempotent on ref: a stop sent again (a retry) is answered as a repeat and never granted twice
|
||||
{ process.env.GAMEPASS = 'on'; const store = require('../lib/store'); store.init(DIR); const gp = require('../lib/polgrant'); const rot = require('../lib/rotation');
|
||||
gp.use({ game: 'polhunter', secret: SECRET, iap: 'http://127.0.0.1:' + stub.address().port, store });
|
||||
rot.markStop(stopRow.id, { state: 'due' }); const again = await rot.deliver(readP().find(p => p.id === stopRow.id), gp);
|
||||
eq([again.tourStop.state, granted.get('tour:' + stopRow.id), [...granted.values()].reduce((a, b) => a + b, 0)], ['sent', 10, 10], 'a retried stop reuses its ref: 10 credits granted once in total');
|
||||
const capped = rot.tourStop({ memberId: 101, email: 'h101@example.com', wallet: '0x' + '101'.padStart(40, '0') }, { id: 'zz', site: 'Z' });
|
||||
eq([capped.tourStop.credits, capped.tourStop.state], [0, 'none'], 'the daily max holds at the library too (10 already granted today)'); }
|
||||
|
||||
// ---- a newly added mission pays POL again to a toured free member, once
|
||||
await mission('d');
|
||||
bf = await call('free', '/api/my/board'); eq([bf.body.tour.toured, bf.body.missions[0].id], [false, 'd'], 'new mission d: no longer toured, d offered first');
|
||||
r = await find('free', 'd'); eq([r.status, r.body.pol > 0, !!r.body.tourStop], [200, true, false], 'the new mission pays POL on the first find');
|
||||
|
||||
// ---- never visited first, then least recently found (member 103, history only)
|
||||
past(103, 'a', 4, '0x' + '103'.padStart(40, '0')); past(103, 'b', 3, '0x' + '103'.padStart(40, '0')); past(103, 'c', 2, '0x' + '103'.padStart(40, '0')); past(103, 'd', 5, '0x' + '103'.padStart(40, '0'));
|
||||
await signIn('h103', 103, true); await call('h103', '/api/my/board'); await mission('e');
|
||||
const b3 = await call('h103', '/api/my/board');
|
||||
eq([b3.body.tour.rounds, b3.body.missions.map(m => m.id)], [1, ['e', 'd', 'a', 'b', 'c']], 'a whole history closes round 1; round 2 order: never visited (e), then least recently found (d, a, b, c)');
|
||||
|
||||
// ---- Game Pass holders unchanged: a repeat pays POL on the full draw
|
||||
past(102, 'a', 3, '0x' + '102'.padStart(40, '0')); past(102, 'b', 3, '0x' + '102'.padStart(40, '0')); past(102, 'c', 3, '0x' + '102'.padStart(40, '0')); past(102, 'd', 3, '0x' + '102'.padStart(40, '0')); past(102, 'e', 3, '0x' + '102'.padStart(40, '0'));
|
||||
r = await find('pass', 'a');
|
||||
eq([r.status, r.body.pol >= 0.05 && r.body.pol <= 1, !!r.body.tourStop], [200, true, false], 'Game Pass holder repeat: POL on the full draw, never a tour stop');
|
||||
|
||||
// ---- rotation off: everything is offered again (the old board), the badge stays
|
||||
toYesterday(101, 'd'); const on1 = await call('free', '/api/my/board');
|
||||
await admin('/api/admin/settings', { rotationOn: 0 });
|
||||
bf = await call('free', '/api/my/board'); eq([on1.body.missions.some(m => m.id === 'd'), bf.body.tour.on, bf.body.missions.some(m => m.id === 'd' && !m.done)], [false, true && false, true], 'rotationOn 0: no progress panel, a mission found this round is offered again');
|
||||
await admin('/api/admin/settings', { rotationOn: 1, freeMissionsPerDay: 1 });
|
||||
bf = await call('free', '/api/my/board'); eq(bf.body.daily.limit, 1, 'free tier back to 1 a day');
|
||||
|
||||
// ---- admin: round stats per hunter
|
||||
const av = await admin('/api/admin/rotation'); const h101 = av.body.hunters.find(h => h.memberId === 101);
|
||||
eq([av.status, h101.rounds, av.body.settings.credits, av.body.settings.dailyMax, av.body.tourStops.creditsSent], [200, 2, 10, 10, 10], 'admin: rounds per hunter, settings 10 / 10, 10 credits sent');
|
||||
|
||||
console.log(fails ? '\nFAILURES: ' + fails : '\nALL ROTATION CHECKS PASS');
|
||||
child.kill(); stub.close(); fs.rmSync(DIR, { recursive: true, force: true }); process.exit(fails ? 1 : 0);
|
||||
})().catch(e => { console.error('CRASH', e); if (child) child.kill(); process.exit(1); });
|
||||
+2
-1
@@ -24,7 +24,8 @@ const admin = (p, opt = {}) => call(p, Object.assign(opt, { headers: { 'X-Admin-
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
(async () => {
|
||||
await sleep(1200);
|
||||
// wait for the server to listen (a busy machine can take well over a second to load ethers)
|
||||
for (let i = 0; i < 120; i++) { try { await fetch(B + '/health'); break; } catch (e) { await sleep(500); } }
|
||||
process.env.HUNT_SSO_SECRET = env.HUNT_SSO_SECRET; const sso = require('../lib/sso');
|
||||
const h = await call('/health'); eq([h.body.outbound, h.body.signups, h.body.faucet, h.body.sso], [false, true, false, true], 'posture: outbound off, signups open, faucet off, sso on');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user