Game POL pays to any LINKED wallet (Marty approved "build all three", 2026-10-27)
- walletnudge.js: the hourly push hands the member's signature-linked wallet (accounts.address, only set by auth.verifyChallenge -> accounts.linkWallet) to every game holding an unpaid balance, activated or not; memberId is the on-chain id when there is one, else 0 (a failed chain read falls back to the stored id instead of skipping the row). Holding-tank members waiting to switch on payouts no longer have their game POL stuck. Game side unchanged contract: signed POST, fill-empty-only (different wallet = 409, retried once a day), idempotent. - Nudge copy (no linked wallet only): "You've earned X POL in <game>. Link your wallet (one free signature) and it's sent automatically, including everything you've earned so far." + /my#wallet; never mentions switching on payouts. - The IAP -> game /auth tokens already carried wallet: a.address regardless of activation (no change). - chatbot.js: game-pol-wallet canned answer (ahead of the per-game entries) + GAME POL TO ANY LINKED WALLET prompt fact - qa/walletnudge.test.cjs (mock game: non-activated push with memberId 0, activated push, chain-read failure, nudge copy, 409 refusal + daily retry), wired into qa/run.sh member + walletnudge; chatbot-parse routing cases for the new answer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,10 @@ const CANNED = [
|
||||
{ id: 'game-pass', title: 'Game Pass and daily POL caps', q: ['What is the Game Pass?', 'Why did I hit the daily POL cap in the games?', 'Does a boss reward carry over to the next day?'], tags: ['games', 'game pass', 'daily cap', 'tournament'],
|
||||
re: /(game ?pass|pass tournament|daily (pol )?cap|pol cap|cap(ped|s)? (on|in|for) (the )?games?|hit (the|my|today.s) (free )?cap|carr(y|ied) (over|forward))/i,
|
||||
a: 'The Game Pass is $5 for 7 days and covers all nine games on your InstantAdPay account (linked positions included). Free play keeps paying real POL every day; the Pass plays more: higher daily POL caps across every game (1.50 POL a day on repeatable rewards instead of 0.30, and 5 POL a day in all instead of 2), a seat in the weekly Pass Tournament (POL prizes from 5% of pass sales, settled Mondays, top 3 posted to Game Achievements), extra plays or a perk in each game, and the gold Game Pass badge with your name. Per game: PolHunter 5 missions a day instead of 3 plus 2 Ad Detective cases; Gem Kingdom one free continue a day; Spooky Doors one extra door a day; ClutterHunt 2 bonus hints a day; SpellWheel daily streak 0.30 POL instead of 0.15 plus 1 free hint a day; PolyBreak daily gem limit 1.5 POL instead of 0.5 plus an extra paddle every round; PolyWarriors a 4th daily mission and defense pays 25 Circuits instead of 15; Drip Runner a free shield at the start of every run; Road Agent 2 patrols a day and 25% more scrap. The full list is on the Game Pass card. Caps are account-wide and reset at midnight Central. A one-time progress reward (a boss, a chapter, a sector) is never lost: whatever is over the day\u2019s total carries to the next day until it is paid in full; repeatable daily play over the daily cap is simply not paid that day. The Pass never changes how much any reward pays, so it is more game, not more payback. Get it in Members > Games > Game Pass: every pass is paid by a NEW package purchase of $5 or more. Tap Get the Pass, then buy the package; the pass starts the moment that purchase settles on chain. Your sponsor and team are paid from that package as usual, and you keep every credit of the package for your ads. Credits you already hold (earned or purchased) never buy a pass, and a package bought before you tapped Get the Pass does not count. Buying again while a pass is active adds 7 days.' },
|
||||
// game POL to any linked wallet (Marty, 2026-10-27, "build all three"): sits ahead of the per-game entries so "my Gem Kingdom POL never came" lands here
|
||||
{ id: 'game-pol-wallet', title: 'Getting your game POL (link your wallet)', q: ['Why was my game POL not sent?', 'It says POL is waiting for my wallet', 'Do I need to switch on payouts to get game POL?'], tags: ['games', 'game pol', 'link wallet', 'waiting for your wallet', 'not sent'],
|
||||
re: /(pol (is )?waiting for (my |your |a )?wallet|link (my |your |a )?wallet to (receive|get)|(game|games|gem ?kingdom|drip ?runner|clutter ?hunt|spooky ?doors|road ?agent|poly ?break|spell ?wheel|poly ?warriors?)\b[^.?!]{0,60}\bpol\b[^.?!]{0,40}\b(not (been )?(paid|sent)|never (paid|sent|arrived|came)|stuck|waiting|pending|switch on|activat\w*)|(switch on|turn on|activate) payouts?[^.?!]{0,40}\b(game|games)\b[^.?!]{0,20}\bpol\b)/i,
|
||||
a: 'Game POL is paid to the wallet linked to your InstantAdPay account. Linking is one free signature on your Wallet tab (https://instantadpay.com/my#wallet): it is not a transaction and it cannot move funds. Once your wallet is linked, every game sends your POL automatically, usually within the hour, including everything you earned before you linked it (each game still pays once your balance reaches the payout line shown in that game). You do not need to switch on payouts for game POL: a linked wallet is paid even before it is activated, so a member waiting in the holding tank for a sponsor still gets their game POL. If a game already has a different wallet on file for you, it keeps paying that one; open Help if that needs changing.' },
|
||||
{ id: 'road-agent', title: 'Road Agent (night-highway shooter)', q: ['What is Road Agent?', 'How do fuel stops work in Road Agent?'], tags: ['games', 'road agent', 'fuel stop'],
|
||||
re: /(road ?agent|night.?highway|fuel stop|weapons truck)/i,
|
||||
a: 'Road Agent is the network’s night-highway shooter, live since October 15 for every member: Games tab > Road Agent > Play, or roadagent.app with your InstantAdPay email. First clear of each sector pays POL to the wallet on your InstantAdPay account, plus a daily patrol reward. Fuel comes from a sponsor visit (a fuel stop), which is a normal verified visit, so advertisers’ visits campaigns get traffic from the game automatically.' },
|
||||
@@ -312,6 +316,7 @@ ${passTiersFact()}${refuelFact()}${synFact()}- ROAD AGENT (LIVE 2026-10-15, http
|
||||
- CLUTTERHUNT (LIVE 2026-10-03, https://clutterhunt.com, in Members > Games): a free hidden-object game. Search cozy, cluttered rooms for 12 hidden objects plus one sponsored find (a sealed letter with a sponsor's name; tapping it shows their ad). Rooms change with the seasons: the Haunted Manor (Attic, Library, Witch's Kitchen, Wizard's Study, Moonlit Greenhouse, Wine Cellar) through Oct 31, then new seasonal rooms. Objects move every round. Stars: finish under 3 minutes, use at most 1 hint, at most 6 wrong taps. 2 free hints a round; after that a short verified visit to a member's page earns a hint (shares the daily refuel allowance). Sign in with the InstantAdPay account right inside the game to save stars. PAYS POL since 2026-10-04: fixed rewards per room each season for the first clear and the first 3-star clear (more for Expert rooms, which unlock after all six rooms), collected in the ClutterHunt balance and sent automatically to the wallet on the member's InstantAdPay account once it reaches the payout amount. Players who cleared rooms before 10-04 can replay each room once to collect. NEVER state a maximum or total a player can earn (Marty's rule) and never promise earnings.
|
||||
- SPOOKY DOORS (Halloween season game, 2026-10-02): https://spookydoors.com, open 2026-10-04 through Halloween night (closes at midnight Central at the end of Oct 31); its Games tab card shows only during the season, with a "Limited time, ends Oct 31" ribbon. Members sign in with one tap from Members > Games. Walk the street, collect candy, avoid black cats and bats, knock on doors. Each door is a verified visit to a member's page or ad (a member video once every page has been visited), the advertiser is charged as for any visit, the player gets candy not credits; 15 doors per Central day, separate from the 20 Earn-tab visits and the 20 Drip Runner refuels. A treat is 10 candy; about 1 door in 5 is a trick (a ghost or skeleton you tap 5 times quickly; beat it for a 3 candy bonus, miss it for half the treat). If no paid ad is left for that player, the door shows a house ad for one of our own programs: a smaller treat (5 candy), and it still counts toward the 15 doors. CANDY LADDER pays POL once per rung: 100 candy 0.1 POL, 250 0.25, 500 0.5, 1,000 1, 2,000 2 (Halloween 2026 badge at 500), paid from a season pool funded by a share of door ad spend and costume sales, only while the pool covers it; the game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. COSTUMES bought with ad credits like Gem Kingdom Crowns: witch free, vampire 300 credits (longer trick timer), bedsheet ghost 300 (black cats ignore you), Lucky caramel apple 500 (+2 candy per treat); no cash value. Top 20 by candy on the season leaderboard. DOOR PACKS: creating a verified-visits campaign, the advertiser picks Everywhere (3 credits per visit, as before), Behind Spooky Doors (4 credits per door) or Golden Spooky Door (6 credits per door; the player gets +2 bonus candy). Paid up front like any visit pack. Door packs are served first on doors (Golden Doors before door packs), each player sees a pack at most once per Central day, they never run on the Earn tab or refuels during the season, and from Nov 1 any doors left run as normal visits; the campaign shows doors opened and unique players. Never promise earnings or call it income.
|
||||
- GEM KINGDOM (LIVE in the Games tab since 2026-10-02): Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon's Peak, the Sunken Reef, the Shadow Citadel), earn stars, and rebuild your Stronghold and forge weapons. It pays POL for FIRST clears only (stages 0.02 to 0.15 POL rising by chapter; bosses 0.25, 0.5, 2, 5, 7.5 and 10 POL for the Goblin King, Ice Queen, Bog Witch, Ember Dragon, Kraken and Shadow King); replays pay nothing. The game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. Rewards come from a pool funded by a share of Crown purchases and pay only while the pool has funds; never promise earnings or call it income. No referral bonus on game clears. Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game's Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. Never promise an amount beyond the posted rewards. (2026-10-03) FREE REVIVE: after a defeat, a short verified visit to a member's page (InstantAdPay verified-visit flow inside the game, shares the 20-a-day refuel allowance with Drip Runner) revives the party once per battle; a revived win earns at most 2 stars. SPECIALS in the Crown shop: Hero Bundle (one time, $5 = 500 credits: a tier-1 forge weapon, one building level, 60 Crowns), Kingdom Pass ($10 = 1,000 credits for 30 days: 10 Crowns a day credited on the first visit each Central day, a 25-Crown chest every 7 days, the three Royal hero looks; no auto-renew, buying again adds 30 days), Hero looks (cosmetic only: Halloween looks Pumpkin Knight, Moon Witch, Scarecrow Ranger for 40 Crowns each, sold through Oct 31 and kept forever; Royal looks with the Pass). Only the purchased-credit part of a purchase funds the POL reward pool.
|
||||
- GAME POL TO ANY LINKED WALLET (2026-10-27, Marty): game POL (Drip Runner, Gem Kingdom, ClutterHunt, Spooky Doors, Road Agent, PolyBreak, SpellWheel, PolyWarriors) is paid to the wallet LINKED to the member's InstantAdPay account (one free signature on the Wallet tab, https://instantadpay.com/my#wallet). Activation is NOT needed: a linked wallet that has not switched on payouts (for example a holding-tank member waiting for a sponsor) is paid too. InstantAdPay hands the linked wallet to every game where the member has a balance (hourly, and on every sign-in to a game), and the game sends the POL on its own sweep once the balance reaches that game's payout line, including everything earned before the link. A game that already holds a different wallet keeps paying that one (it is never replaced automatically). Players with no linked wallet get at most three reminders ("X POL is waiting for your wallet": link your wallet, one free signature, and it's sent automatically, including everything you've earned so far), and in the games the reward screen says "Link your wallet to receive this POL" with the same link. Never tell a member to switch on payouts to get game POL.
|
||||
- GAMES TAB (2026-10-01): Members > Games (/my#games) shows one card per network game (as of 2026-10-15: PolHunter, Drip Runner, Gem Kingdom, ClutterHunt, SpellWheel, PolyWarriors, PolyBreak, Road Agent, Spooky Doors during Halloween; all pay POL to the member's InstantAdPay wallet), with their own progress and a Play button that signs them in with one tap; new games appear there as they launch (PolHunter is one card). DRIP RUNNER (https://driprunner.app, LIVE for every member since 2026-10-01): tap-to-hop runner; gold drips, magenta bots, orange firewalls from chapter 2; each chapter has a drip goal for one run; the FIRST clear of a chapter pays a small POL drip (amount set by the admin, shown in the game) into the game balance, replays pay nothing; the balance is sent on Polygon to the member's InstantAdPay wallet once it reaches the payout line shown in the game. REFUELS: a run that ends can be refuelled with a verified visit to a member's page (a member video once every page has been visited), up to 20 a day, separate from the 20 Earn-tab visits; the advertiser is charged as for any visit, the player gets fuel not credits. The POL pool is funded ONLY by a share of refuel ad spend plus POL spent in the hangar, so drips depend on refuels and can be zero when the pool is empty; say so honestly. HANGAR: Drip Magnet and Courier Mk II cost drips (game currency); Shield Core and Slow Field cost POL from the game balance, which returns to the pool. GUESTS can try a run without signing in; their clears pay once they sign in. REFERRALS: each player's share link /r/<username>; when members whose InstantAdPay sponsor is that player refuel, a share (10 percent by default) of each refuel's pool income goes to the sponsor's game balance. Telegram posts achievement badges (chapters, unlocks, refuel milestones, payouts). Never promise amounts or income. The public list of every game, open now and opening next, is https://instantadpay.com/games (shareable; add ?ref=<username> to keep the referral).
|
||||
- Every purchase is split by an immutable smart contract in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. No withdrawals exist; money lands in members' own wallets instantly.
|
||||
- Qualification: level 1 open to all; 2 buyers of $20+ unlock level 2; 5 unlock level 3. Unqualified shares pass up the sponsor line, checking up to 25 positions, else the platform receives them. Qualification cannot be bought and never expires.
|
||||
|
||||
@@ -76,7 +76,8 @@ const WANT = {
|
||||
PIF: /PIF is a gift/,
|
||||
PRICE: /Five packages, priced/,
|
||||
EARN: /Every package splits the same way/,
|
||||
TANK: /The holding tank is where free members/
|
||||
TANK: /The holding tank is where free members/,
|
||||
GAMEPOL: /Game POL is paid to the wallet linked/
|
||||
};
|
||||
const ROUTES = [
|
||||
['PIF', 'should I pif someone from the holding tank'], ['PIF', 'what is pif'],
|
||||
@@ -89,7 +90,9 @@ const ROUTES = [
|
||||
['PRICE', 'how much does it cost'],
|
||||
['EARN', 'how much do I earn'], ['EARN', 'how much can i make'],
|
||||
['EARN', 'what will i get paid'], ['EARN', 'what is the commission'],
|
||||
['TANK', 'how does the holding tank work'], ['TANK', 'can I adopt someone from the tank']
|
||||
['TANK', 'how does the holding tank work'], ['TANK', 'can I adopt someone from the tank'],
|
||||
['GAMEPOL', 'my gem kingdom pol was never sent'], ['GAMEPOL', 'it says 1.50 POL is waiting for your wallet'],
|
||||
['GAMEPOL', 'do I need to switch on payouts to get my game pol']
|
||||
];
|
||||
for (const [want, q] of ROUTES) {
|
||||
const reply = await ask(q);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# bash qa/run.sh earn # local copy: earning flows end to end (~2-3 min)
|
||||
# bash qa/run.sh all # public + member + earn
|
||||
# bash qa/run.sh kb # chat knowledge base: retrieval unit test + chat endpoint e2e on a local copy with a mock OpenRouter
|
||||
# bash qa/run.sh walletnudge # game wallet push (any linked wallet, activated or not) + no-wallet nudge copy against a mock game (also runs in member)
|
||||
# bash qa/run.sh tankhold # holding-tank activation hold, 24-hour safety net (mocked clock) and LinkSpin alignment: unit + local copy (also runs in member)
|
||||
# bash qa/run.sh sponsorfollow # sponsor follow rule + network tank unit tests and the two-server e2e (local IAP + local LinkSpin, throwaway data)
|
||||
# bash qa/run.sh door # Spooky Doors door + costume shop flows on their own local copy (qa/door.mjs boots it)
|
||||
@@ -43,6 +44,9 @@ if [ "$MODE" = "public" ]; then
|
||||
elif [ "$MODE" = "member" ]; then
|
||||
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796
|
||||
node qa/tank-hold.mjs || status=1
|
||||
node qa/walletnudge.test.cjs || status=1
|
||||
elif [ "$MODE" = "walletnudge" ]; then
|
||||
node qa/walletnudge.test.cjs || status=1
|
||||
elif [ "$MODE" = "tankhold" ]; then
|
||||
node qa/tank-hold.mjs || status=1
|
||||
elif [ "$MODE" = "sponsorfollow" ]; then
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// Wallet push + nudge (walletnudge.js) against a MOCK game on localhost, throwaway data. Run: node qa/walletnudge.test.cjs
|
||||
// 2026-10-27 (Marty, "build all three"): a signature-linked wallet is pushed to the game whether or not it is an on-chain
|
||||
// member (memberId 0 when it is not); only players with NO linked wallet are nudged, and the nudge asks for the link step only.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const crypto = require('crypto');
|
||||
const assert = require('assert');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
let fails = 0, n = 0;
|
||||
async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e.message); } }
|
||||
function fresh(mod) { const p = require.resolve(path.join(ROOT, mod)); delete require.cache[p]; return require(p); }
|
||||
const SECRET = 'x'.repeat(40);
|
||||
const W1 = '0x' + '1'.repeat(40), W2 = '0x' + '2'.repeat(40), W3 = '0x' + '3'.repeat(40);
|
||||
|
||||
// a game with the same contract as the real ones: signed GET /api/iap/unpaid, signed POST /api/iap/wallet (fill empty only)
|
||||
function mockGame(players) {
|
||||
const pushes = [];
|
||||
const srv = http.createServer((req, res) => {
|
||||
const u = new URL(req.url, 'http://x'), send = (c, j) => { res.writeHead(c, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(j)); };
|
||||
if (u.pathname === '/api/iap/unpaid') {
|
||||
const ts = u.searchParams.get('ts'), want = crypto.createHmac('sha256', SECRET).update('unpaid\n' + ts).digest('hex');
|
||||
if (u.searchParams.get('sig') !== want) return send(401, { error: 'bad signature' });
|
||||
return send(200, { ok: true, rows: Object.entries(players).filter(([, p]) => p.unpaid > 0 && !p.wallet).map(([email, p]) => ({ email, memberId: 0, username: null, unpaid: p.unpaid })) });
|
||||
}
|
||||
if (u.pathname === '/api/iap/wallet' && req.method === 'POST') {
|
||||
let raw = ''; req.on('data', c => raw += c); req.on('end', () => {
|
||||
const ts = String(req.headers['x-iap-ts'] || '');
|
||||
const want = crypto.createHmac('sha256', SECRET).update('wallet\n' + ts + '\n' + crypto.createHash('sha256').update(raw).digest('hex')).digest('hex');
|
||||
if (req.headers['x-iap-sig'] !== want) return send(401, { error: 'bad signature' });
|
||||
const b = JSON.parse(raw), p = players[b.email]; pushes.push(b);
|
||||
if (!p) return send(404, { error: 'unknown player' });
|
||||
if (p.wallet && p.wallet.toLowerCase() !== b.wallet.toLowerCase()) return send(409, { error: 'a different wallet is already set' });
|
||||
const changed = !p.wallet; if (!p.wallet) p.wallet = b.wallet;
|
||||
send(200, { ok: true, changed, wallet: b.wallet, unpaid: p.unpaid });
|
||||
});
|
||||
return;
|
||||
}
|
||||
send(404, {});
|
||||
});
|
||||
return new Promise(ok => srv.listen(0, '127.0.0.1', () => ok({ srv, pushes, url: 'http://127.0.0.1:' + srv.address().port })));
|
||||
}
|
||||
|
||||
(async () => {
|
||||
for (const k of ['SD', 'GK', 'SEEK', 'DR', 'RA', 'PB', 'SW', 'PW']) { delete process.env[k + '_URL']; delete process.env[k + '_SSO_SECRET']; }
|
||||
const players = {
|
||||
'tank@x.test': { unpaid: 1.5 }, // linked wallet, NOT activated (holding tank): must be pushed, memberId 0
|
||||
'member@x.test': { unpaid: 0.4 }, // linked + activated: pushed with its member id, as before
|
||||
'nowallet@x.test': { unpaid: 0.75 }, // no linked wallet: nudged
|
||||
'other@x.test': { unpaid: 0.2, wallet: null }, // game already holds a different wallet -> refused below
|
||||
'rpc@x.test': { unpaid: 0.3 } // chain read fails: still pushed (stored member id, here 0)
|
||||
};
|
||||
const G = await mockGame(players);
|
||||
process.env.GK_URL = G.url; process.env.GK_SSO_SECRET = SECRET;
|
||||
const accts = {
|
||||
'tank@x.test': { email: 'tank@x.test', username: 'tanky', address: W1, memberId: 0 },
|
||||
'member@x.test': { email: 'member@x.test', username: 'mem', address: W2, memberId: 0 },
|
||||
'nowallet@x.test': { email: 'nowallet@x.test', username: 'nw', address: null, memberId: 0 },
|
||||
'other@x.test': { email: 'other@x.test', username: 'ot', address: W3, memberId: 0 },
|
||||
'rpc@x.test': { email: 'rpc@x.test', username: 'rp', address: '0x' + '4'.repeat(40), memberId: 0 }
|
||||
};
|
||||
const chainIds = { [W2.toLowerCase()]: 77 };
|
||||
const inbox = [], mail = [];
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-wn-'));
|
||||
const wn = fresh('walletnudge.js');
|
||||
// the 'other' player's game copy got a different wallet in between (fill-empty-only must refuse a replacement)
|
||||
players['other@x.test'].wallet = '0x' + '5'.repeat(40);
|
||||
players['other@x.test'].unpaid = 0.2;
|
||||
// ...but then the game would not list it as unpaid-without-wallet; force it into the list once to exercise the 409 path
|
||||
const origOther = players['other@x.test'];
|
||||
wn.init({ dataDir: dir, site: 'https://instantadpay.com',
|
||||
accounts: { byEmail: async e => accts[e] || null, byMemberId: async () => null },
|
||||
chain: { memberIdByAccount: async a => { if (a === accts['rpc@x.test'].address) throw new Error('rpc down'); return chainIds[a.toLowerCase()] || 0; } },
|
||||
mailer: { hasKey: () => true, send: async (to, subject, text, html) => { mail.push({ to, subject, text, html }); } },
|
||||
optedIn: async () => true,
|
||||
message: async (to, subject, html) => { inbox.push({ to, subject, html }); } });
|
||||
|
||||
let r;
|
||||
await t('tick runs against the mock game', async () => { r = await wn.tick(); assert.ok(r.ok); assert.strictEqual(r.games.gemkingdom, 4); });
|
||||
await t('non-activated linked wallet is pushed with memberId 0 and filled', async () => {
|
||||
const p = G.pushes.find(x => x.email === 'tank@x.test'); assert.ok(p, 'no push');
|
||||
assert.strictEqual(p.wallet, W1); assert.strictEqual(p.memberId, 0); assert.strictEqual(players['tank@x.test'].wallet, W1);
|
||||
});
|
||||
await t('activated wallet still pushed with its member id', async () => {
|
||||
const p = G.pushes.find(x => x.email === 'member@x.test'); assert.ok(p); assert.strictEqual(p.memberId, 77); assert.strictEqual(players['member@x.test'].wallet, W2);
|
||||
});
|
||||
await t('a failed chain read still pushes the linked wallet (stored member id)', async () => {
|
||||
const p = G.pushes.find(x => x.email === 'rpc@x.test'); assert.ok(p); assert.strictEqual(p.memberId, 0);
|
||||
});
|
||||
await t('linked players are never nudged; the no-wallet player is', async () => {
|
||||
assert.deepStrictEqual(inbox.map(x => x.to), ['nowallet@x.test']); assert.deepStrictEqual(mail.map(x => x.to), ['nowallet@x.test']);
|
||||
assert.strictEqual(r.pushed, 3); assert.strictEqual(r.sent, 1);
|
||||
});
|
||||
await t('nudge copy: link step only, the exact approved wording, /my#wallet', async () => {
|
||||
const m = mail[0];
|
||||
assert.strictEqual(m.subject, '0.75 POL is waiting for your wallet');
|
||||
assert.ok(m.text.includes("You've earned 0.75 POL in Gem Kingdom. Link your wallet (one free signature) and it's sent automatically, including everything you've earned so far."), m.text);
|
||||
assert.ok(m.text.includes('https://instantadpay.com/my#wallet')); assert.ok(inbox[0].html.includes('https://instantadpay.com/my#wallet'));
|
||||
assert.ok(!/switch on|activate/i.test(m.text + inbox[0].html), 'mentions switching on payouts');
|
||||
assert.ok(!/—/.test(m.text + inbox[0].html), 'em dash');
|
||||
});
|
||||
await t('second tick: nothing re-pushed as a change, no second nudge before 3 days', async () => {
|
||||
const before = G.pushes.length; const r2 = await wn.tick();
|
||||
assert.strictEqual(r2.pushed, 0); assert.strictEqual(r2.sent, 0); assert.strictEqual(G.pushes.length, before, 'filled players are no longer listed');
|
||||
});
|
||||
await t('a different wallet in the game is refused (409), never replaced, and not retried within the day', async () => {
|
||||
// list the "other" player as unpaid with no wallet in the listing, but the game copy holds a different wallet
|
||||
const realWallet = origOther.wallet;
|
||||
const saved = G.srv.listeners('request')[0];
|
||||
G.srv.removeAllListeners('request');
|
||||
G.srv.on('request', (req, res) => {
|
||||
if (req.url.startsWith('/api/iap/unpaid')) { res.writeHead(200, { 'Content-Type': 'application/json' }); return res.end(JSON.stringify({ ok: true, rows: [{ email: 'other@x.test', memberId: 0, unpaid: 0.2 }] })); }
|
||||
return saved(req, res);
|
||||
});
|
||||
const before = G.pushes.length;
|
||||
await wn.tick(); assert.strictEqual(G.pushes.length, before + 1); assert.strictEqual(players['other@x.test'].wallet, realWallet);
|
||||
const v = wn.adminView(); assert.ok(v.pushRefused.some(x => x.email === 'other@x.test' && x.status === 'conflict'));
|
||||
await wn.tick(); assert.strictEqual(G.pushes.length, before + 1, 'retried within 24 h');
|
||||
});
|
||||
G.srv.close(); fs.rmSync(dir, { recursive: true, force: true });
|
||||
console.log((n - fails) + '/' + n + ' passed'); process.exit(fails ? 1 : 0);
|
||||
})();
|
||||
+18
-10
@@ -9,6 +9,10 @@
|
||||
// account has a wallet that is an on-chain member (the same a.address the hand-off token carries) is PUSHED to that game's
|
||||
// signed POST /api/iap/wallet instead of nudged; the game's own payout sweep then pays it. Idempotent on the game side (the same
|
||||
// wallet twice is a no-op, a different one is refused), so the deploy overlap's two copies cannot do harm.
|
||||
// Any linked wallet (Marty, 2026-10-27, "build all three"): the push no longer waits for the wallet to be an on-chain member. A
|
||||
// holding-tank member can wait a day or more before switching on payouts, and their game POL sat unpaid with the nudges stopped.
|
||||
// accounts.address is only ever set after a verified wallet signature (auth.verifyChallenge -> accounts.linkWallet), so that is
|
||||
// the wallet every game pays. memberId goes along when the chain knows one, else 0.
|
||||
// nudge: false = push only. PolyBreak, SpellWheel and PolyWarriors joined 2026-10-25 push-only; Marty turned their nudges on the same day.
|
||||
const fs = require('fs'), path = require('path'), crypto = require('crypto'), https = require('https'), http = require('http');
|
||||
let R = {}, DATA_DIR = '.';
|
||||
@@ -48,11 +52,13 @@ function pushWallet(g, body) {
|
||||
rq.end(raw);
|
||||
});
|
||||
}
|
||||
// the wallet to push for an account: its linked address, only when that address is an on-chain member -> { wallet, memberId } | null
|
||||
async function activatedWallet(a) {
|
||||
if (!a || !a.address || !/^0x[a-f0-9]{40}$/i.test(a.address) || !R.chain || !R.chain.memberIdByAccount) return null;
|
||||
const id = await R.chain.memberIdByAccount(a.address); // throws on an RPC failure: the caller skips this row until next hour
|
||||
return Number(id) > 0 ? { wallet: a.address, memberId: Number(id) } : null;
|
||||
// the wallet to push for an account: its signature-linked address, activated or not -> { wallet, memberId } | null
|
||||
// memberId is the on-chain member id when there is one, else 0; a failed chain read falls back to the account's stored id.
|
||||
async function linkedWallet(a) {
|
||||
if (!a || !a.address || !/^0x[a-f0-9]{40}$/i.test(a.address)) return null;
|
||||
let id = Number(a.memberId) || 0;
|
||||
if (R.chain && R.chain.memberIdByAccount) { try { id = Number(await R.chain.memberIdByAccount(a.address)) || 0; } catch (e) { console.warn('walletnudge chain read', e.message); } }
|
||||
return { wallet: a.address, memberId: id > 0 ? id : 0 };
|
||||
}
|
||||
function fetchRows(g) {
|
||||
return new Promise(resolve => {
|
||||
@@ -66,12 +72,14 @@ function fetchRows(g) {
|
||||
rq.on('timeout', () => { rq.destroy(); resolve(null); }); rq.on('error', () => resolve(null));
|
||||
});
|
||||
}
|
||||
// copy (Marty, 2026-10-27): the ask is the LINK step only (one free signature), never "switch on payouts": a linked wallet is paid
|
||||
function copy(games, stage, link) {
|
||||
const total = games.reduce((n, g) => n + g.unpaid, 0);
|
||||
const list = games.map(g => g.unpaid.toFixed(2) + ' POL from ' + g.name).join(', ');
|
||||
const parts = games.map(g => g.unpaid.toFixed(2) + ' POL in ' + g.name);
|
||||
const list = parts.length > 1 ? parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1] : parts[0];
|
||||
const subject = total.toFixed(2) + ' POL is waiting for your wallet';
|
||||
const p1 = 'You have ' + list + ' sitting in your game balance' + (games.length > 1 ? 's' : '') + '. It cannot be paid out yet because no wallet is linked to your InstantAdPay account.';
|
||||
const p2 = 'Link a wallet on your Wallet tab. It is one free signature, no transaction, and it cannot move funds. Your POL pays out on the next sweep, and every game pays that same wallet from then on.';
|
||||
const p1 = "You've earned " + list + ". Link your wallet (one free signature) and it's sent automatically, including everything you've earned so far.";
|
||||
const p2 = 'It is not a transaction and it cannot move funds. Every game pays that same wallet from then on.';
|
||||
const p3 = stage >= 2 ? 'This is the last reminder about this balance. It stays yours; it just waits for a wallet.' : 'Not sure which wallet to use? SafePal is the one we recommend; MetaMask and Phantom work too. The Wallet tab has a short guide.';
|
||||
const text = [p1, '', p2, '', 'Link your wallet: ' + link, '', p3].join('\n');
|
||||
const html = '<p>' + esc(p1).replace(esc(list), '<b>' + esc(list) + '</b>') + '</p><p>' + esc(p2) + '</p><p><a href="' + esc(link) + '"><b>Link your wallet</b></a></p><p>' + esc(p3) + '</p>';
|
||||
@@ -88,9 +96,9 @@ async function tick() {
|
||||
if (!email && Number(r.memberId) > 0 && R.accounts.byMemberId) { acct = await R.accounts.byMemberId(Number(r.memberId)); email = acct ? acct.email : ''; }
|
||||
if (!email) continue;
|
||||
const unpaid = Math.max(0, Number(r.unpaid) || 0);
|
||||
// the IAP account already has an activated wallet: hand it to the game instead of asking the member for it
|
||||
// the IAP account already has a linked wallet (activated or not): hand it to the game instead of asking the member for it
|
||||
if (!acct) acct = await R.accounts.byEmail(email);
|
||||
let act = null; try { act = await activatedWallet(acct); } catch (e) { console.warn('walletnudge chain read', e.message); continue; }
|
||||
const act = await linkedWallet(acct);
|
||||
if (act) {
|
||||
const pk = g.key + ':' + email, prev = S.pushes[pk];
|
||||
// a refusal (different wallet already in the game, unknown player) is retried once a day, never every hour
|
||||
|
||||
Reference in New Issue
Block a user