fix: close demo payment bypass and guard order transitions
masterplan-lock / check (pull_request) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 14s
CI (SIAX Cloud) / security (pull_request) Successful in 15s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / integration (pull_request) Successful in 26s
masterplan-lock / check (push) Successful in 35s
CI (SIAX Cloud) / quality (pull_request) Successful in 37s
Security Scan (SIAX Cloud) / security (push) Successful in 1m4s
CI (SIAX Cloud) / integration (push) Successful in 1m14s
CI (SIAX Cloud) / quality (push) Successful in 2m12s
masterplan-lock / check (pull_request) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 14s
CI (SIAX Cloud) / security (pull_request) Successful in 15s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / integration (pull_request) Successful in 26s
masterplan-lock / check (push) Successful in 35s
CI (SIAX Cloud) / quality (pull_request) Successful in 37s
Security Scan (SIAX Cloud) / security (push) Successful in 1m4s
CI (SIAX Cloud) / integration (push) Successful in 1m14s
CI (SIAX Cloud) / quality (push) Successful in 2m12s
This commit is contained in:
@@ -202,3 +202,20 @@ export async function setStatus(id: string, status: string): Promise<Order | nul
|
||||
if (o) { o.status = status; mem.set(id, o); }
|
||||
return o ?? null;
|
||||
}
|
||||
|
||||
/** Atomic status transition; rejects stale concurrent writers instead of overwriting them. */
|
||||
export async function setStatusIfCurrent(id: string, current: string, next: string): Promise<Order | null> {
|
||||
const sql = getSqlForDurableStore("0pt.orders");
|
||||
if (sql) {
|
||||
const rows = await sql<Order[]>`
|
||||
UPDATE orders SET status = ${next}, updated_at = now()
|
||||
WHERE order_id::text = ${id} AND status = ${current}
|
||||
RETURNING order_id, flow, status, config, total_ore, deposit_ore, balance_ore, est_days, est_confidence, created_at`;
|
||||
return rows[0] ? coerceOrder(rows[0]) : null;
|
||||
}
|
||||
const order = mem.get(id);
|
||||
if (!order || order.status !== current) return null;
|
||||
order.status = next;
|
||||
mem.set(id, order);
|
||||
return order;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user