Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push (docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels. Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js, rankings DoS, static headers, ...): fixes follow in the next commit. NOT done: bots/balance, e2e suite, real-device checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
12 lines
704 B
JavaScript
12 lines
704 B
JavaScript
'use strict';
|
|
/* An open Internet exchange offer ran out of time: the escrow goes back to the POP. Payload { offerId }. Idempotent: acts only
|
|
* while the offer is still open (accepted/cancelled offers cancel their own expiry event, this is the second line of defence). */
|
|
const T = require('../trade');
|
|
|
|
module.exports = function tradeExpire(ctx, ev) {
|
|
const o = T.getOffer(ctx.db, ev.payload.offerId);
|
|
if (!o || o.status !== 'open') return;
|
|
T.closeOffer(ctx, o, 'expired', ev.dueAt);
|
|
const uid = T.userOfOperator(ctx.db, o.operator_id);
|
|
if (uid) ctx.notify(uid, o.world_id, 'trade_expired', { offerId: o.id, townId: o.town_id, returned: { resource: o.give_res, amount: o.give_amount } });
|
|
};
|