@openora/core 0.4.1-canary.93 → 0.4.1-canary.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/contracts/adapters/audit.d.ts +1 -1
  3. package/dist/contracts/adapters/audit.d.ts.map +1 -1
  4. package/dist/contracts/adapters/audit.js.map +1 -1
  5. package/dist/wallet/__tests__/custody-sweep-gate.test.d.ts +2 -0
  6. package/dist/wallet/__tests__/custody-sweep-gate.test.d.ts.map +1 -0
  7. package/dist/wallet/__tests__/custody-sweep-gate.test.js +70 -0
  8. package/dist/wallet/__tests__/custody-sweep-gate.test.js.map +1 -0
  9. package/dist/wallet/__tests__/custody-sweep.service.int.test.d.ts +2 -0
  10. package/dist/wallet/__tests__/custody-sweep.service.int.test.d.ts.map +1 -0
  11. package/dist/wallet/__tests__/custody-sweep.service.int.test.js +246 -0
  12. package/dist/wallet/__tests__/custody-sweep.service.int.test.js.map +1 -0
  13. package/dist/wallet/__tests__/wallet-asset.router.int.test.js +6 -1
  14. package/dist/wallet/__tests__/wallet-asset.router.int.test.js.map +1 -1
  15. package/dist/wallet/__tests__/wallet-auto-rule.router.int.test.js +1 -1
  16. package/dist/wallet/__tests__/wallet-auto-rule.router.int.test.js.map +1 -1
  17. package/dist/wallet/__tests__/wallet-auto-withdrawal-config.router.int.test.js +1 -1
  18. package/dist/wallet/__tests__/wallet-auto-withdrawal-config.router.int.test.js.map +1 -1
  19. package/dist/wallet/__tests__/wallet-custody-stubs.router.test.js +21 -10
  20. package/dist/wallet/__tests__/wallet-custody-stubs.router.test.js.map +1 -1
  21. package/dist/wallet/__tests__/wallet-webhook.router.int.test.js +7 -1
  22. package/dist/wallet/__tests__/wallet-webhook.router.int.test.js.map +1 -1
  23. package/dist/wallet/__tests__/wallet.router.int.test.js +6 -1
  24. package/dist/wallet/__tests__/wallet.router.int.test.js.map +1 -1
  25. package/dist/wallet/contract/index.js +1 -1
  26. package/dist/wallet/contract/index.js.map +1 -1
  27. package/dist/wallet/plugin.d.ts.map +1 -1
  28. package/dist/wallet/plugin.js +55 -14
  29. package/dist/wallet/plugin.js.map +1 -1
  30. package/dist/wallet/router/index.d.ts +16 -2
  31. package/dist/wallet/router/index.d.ts.map +1 -1
  32. package/dist/wallet/router/index.js +15 -2
  33. package/dist/wallet/router/index.js.map +1 -1
  34. package/dist/wallet/service/custody-sweep.service.d.ts +77 -0
  35. package/dist/wallet/service/custody-sweep.service.d.ts.map +1 -0
  36. package/dist/wallet/service/custody-sweep.service.js +357 -0
  37. package/dist/wallet/service/custody-sweep.service.js.map +1 -0
  38. package/package.json +1 -1
@@ -0,0 +1,77 @@
1
+ import * as z from 'zod';
2
+ import { type DrizzleService } from '@openora/core/server';
3
+ import { type AuditWritePort, type PaymentProviderRegistry, type PlatformConfig, type Uuid } from '@openora/core/contracts';
4
+ export declare const CUSTODY_SWEEP_JOB_NAME = "wallet-custody-sweep";
5
+ export declare const CUSTODY_SWEEP_QUEUE: import("@openora/core/contracts").QueueName;
6
+ export declare const CustodySweepJobPayloadSchema: z.ZodObject<{
7
+ runId: z.ZodOptional<z.ZodUUID>;
8
+ }, z.core.$strip>;
9
+ export type CustodySweepJobPayload = z.infer<typeof CustodySweepJobPayloadSchema>;
10
+ export type SweepCycleSummary = {
11
+ considered: number;
12
+ swept: number;
13
+ skippedDust: number;
14
+ skippedFee: number;
15
+ skippedCeiling: number;
16
+ inFlight: number;
17
+ failed: number;
18
+ unknown: number;
19
+ };
20
+ export type SweepGateDecision = 'sweep' | 'dust' | 'fee' | 'ceiling';
21
+ /**
22
+ * Pure gate over a single custody balance, in the exact order
23
+ * docs/adapters/payment.md diagram D3 specifies: dust floor, then the fee-multiple
24
+ * floor, then the fee ceiling (overridden only when the pool is running dry).
25
+ *
26
+ * `poolBalance` is null whenever the caller hasn't fetched it (no ceiling breach yet,
27
+ * the adapter has no `getPoolBalance`, or the asset has no `poolLiquidityFloor`) - null
28
+ * always means "the ceiling stays absolute", never an accidental override.
29
+ */
30
+ export declare function gateSweepBalance(args: {
31
+ amount: string;
32
+ estimatedFee: string;
33
+ minDeposit: string;
34
+ feeMultiple: string;
35
+ sweepFeeCeiling: string | null;
36
+ poolLiquidityFloor: string | null;
37
+ poolBalance: string | null;
38
+ }): SweepGateDecision;
39
+ export type CustodySweepServiceDeps = {
40
+ drizzle: DrizzleService;
41
+ paymentProviders: PaymentProviderRegistry;
42
+ audit: AuditWritePort;
43
+ platformConfig?: PlatformConfig;
44
+ };
45
+ /**
46
+ * Owns the custody sweep cron: moves vendor-side per-player custody balances into the
47
+ * pooled account they're paid out of. Deliberately separate from WalletService (which
48
+ * is already ~2000 lines) and deliberately never touches wallet_balance/wallet_transaction
49
+ * - the player was credited at deposit time, this only moves the vendor's own money
50
+ * between its own containers. See docs/adapters/payment.md, "Custody: pooling, sweeping
51
+ * and reconciliation".
52
+ */
53
+ export declare class CustodySweepService {
54
+ private readonly drizzle;
55
+ private readonly paymentProviders;
56
+ private readonly audit;
57
+ private readonly platformConfig?;
58
+ constructor({ drizzle, paymentProviders, audit, platformConfig }: CustodySweepServiceDeps);
59
+ /**
60
+ * Runs one sweep cycle. No-ops (returns null, touches nothing) when
61
+ * `platformConfig.wallet.sweep` is absent - an operator who hasn't configured sweep
62
+ * policy still gets a scheduled job, it just never claims a run. Also returns null
63
+ * when another cycle already owns the claim.
64
+ */
65
+ runCycle(requestedRunId?: Uuid): Promise<{
66
+ runId: Uuid;
67
+ summary: SweepCycleSummary;
68
+ } | null>;
69
+ private claimRun;
70
+ private resolveInFlightSweeps;
71
+ private assetFor;
72
+ private hasInFlightSweep;
73
+ private getPoolBalanceCached;
74
+ private processBalance;
75
+ private finishRun;
76
+ }
77
+ //# sourceMappingURL=custody-sweep.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custody-sweep.service.d.ts","sourceRoot":"","sources":["../../../src/wallet/service/custody-sweep.service.ts"],"names":[],"mappings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C1C,KAAK,EAAE,cAAc,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IAC3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAiB;gBAErC,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,uBAAuB;IAOzF;;;;;OAKG;IACG,QAAQ,CACZ,cAAc,CAAC,EAAE,IAAI,GACpB,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI,CAAC;YA2EhD,QAAQ;YAiDR,qBAAqB;YA0BrB,QAAQ;YAQR,gBAAgB;YAmBhB,oBAAoB;YAmBpB,cAAc;YA6Id,SAAS;CA4BxB"}
@@ -0,0 +1,357 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import * as z from 'zod';
3
+ import { moneyCompare, moneyScaleBy, mapConcurrent, createLogger, } from '@openora/core/server';
4
+ import { queue, UuidSchema, } from '@openora/core/contracts';
5
+ import { and, eq, inArray, isNotNull, isNull } from 'drizzle-orm';
6
+ import { walletAsset, walletCustodySweep, walletJobRun, walletReconciliationFinding, } from '../schema/index.js';
7
+ const logger = createLogger('wallet-custody-sweep');
8
+ export const CUSTODY_SWEEP_JOB_NAME = 'wallet-custody-sweep';
9
+ export const CUSTODY_SWEEP_QUEUE = queue('wallet.custody-sweep');
10
+ // `runId` is only present when an admin's on-demand POST /wallet/custody/sweep/run
11
+ // enqueued this tick - the router mints it up front so it can hand the caller back a
12
+ // runId synchronously, before the job actually runs. A cron tick omits it and the
13
+ // service mints its own.
14
+ export const CustodySweepJobPayloadSchema = z.object({ runId: UuidSchema.optional() });
15
+ const IN_FLIGHT_STATUSES = ['pending', 'processing', 'unknown'];
16
+ /**
17
+ * Pure gate over a single custody balance, in the exact order
18
+ * docs/adapters/payment.md diagram D3 specifies: dust floor, then the fee-multiple
19
+ * floor, then the fee ceiling (overridden only when the pool is running dry).
20
+ *
21
+ * `poolBalance` is null whenever the caller hasn't fetched it (no ceiling breach yet,
22
+ * the adapter has no `getPoolBalance`, or the asset has no `poolLiquidityFloor`) - null
23
+ * always means "the ceiling stays absolute", never an accidental override.
24
+ */
25
+ export function gateSweepBalance(args) {
26
+ if (moneyCompare(args.amount, args.minDeposit) < 0) {
27
+ return 'dust';
28
+ }
29
+ const feeFloor = moneyScaleBy(args.estimatedFee, args.feeMultiple);
30
+ if (moneyCompare(args.amount, feeFloor) < 0) {
31
+ return 'fee';
32
+ }
33
+ if (args.sweepFeeCeiling !== null && moneyCompare(args.estimatedFee, args.sweepFeeCeiling) > 0) {
34
+ const poolBelowFloor = args.poolLiquidityFloor !== null &&
35
+ args.poolBalance !== null &&
36
+ moneyCompare(args.poolBalance, args.poolLiquidityFloor) < 0;
37
+ if (!poolBelowFloor) {
38
+ return 'ceiling';
39
+ }
40
+ }
41
+ return 'sweep';
42
+ }
43
+ /**
44
+ * Owns the custody sweep cron: moves vendor-side per-player custody balances into the
45
+ * pooled account they're paid out of. Deliberately separate from WalletService (which
46
+ * is already ~2000 lines) and deliberately never touches wallet_balance/wallet_transaction
47
+ * - the player was credited at deposit time, this only moves the vendor's own money
48
+ * between its own containers. See docs/adapters/payment.md, "Custody: pooling, sweeping
49
+ * and reconciliation".
50
+ */
51
+ export class CustodySweepService {
52
+ drizzle;
53
+ paymentProviders;
54
+ audit;
55
+ platformConfig;
56
+ constructor({ drizzle, paymentProviders, audit, platformConfig }) {
57
+ this.drizzle = drizzle;
58
+ this.paymentProviders = paymentProviders;
59
+ this.audit = audit;
60
+ this.platformConfig = platformConfig;
61
+ }
62
+ /**
63
+ * Runs one sweep cycle. No-ops (returns null, touches nothing) when
64
+ * `platformConfig.wallet.sweep` is absent - an operator who hasn't configured sweep
65
+ * policy still gets a scheduled job, it just never claims a run. Also returns null
66
+ * when another cycle already owns the claim.
67
+ */
68
+ async runCycle(requestedRunId) {
69
+ const sweepConfig = this.platformConfig?.wallet?.sweep;
70
+ if (!sweepConfig) {
71
+ return null;
72
+ }
73
+ const claim = await this.claimRun(requestedRunId, sweepConfig.staleRunAfterMinutes);
74
+ if (!claim) {
75
+ return null;
76
+ }
77
+ const { runId, jobRunId } = claim;
78
+ const summary = {
79
+ considered: 0,
80
+ swept: 0,
81
+ skippedDust: 0,
82
+ skippedFee: 0,
83
+ skippedCeiling: 0,
84
+ inFlight: 0,
85
+ failed: 0,
86
+ unknown: 0,
87
+ };
88
+ // Everything past the claim runs guarded: an adapter that throws (a vendor 5xx is
89
+ // the ordinary case) would otherwise leave this run's row with finishedAt NULL, and
90
+ // the partial unique index would then block every subsequent cycle until the
91
+ // staleness takeover window elapsed. A failed cycle must free its own slot.
92
+ try {
93
+ await this.resolveInFlightSweeps(sweepConfig.concurrency);
94
+ const poolBalanceCache = new Map();
95
+ for (const providerName of this.paymentProviders.names()) {
96
+ const adapter = this.paymentProviders.get(providerName)?.adapter;
97
+ // sweepToPool is checked here, not after a claim row exists: an adapter that
98
+ // advertises listSweepableBalances without it would otherwise claim a container,
99
+ // throw, and park an `unknown` row that holds the in-flight guard forever.
100
+ if (!adapter?.listSweepableBalances) {
101
+ continue;
102
+ }
103
+ if (!adapter.sweepToPool) {
104
+ logger.error({ providerName }, 'provider lists sweepable balances but cannot sweep them; skipping');
105
+ continue;
106
+ }
107
+ // listSweepableBalances is unbounded; sweeping is throughput work, so the cron
108
+ // cadence drains the backlog rather than one cycle chasing it all.
109
+ const balances = (await adapter.listSweepableBalances()).slice(0, sweepConfig.batchSize);
110
+ summary.considered += balances.length;
111
+ await mapConcurrent(balances, sweepConfig.concurrency, (balance) => this.processBalance({
112
+ providerName,
113
+ adapter,
114
+ balance,
115
+ runId,
116
+ sweepConfig,
117
+ summary,
118
+ poolBalanceCache,
119
+ }));
120
+ }
121
+ }
122
+ catch (err) {
123
+ await this.finishRun(jobRunId, runId, summary, 'failed', err);
124
+ throw err;
125
+ }
126
+ await this.finishRun(jobRunId, runId, summary);
127
+ return { runId, summary };
128
+ }
129
+ // The insert IS the claim: the partial unique index on wallet_job_run(job_name) WHERE
130
+ // finished_at IS NULL means a conflicting insert can only mean another cycle already
131
+ // owns it. A run whose startedAt outlives `staleAfterMinutes` is presumed crashed and
132
+ // taken over: marked abandoned, then re-claimed inside the same transaction.
133
+ async claimRun(requestedRunId, staleAfterMinutes) {
134
+ const runId = requestedRunId ?? randomUUID();
135
+ return this.drizzle.db.transaction(async (txn) => {
136
+ const [inserted] = await txn
137
+ .insert(walletJobRun)
138
+ .values({ jobName: CUSTODY_SWEEP_JOB_NAME, runId })
139
+ .onConflictDoNothing()
140
+ .returning();
141
+ if (inserted) {
142
+ return { runId, jobRunId: inserted.id };
143
+ }
144
+ const [existing] = await txn
145
+ .select()
146
+ .from(walletJobRun)
147
+ .where(and(eq(walletJobRun.jobName, CUSTODY_SWEEP_JOB_NAME), isNull(walletJobRun.finishedAt)))
148
+ .for('update');
149
+ if (!existing) {
150
+ // The owning run finished between our failed insert and this read - let the
151
+ // next tick claim cleanly instead of racing a second insert here.
152
+ return null;
153
+ }
154
+ const staleMs = staleAfterMinutes * 60_000;
155
+ if (Date.now() - existing.startedAt.getTime() < staleMs) {
156
+ return null;
157
+ }
158
+ await txn
159
+ .update(walletJobRun)
160
+ .set({ status: 'abandoned', finishedAt: new Date() })
161
+ .where(eq(walletJobRun.id, existing.id));
162
+ const [takenOver] = await txn
163
+ .insert(walletJobRun)
164
+ .values({ jobName: CUSTODY_SWEEP_JOB_NAME, runId })
165
+ .returning();
166
+ if (!takenOver) {
167
+ throw new Error('wallet-custody-sweep: failed to claim run after abandoning a stale one');
168
+ }
169
+ return { runId, jobRunId: takenOver.id };
170
+ });
171
+ }
172
+ // Reusing getWithdrawalStatus for a sweep is deliberate: its {status, txHash} shape
173
+ // is generic to any vendor transaction (a withdrawal or a sweep), and a sweep's
174
+ // externalId is exactly the reference such a lookup needs.
175
+ async resolveInFlightSweeps(concurrency) {
176
+ const rows = await this.drizzle.db
177
+ .select()
178
+ .from(walletCustodySweep)
179
+ .where(and(inArray(walletCustodySweep.status, IN_FLIGHT_STATUSES), isNotNull(walletCustodySweep.externalId)));
180
+ await mapConcurrent(rows, concurrency, async (row) => {
181
+ const adapter = this.paymentProviders.get(row.providerName)?.adapter;
182
+ if (!adapter?.getWithdrawalStatus || !row.externalId) {
183
+ return;
184
+ }
185
+ const result = await adapter.getWithdrawalStatus(row.externalId);
186
+ if (!result || result.status === 'processing') {
187
+ return;
188
+ }
189
+ await this.drizzle.db
190
+ .update(walletCustodySweep)
191
+ .set({ status: result.status, txHash: result.txHash ?? row.txHash })
192
+ .where(eq(walletCustodySweep.id, row.id));
193
+ });
194
+ }
195
+ async assetFor(currency, network) {
196
+ const [row] = await this.drizzle.db
197
+ .select()
198
+ .from(walletAsset)
199
+ .where(and(eq(walletAsset.currency, currency), eq(walletAsset.network, network)));
200
+ return row ?? null;
201
+ }
202
+ async hasInFlightSweep(userId, currency, network) {
203
+ const [row] = await this.drizzle.db
204
+ .select({ id: walletCustodySweep.id })
205
+ .from(walletCustodySweep)
206
+ .where(and(eq(walletCustodySweep.userId, userId), eq(walletCustodySweep.currency, currency), eq(walletCustodySweep.network, network), inArray(walletCustodySweep.status, IN_FLIGHT_STATUSES)));
207
+ return row !== undefined;
208
+ }
209
+ async getPoolBalanceCached(cache, adapter, currency, network) {
210
+ if (!adapter.getPoolBalance) {
211
+ return null;
212
+ }
213
+ const key = `${currency}:${network}`;
214
+ const cached = cache.get(key);
215
+ if (cached !== undefined) {
216
+ return cached;
217
+ }
218
+ const balance = await adapter.getPoolBalance(currency, network);
219
+ cache.set(key, balance);
220
+ return balance;
221
+ }
222
+ async processBalance({ providerName, adapter, balance, runId, sweepConfig, summary, poolBalanceCache, }) {
223
+ const asset = await this.assetFor(balance.currency, balance.network);
224
+ if (!asset) {
225
+ // Funds sitting in a container the operator has no policy for must be visible,
226
+ // not a log line.
227
+ await this.drizzle.db
228
+ .insert(walletReconciliationFinding)
229
+ .values({
230
+ runId,
231
+ providerName,
232
+ kind: 'unconfigured_asset',
233
+ currency: balance.currency,
234
+ network: balance.network,
235
+ amount: balance.amount,
236
+ // The dedup key for the partial unique index on (kind, externalId). This
237
+ // finding has no vendor reference, and the condition recurs every single
238
+ // cycle until an operator configures the asset - without a stable stand-in
239
+ // one missing catalog row files a finding every cron tick, drowning the real
240
+ // findings and pinning the alert threshold permanently over the line. The
241
+ // asset, not the player, is the subject: one row to act on, not one per
242
+ // affected container.
243
+ externalId: `unconfigured:${providerName}:${balance.currency}:${balance.network}`,
244
+ detail: `no wallet_asset configured for ${balance.currency}/${balance.network}`,
245
+ })
246
+ .onConflictDoNothing();
247
+ return;
248
+ }
249
+ const gateArgs = {
250
+ amount: balance.amount,
251
+ estimatedFee: balance.estimatedFee,
252
+ minDeposit: asset.minDeposit,
253
+ feeMultiple: sweepConfig.feeMultiple,
254
+ sweepFeeCeiling: asset.sweepFeeCeiling,
255
+ poolLiquidityFloor: asset.poolLiquidityFloor,
256
+ };
257
+ let decision = gateSweepBalance({ ...gateArgs, poolBalance: null });
258
+ // Only fetch the pool balance when the ceiling actually blocks - it's an extra
259
+ // vendor call, not a free one.
260
+ if (decision === 'ceiling' && asset.poolLiquidityFloor) {
261
+ const poolBalance = await this.getPoolBalanceCached(poolBalanceCache, adapter, balance.currency, balance.network);
262
+ decision = gateSweepBalance({ ...gateArgs, poolBalance });
263
+ }
264
+ if (decision === 'dust') {
265
+ summary.skippedDust += 1;
266
+ return;
267
+ }
268
+ if (decision === 'fee') {
269
+ summary.skippedFee += 1;
270
+ return;
271
+ }
272
+ if (decision === 'ceiling') {
273
+ summary.skippedCeiling += 1;
274
+ return;
275
+ }
276
+ if (await this.hasInFlightSweep(balance.userId, balance.currency, balance.network)) {
277
+ summary.inFlight += 1;
278
+ return;
279
+ }
280
+ const [claimed] = await this.drizzle.db
281
+ .insert(walletCustodySweep)
282
+ .values({
283
+ userId: balance.userId,
284
+ providerName,
285
+ currency: balance.currency,
286
+ network: balance.network,
287
+ amount: balance.amount,
288
+ estimatedFee: balance.estimatedFee,
289
+ status: 'pending',
290
+ runId,
291
+ })
292
+ .onConflictDoNothing()
293
+ .returning();
294
+ if (!claimed) {
295
+ // Another cycle claimed this (userId, currency, network) between the check above
296
+ // and this insert - the partial unique index is the real guard, this is a race.
297
+ summary.inFlight += 1;
298
+ return;
299
+ }
300
+ // Deliberately outside any transaction - sweepToPool is a real vendor call
301
+ // (docs/standards/money.md: treat external payment calls as non-transactional).
302
+ // The claim row above already holds the durable guard.
303
+ try {
304
+ const result = await adapter.sweepToPool?.(balance, { idempotencyKey: claimed.id });
305
+ if (!result) {
306
+ throw new Error(`provider "${providerName}" advertised listSweepableBalances but has no sweepToPool`);
307
+ }
308
+ await this.drizzle.db
309
+ .update(walletCustodySweep)
310
+ // poolRef records WHICH pool received the funds, not just that a transfer
311
+ // happened. Player funds must stay separate from operator funds, and that is
312
+ // the question a regulator asks; without it the ledger cannot answer it.
313
+ .set({
314
+ status: 'processing',
315
+ externalId: result.externalId,
316
+ poolRef: result.poolRef ?? null,
317
+ })
318
+ .where(eq(walletCustodySweep.id, claimed.id));
319
+ summary.swept += 1;
320
+ }
321
+ catch (err) {
322
+ // A thrown sweepToPool cannot distinguish "the vendor never saw it" from "the
323
+ // vendor accepted it and the response was lost" - moving to `failed` on the
324
+ // second case would let the next cycle sweep the same container again and
325
+ // double-transfer real custody funds. `unknown` keeps the in-flight guard held
326
+ // (see IN_FLIGHT_STATUSES) until reconciliation or an operator resolves it.
327
+ logger.warn({ err, sweepId: claimed.id }, 'sweepToPool threw; parking sweep as unknown');
328
+ await this.drizzle.db
329
+ .update(walletCustodySweep)
330
+ .set({ status: 'unknown' })
331
+ .where(eq(walletCustodySweep.id, claimed.id));
332
+ summary.unknown += 1;
333
+ }
334
+ }
335
+ async finishRun(jobRunId, runId, summary, status = 'completed', err) {
336
+ const error = err === undefined ? {} : { error: err instanceof Error ? err.message : String(err) };
337
+ await this.drizzle.db.transaction(async (txn) => {
338
+ await txn
339
+ .update(walletJobRun)
340
+ .set({ finishedAt: new Date(), status, summary: { ...summary, ...error } })
341
+ .where(eq(walletJobRun.id, jobRunId));
342
+ // One entry for the whole cycle, never one per swept balance -
343
+ // AuditService.recordInTransaction takes a single global advisory lock (the audit
344
+ // log is a hash chain), so one row per container at thousands of containers would
345
+ // serialize the entire platform's audit stream behind this job. wallet_custody_sweep
346
+ // rows are the per-move record; this is the cycle record, joined on runId.
347
+ await this.audit.recordInTransaction(txn, {
348
+ actorType: 'system',
349
+ action: 'wallet.custody.sweep_cycle',
350
+ resourceType: 'wallet_job_run',
351
+ resourceId: runId,
352
+ after: { runId, status, ...summary, ...error },
353
+ });
354
+ });
355
+ }
356
+ }
357
+ //# sourceMappingURL=custody-sweep.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custody-sweep.service.js","sourceRoot":"","sources":["../../../src/wallet/service/custody-sweep.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,UAAU,GAQX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,2BAA2B,GAG5B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAEpD,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;iBACN,MAAM,CAAC,YAAY,CAAC;iBACpB,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC;iBAC1E,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;YACxC,+DAA+D;YAC/D,kFAAkF;YAClF,kFAAkF;YAClF,qFAAqF;YACrF,2EAA2E;YAC3E,MAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE;gBACxC,SAAS,EAAE,QAAQ;gBACnB,MAAM,EAAE,4BAA4B;gBACpC,YAAY,EAAE,gBAAgB;gBAC9B,UAAU,EAAE,KAAK;gBACjB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE;aAC/C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openora/core",
3
- "version": "0.4.1-canary.93",
3
+ "version": "0.4.1-canary.94",
4
4
  "description": "Open-source, headless, plugin-based, AI-native iGaming framework - domain modules, plugin engine, Zod-first contracts, typed React SDK",
5
5
  "keywords": [
6
6
  "ai-native",