PolyWarriors mint pass: the button shows Minting... and the redirect no longer waits on the game callback (Marty's phone sat on the form on 2026-10-09 while the mint had already gone through)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -3082,7 +3082,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (have > 0) {
|
if (have > 0) {
|
||||||
const csrf = pwSign('pass:' + c.order + ':' + String(s.email).toLowerCase());
|
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>'
|
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"><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>'
|
+ '<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_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>');
|
||||||
}
|
}
|
||||||
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>'
|
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>'
|
||||||
@@ -3099,7 +3099,10 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const want = pwSign('pass:' + c.order + ':' + e), got = String(f.get('csrf') || '');
|
const want = pwSign('pass:' + c.order + ':' + e), got = String(f.get('csrf') || '');
|
||||||
if (want.length !== got.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got))) return gkPage(res, 403, 'Mint problem', '<h1>That form expired</h1><a class="btn blue" href="/pw/mint?t=' + encodeURIComponent(t) + '">Try again</a>');
|
if (want.length !== got.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got))) return gkPage(res, 403, 'Mint problem', '<h1>That form expired</h1><a class="btn blue" href="/pw/mint?t=' + encodeURIComponent(t) + '">Try again</a>');
|
||||||
const o = pwOrders.get(c.order);
|
const o = pwOrders.get(c.order);
|
||||||
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() })); await pwDeliver(c.order); }
|
// the redirect goes out at once; the game is told in the background (and the GET below hands the member's own browser the
|
||||||
|
// 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, { Location: '/pw/mint?t=' + encodeURIComponent(t), 'Cache-Control': 'no-store' }); return res.end();
|
||||||
}
|
}
|
||||||
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 === '/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(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user