PolyWarriors mint bar: 4 h cookie (was 7 days), cleared on every exit, x to hide
Members who tapped Mint, saw the price and went back to the game kept the blue "PolyWarriors mint" bar on the dashboard for a week. The cookie now lives 4 h, is cleared by Back to PolyWarriors / Cancel (new /pw/mint/leave), by the mint-pass success redirect, and by an x on the bar (/pw/mint/dismiss). The waiting order itself is untouched: a later package still completes the mint. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -848,7 +848,10 @@
|
||||
if (me.returnTo === 'gkshop' && !render.toGame) { render.toGame = true; location.href = '/gk/shop/resume'; return; }
|
||||
if (me.returnTo === 'spookydoors' && !render.toGame) { render.toGame = true; location.href = '/api/my/spookydoors'; return; } // Spooky Doors sent them here to sign in (2026-10-02)
|
||||
if (me.returnTo === 'pwmint' && !render.toGame) { render.toGame = true; location.href = '/pw/mint/resume'; return; } // PolyWarriors paid mint (2026-10-05)
|
||||
if (me.pwMint && !me.gkShop && !me.sdShop && !document.getElementById('pwBack')) { const d = document.createElement('a'); d.id = 'pwBack'; document.body.classList.add('hasback'); d.href = '/pw/mint/resume'; d.textContent = 'PolyWarriors mint: buy a package and you go straight back to the game when it settles. Or go back now →'; d.setAttribute('style', 'position:fixed;left:12px;right:12px;bottom:14px;z-index:9999;display:block;padding:14px 16px;border-radius:14px;background:linear-gradient(180deg,#22E5FF,#7A2CFF);color:#fff;font-weight:800;text-align:center;text-decoration:none;box-shadow:0 10px 30px rgba(0,0,0,.45)'); document.body.appendChild(d); }
|
||||
if (me.pwMint && !me.gkShop && !me.sdShop && !document.getElementById('pwBack')) { const d = document.createElement('a'); d.id = 'pwBack'; document.body.classList.add('hasback'); d.href = '/pw/mint/resume'; d.textContent = 'PolyWarriors mint: buy a package and you go straight back to the game when it settles. Or go back now →'; d.setAttribute('style', 'position:fixed;left:12px;right:12px;bottom:14px;z-index:9999;display:block;padding:14px 44px 14px 16px;border-radius:14px;background:linear-gradient(180deg,#22E5FF,#7A2CFF);color:#fff;font-weight:800;text-align:center;text-decoration:none;box-shadow:0 10px 30px rgba(0,0,0,.45)'); document.body.appendChild(d);
|
||||
// x = not now: clears the bar cookie (the waiting mint order stays and a later package still completes it), Marty 2026-10-11
|
||||
const x = document.createElement('button'); x.type = 'button'; x.setAttribute('aria-label', 'Hide'); x.textContent = '×'; x.setAttribute('style', 'position:absolute;right:8px;top:50%;transform:translateY(-50%);width:30px;height:30px;border:0;border-radius:50%;background:rgba(0,0,0,.28);color:#fff;font-size:20px;line-height:30px;cursor:pointer;padding:0');
|
||||
x.addEventListener('click', ev => { ev.preventDefault(); ev.stopPropagation(); fetch('/pw/mint/dismiss', { method: 'POST' }).catch(() => {}); d.remove(); document.body.classList.remove('hasback'); if (me) me.pwMint = false; }); d.appendChild(x); }
|
||||
if (me.returnTo === 'sdshop' && !render.toGame) { render.toGame = true; location.href = '/sd/shop/resume'; return; }
|
||||
if (me.sdShop && !document.getElementById('sdBack')) { const d = document.createElement('a'); d.id = 'sdBack'; document.body.classList.add('hasback'); d.href = '/sd/shop/resume'; d.textContent = 'Finish your Spooky Doors costume order \u2192'; d.setAttribute('style', 'position:fixed;left:12px;right:12px;bottom:' + (me.gkShop ? '74px' : '14px') + ';z-index:9999;display:block;padding:14px 16px;border-radius:14px;background:#FF8A1F;color:#2a1200;font-weight:800;text-align:center;text-decoration:none;box-shadow:0 5px 0 #C25A06,0 10px 30px rgba(0,0,0,.45)'); document.body.appendChild(d); }
|
||||
if (me.gkShop && !document.getElementById('gkBack')) { const d = document.createElement('a'); d.id = 'gkBack'; document.body.classList.add('hasback'); d.href = '/gk/shop/resume'; d.textContent = 'Finish your Gem Kingdom Crowns order \u2192'; d.setAttribute('style', 'position:fixed;left:12px;right:12px;bottom:14px;z-index:9999;display:block;padding:14px 16px;border-radius:14px;background:linear-gradient(180deg,#E8455A,#A8172B);color:#fff;font-weight:800;text-align:center;text-decoration:none;box-shadow:0 10px 30px rgba(0,0,0,.45)'); document.body.appendChild(d); }
|
||||
|
||||
+1
-1
@@ -1151,7 +1151,7 @@
|
||||
<script src="/assets/common.js?v=20261007a"></script><script src="/assets/welcome.js?v=20260923b"></script>
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20261010a"></script>
|
||||
<script src="/assets/my.js?v=20261009c"></script>
|
||||
<script src="/assets/my.js?v=20261011a"></script>
|
||||
<script src="/assets/chat.js?v=20260907l"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1384,6 +1384,7 @@ async function swCallback(cbUrl, receipt) {
|
||||
if (!swIsGameUrl(cbUrl)) return false;
|
||||
try { const r = await fetch(cbUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ t: receipt }), signal: AbortSignal.timeout(8000) }); return r.ok; } catch (e) { console.warn('spellwheel callback', e.message); return false; }
|
||||
}
|
||||
const PW_MINT_COOKIE_S = 4 * 3600; // the dashboard "back to the mint" bar lives this long (was 7 days: people who looked at the price and left saw it for a week, Marty 2026-10-11)
|
||||
// -- PolyWarriors paid mints (2026-10-05): the first mint is free in the game; later mints cost PW_MINT_CREDITS (100) from
|
||||
// PURCHASED credits only (package credits on a position; earned credits never count, Marty's rule). The game signs an order
|
||||
// with PW_SSO_SECRET (kind 'pw-mint'), the member confirms here, ads.gamePurchase(purchasedOnly) charges, and a signed
|
||||
@@ -3083,21 +3084,21 @@ const server = http.createServer(async (req, res) => {
|
||||
const done = pwOrders.get(c.order);
|
||||
if (done && done.status === 'paid') { const rc = pwReceipt(c.order, done); res.writeHead(302, { Location: (pwIsGameUrl(done.ret) ? done.ret : PW_URL() + '/api/iap/mint-receipt') + '?t=' + rc, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.pwmint', '', 0) }); return res.end(); }
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.pwmint', t, 7 * 86400), gkCookie('iap.return', 'pwmint', 1800)] }); return res.end(); }
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.pwmint', t, PW_MINT_COOKIE_S), gkCookie('iap.return', 'pwmint', 1800)] }); return res.end(); }
|
||||
if (String(s.email).toLowerCase() !== String(c.email).toLowerCase()) return gkPage(res, 403, 'Different account', '<h1>Different account</h1><p class="sub">This mint was started by the PolyWarriors player ' + gkEsc(c.email) + ', but you are signed in to InstantAdPay as ' + gkEsc(s.email) + '. Sign in with the same account and tap Mint again.</p>');
|
||||
// the order waits here until a new package purchase from this account lands on chain (oldest waiting order first)
|
||||
if (!done) pwOrders.set(c.order, { status: 'waiting', email: String(s.email).toLowerCase(), serial: Number(c.serial), label: String(c.label || '').slice(0, 60), ret: c.ret, cb: c.cb, ts: Date.now() });
|
||||
res.setHeader('Set-Cookie', gkCookie('iap.pwmint', t, 7 * 86400));
|
||||
res.setHeader('Set-Cookie', gkCookie('iap.pwmint', t, PW_MINT_COOKIE_S));
|
||||
const have = pwPassN(String(s.email).toLowerCase());
|
||||
if (have > 0) {
|
||||
const csrf = pwSign('pass:' + c.order + ':' + String(s.email).toLowerCase());
|
||||
return gkPage(res, 200, 'Mint your warrior', '<p class="sub">PolyWarriors · Mint to your wallet</p><h1>' + gkEsc(c.label || ('Warrior #' + c.serial)) + '</h1><div class="big">' + have + ' mint pass' + (have === 1 ? '' : 'es') + '</div>'
|
||||
+ '<form method="post" action="/pw/mint/pass" onsubmit="var b=this.querySelector(\'button\');b.disabled=true;b.textContent=\'Minting… one moment\';b.style.opacity=.7"><input type="hidden" name="t" value="' + gkEsc(t) + '"><input type="hidden" name="csrf" value="' + csrf + '"><button class="btn" type="submit">Use 1 mint pass and mint</button></form>'
|
||||
+ '<a class="alt" href="' + PW_URL() + '/play">Cancel and go back</a><p class="fine">You earned these passes with your package purchases: one mint for every $5. The game pays the network fee.</p>');
|
||||
+ '<a class="alt" href="/pw/mint/leave">Cancel and go back</a><p class="fine">You earned these passes with your package purchases: one mint for every $5. The game pays the network fee.</p>');
|
||||
}
|
||||
return gkPage(res, 200, 'Mint your warrior', '<p class="sub">PolyWarriors · Mint to your wallet</p><h1>' + gkEsc(c.label || ('Warrior #' + c.serial)) + '</h1><div class="big">Comes with a $5 package</div>'
|
||||
+ '<p class="sub">Your first mint was free. After that, every $5 of new ad packages earns one mint: $5 mints this warrior, $10 earns 2 mints, $20 earns 4, and any extra mints stay on your account for next time. You keep every package\'s ad credits.</p>'
|
||||
+ '<a class="btn" href="/my?from=polywarriors#buy">Buy a $5 package</a><a class="btn blue" href="' + PW_URL() + '/play">Back to PolyWarriors</a>'
|
||||
+ '<a class="btn" href="/my?from=polywarriors#buy">Buy a $5 package</a><a class="btn blue" href="/pw/mint/leave">Back to PolyWarriors</a>'
|
||||
+ '<p class="fine">Buy while this mint is waiting and it mints to your wallet automatically. Credits you already have cannot be used for mints. The game pays the network fee.</p>');
|
||||
}
|
||||
if (!IS_PROD && p === '/api/dev/pw-purchase' && req.method === 'POST') { const b = await readBody(req); return json(res, 200, { order: await pwMintOnEvent({ type: 'Purchase', priceCents: Number(b.cents) || 500, buyerId: 0, tx: '0x' + crypto.randomBytes(32).toString('hex'), ts: Date.now(), devEmail: b.email }) }); } // local tests only
|
||||
@@ -3113,8 +3114,10 @@ const server = http.createServer(async (req, res) => {
|
||||
// receipt too, so the mint never waits on this callback). Marty's phone sat on this form on 2026-10-09 while the mint had
|
||||
// already gone through.
|
||||
if (o && o.status === 'waiting' && pwPassN(e) > 0) { pwPassAdd(e, -1, 'mint:' + c.order); pwOrders.set(c.order, Object.assign({}, o, { status: 'paid', tx: 'pass', cents: 500, paidAt: Date.now() })); pwDeliver(c.order).catch(() => {}); }
|
||||
res.writeHead(303, { Location: '/pw/mint?t=' + encodeURIComponent(t), 'Cache-Control': 'no-store' }); return res.end();
|
||||
res.writeHead(303, Object.assign({ Location: '/pw/mint?t=' + encodeURIComponent(t), 'Cache-Control': 'no-store' }, pwOrders.get(c.order) && pwOrders.get(c.order).status === 'paid' ? { 'Set-Cookie': gkCookie('iap.pwmint', '', 0) } : {})); return res.end();
|
||||
}
|
||||
if (p === '/pw/mint/leave' && req.method === 'GET') { res.writeHead(302, { Location: PW_URL() + '/play', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.pwmint', '', 0), gkCookie('iap.return', '', 0)] }); return res.end(); } // the waiting order stays; a later package still completes the mint
|
||||
if (p === '/pw/mint/dismiss' && req.method === 'POST') { res.writeHead(204, { 'Set-Cookie': [gkCookie('iap.pwmint', '', 0), gkCookie('iap.return', '', 0)] }); return res.end(); } // the dashboard bar's x
|
||||
if (p === '/pw/mint/resume' && req.method === 'GET') { const t = parseCookies(req)['iap.pwmint']; res.writeHead(302, { Location: t ? '/pw/mint?t=' + encodeURIComponent(t) : PW_URL() + '/play', 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end(); }
|
||||
if (p === '/gk/shop/topup' && req.method === 'GET') { // the detour to Buy packages, remembered for the way back
|
||||
const t = u.searchParams.get('t') || ''; if (gkOpen(t).error) { res.writeHead(302, { Location: '/my#buy' }); return res.end(); }
|
||||
|
||||
Reference in New Issue
Block a user