@dvmkit/sdk 0.1.5-rc.8 → 0.2.0-rc.9
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.
- package/README.md +12 -0
- package/dist/{chunk-BIP6G74V.js → chunk-2ATUAUAO.js} +8 -8
- package/dist/{chunk-27V2ILSR.js → chunk-4A2RAKCW.js} +2 -2
- package/dist/{chunk-EVBK675R.js → chunk-6GRIKOFB.js} +28 -23
- package/dist/{chunk-CEOAHV2I.js → chunk-FDKRXOZO.js} +0 -5
- package/dist/{chunk-L4OYF4DQ.js → chunk-FT6HTUM4.js} +1 -1
- package/dist/{chunk-BTZY7VPH.js → chunk-GAIPXGM3.js} +1 -1
- package/dist/{chunk-U6M3ATSG.js → chunk-JDT5LCJC.js} +40 -6
- package/dist/{chunk-FROTD5XQ.js → chunk-JLXYOV4Y.js} +1 -2
- package/dist/{chunk-M7LHFJ5K.js → chunk-KMZXTBLA.js} +2 -2
- package/dist/{chunk-6BQM7TOW.js → chunk-L67WTZX2.js} +3 -7
- package/dist/{chunk-CGKZDODG.js → chunk-MG67KXU7.js} +0 -5
- package/dist/{chunk-JZWELPFH.js → chunk-MRAGS5VP.js} +1 -1
- package/dist/{chunk-2UUXIIOC.js → chunk-O2X2CCKH.js} +3 -3
- package/dist/{chunk-TQWGQCNV.js → chunk-OMIQMMME.js} +3 -3
- package/dist/{chunk-UB5FZ43T.js → chunk-PCUQZDZA.js} +475 -366
- package/dist/{chunk-KVEHHC7W.js → chunk-PHHAYRQV.js} +7 -9
- package/dist/{chunk-SSSZUVWM.js → chunk-QP53RWAD.js} +88 -38
- package/dist/{chunk-DMNLFNTW.js → chunk-QT4ONTST.js} +1 -1
- package/dist/{chunk-RW5LP57K.js → chunk-SDK6KDJN.js} +0 -1
- package/dist/{chunk-MLRCSJYX.js → chunk-V7EVFLAK.js} +87 -90
- package/dist/{chunk-E4EVGPDX.js → chunk-XQXJKJ3P.js} +0 -2
- package/dist/{credit-ledger-2DFQHNLB.js → credit-ledger-5ZEJRI46.js} +1 -1
- package/dist/{credit-menu-s5HmGCqx.d.ts → credit-menu-D4Gcdgc4.d.ts} +488 -644
- package/dist/{fx-D860pZvP.d.ts → fx-B0SLBe5x.d.ts} +38 -82
- package/dist/index.d.ts +11 -14
- package/dist/index.js +2 -2
- package/dist/internal/caller.d.ts +618 -1525
- package/dist/internal/caller.js +28 -60
- package/dist/internal/server.d.ts +36 -61
- package/dist/internal/server.js +11 -11
- package/dist/{job-store-BUGqvCfL.d.ts → job-store-B2uZvga4.d.ts} +70 -59
- package/dist/{lightning-backend-BozcevPZ.d.ts → lightning-backend-CQBnQgsT.d.ts} +19 -27
- package/dist/{memory-credit-ledger-MNUOTQO5.js → memory-credit-ledger-ZOH6C3N4.js} +2 -2
- package/dist/{mpp-setup-4FJD6ZHV.js → mpp-setup-IOJBF7DB.js} +1 -1
- package/dist/{payout-reporter-RG6XNGPI.js → payout-reporter-5PIRYFVQ.js} +1 -1
- package/dist/{postgres-consumed-credential-store-VHBT4KEA.js → postgres-consumed-credential-store-ISRHBMOU.js} +1 -1
- package/dist/{postgres-job-store-3RAXMNSY.js → postgres-job-store-OGQ6IT4U.js} +1 -1
- package/dist/{postgres-kv-store-JFBDP5IP.js → postgres-kv-store-D5E2EZ24.js} +1 -1
- package/dist/{postgres-replay-store-UJXRT6VO.js → postgres-replay-store-IZFLTTAC.js} +1 -1
- package/dist/{pricing-4CEB34RM.js → pricing-MU5GNUJZ.js} +1 -1
- package/dist/{processed-payment-store-HAA4SFNK.js → processed-payment-store-FIDI3RNH.js} +1 -1
- package/dist/{revenue-reporter-ASZ7SHHH.js → revenue-reporter-NNCNRY4C.js} +1 -1
- package/dist/server/index.d.ts +53 -59
- package/dist/server/index.js +38 -37
- package/dist/{ssrf-DbFkpDv0.d.ts → ssrf-dMooihtY.d.ts} +1 -2
- package/dist/{step-cache-5dljDqrQ.d.ts → step-cache-CXg7ziML.d.ts} +389 -551
- package/dist/{tempo-charge-store-RIFTALZK.js → tempo-charge-store-76TDAF34.js} +1 -1
- package/dist/{tempo-lifecycle-DFIXQ54Q.js → tempo-lifecycle-DXM7QXJQ.js} +3 -3
- package/dist/{tempo-wallet-4QKSV65O.js → tempo-wallet-O67H5M4N.js} +2 -2
- package/dist/testing/index.d.ts +5 -15
- package/dist/testing/index.js +4 -11
- package/dist/{usd-DoRuAckA.d.ts → usd-BNDg1715.d.ts} +14 -16
- package/dist/{wallet-CJC8lwxx.d.ts → wallet-Dwjs5n_M.d.ts} +1 -1
- package/dist/{x402-5H27DCBE.js → x402-7S2EFINY.js} +2 -2
- package/package.json +2 -1
|
@@ -208,7 +208,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
208
208
|
*
|
|
209
209
|
* Both accessors run on the settlement pool: every caller reads or writes the
|
|
210
210
|
* marker while {@link withFleetSettlementLock} holds a host-pool client, which
|
|
211
|
-
* is the nesting the
|
|
211
|
+
* is the nesting the split exists to keep off a non-terminal pool.
|
|
212
212
|
*/
|
|
213
213
|
async isSettlePending(scope) {
|
|
214
214
|
const reader = await this.settlementWriter();
|
|
@@ -235,9 +235,9 @@ var PostgresX402ChannelStorage = class {
|
|
|
235
235
|
*
|
|
236
236
|
* On the dedicated settlement pool like every other marker, and for a sharper
|
|
237
237
|
* reason than they had: this and {@link prepareSettlement} now run *inside*
|
|
238
|
-
* the channel transaction
|
|
238
|
+
* the channel transaction, which holds a host-pool client for its
|
|
239
239
|
* whole duration. Taking a second client from that same pool is the
|
|
240
|
-
* self-deadlock
|
|
240
|
+
* self-deadlock fixed — at pool max every client is a holder and a
|
|
241
241
|
* waiter — and moving these calls under the transaction is exactly what would
|
|
242
242
|
* reintroduce it.
|
|
243
243
|
*/
|
|
@@ -250,7 +250,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* The refund on this channel that is neither finished nor abandoned, if there
|
|
253
|
-
* is one — the credit ledger's spend gate
|
|
253
|
+
* is one — the credit ledger's spend gate.
|
|
254
254
|
*
|
|
255
255
|
* `statuses` is the caller's, because the two gates disagree by design: a
|
|
256
256
|
* draw is blocked by {@link X402_SPEND_BLOCKING_SETTLEMENT_STATUSES}, a fresh
|
|
@@ -258,12 +258,12 @@ var PostgresX402ChannelStorage = class {
|
|
|
258
258
|
*
|
|
259
259
|
* On the dedicated settlement pool, and that is what makes the gate callable
|
|
260
260
|
* at all: a draw routinely runs inside an open channel transaction holding a
|
|
261
|
-
* host-pool client, and taking a second one from that pool is the
|
|
261
|
+
* host-pool client, and taking a second one from that pool is the
|
|
262
262
|
* self-deadlock. The oldest blocking row wins, so a channel that somehow
|
|
263
263
|
* accumulated two names the one an operator should reach for first.
|
|
264
264
|
*
|
|
265
265
|
* Projects three columns rather than decoding a whole {@link
|
|
266
|
-
* X402SettlementIntent}: the decoder refuses a
|
|
266
|
+
* X402SettlementIntent}: the decoder refuses a legacy row that carries
|
|
267
267
|
* no reconciliation snapshot, and a gate that throws on one would take every
|
|
268
268
|
* draw on that channel down with it — when the row is exactly the kind that
|
|
269
269
|
* ought to block them.
|
|
@@ -282,7 +282,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Read one settlement by its own identifier — the handle an operator holds
|
|
285
|
-
*
|
|
285
|
+
* Same dedicated pool as {@link getSettlement}, for the same
|
|
286
286
|
* reason: the repair reads this while a channel transaction may be open.
|
|
287
287
|
*/
|
|
288
288
|
async getSettlementById(settlementId) {
|
|
@@ -308,7 +308,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* The operator's repair queue: settlements stuck between "chain paid" and
|
|
311
|
-
* "ledger booked", oldest write first
|
|
311
|
+
* "ledger booked", oldest write first.
|
|
312
312
|
*
|
|
313
313
|
* Keyset-paginated on `(created_at, settlement_id)` for the reason the
|
|
314
314
|
* blocked-invoice queue is: a wedged row never self-clears, so a fixed first
|
|
@@ -350,7 +350,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
|
-
* Close a wedged settlement without booking anything
|
|
353
|
+
* Close a wedged settlement without booking anything.
|
|
354
354
|
*
|
|
355
355
|
* A single-statement CAS on the wedged statuses, on the settlement pool —
|
|
356
356
|
* there is no ledger effect to be atomic with, which is the whole point:
|
|
@@ -460,7 +460,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
460
460
|
* Mark that the next operation is the ambiguous external-call boundary.
|
|
461
461
|
*
|
|
462
462
|
* `channelAtSubmission` is the live channel the facilitator is about to size
|
|
463
|
-
* and sign the settlement against
|
|
463
|
+
* and sign the settlement against — bookmarked here, with the
|
|
464
464
|
* block height, because these two are the only description of that instant
|
|
465
465
|
* that survives the call.
|
|
466
466
|
*/
|
|
@@ -521,7 +521,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
521
521
|
/**
|
|
522
522
|
* Mark the external settlement and ledger effect complete in the active transaction.
|
|
523
523
|
*
|
|
524
|
-
* `resolvedAtMs` is set only by the operator repair
|
|
524
|
+
* `resolvedAtMs` is set only by the operator repair, so an audit
|
|
525
525
|
* read can tell a settlement that completed on its own from one a human had
|
|
526
526
|
* to finish.
|
|
527
527
|
*/
|
|
@@ -591,7 +591,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
591
591
|
* this is how the settlement layer says "this exact decrease is the one the
|
|
592
592
|
* payer's verified refund voucher authorises". Outside this scope a decrease
|
|
593
593
|
* of `chargedCumulativeAmount` is refused flat, which is what keeps the
|
|
594
|
-
* arbitrary-decrease guard meaningful
|
|
594
|
+
* arbitrary-decrease guard meaningful.
|
|
595
595
|
*/
|
|
596
596
|
withSanctionedRefundBase(base, operation) {
|
|
597
597
|
return this.refundBase.run(base, operation);
|
|
@@ -617,7 +617,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
617
617
|
* The lock is session-scoped, so its client stays checked out for the whole
|
|
618
618
|
* operation — and `operation()` (upstream's claim/settle) re-enters the pool
|
|
619
619
|
* through {@link updateChannel}. Two bounds keep that from wedging the pool
|
|
620
|
-
*
|
|
620
|
+
* local callers are serialized in-process, so this holds at most
|
|
621
621
|
* one client per process no matter how many requests arrive, and a waiting
|
|
622
622
|
* acquire carries a `lock_timeout` so a wedged fleet-mate can't pin that
|
|
623
623
|
* client — and the caller's request — indefinitely. A timeout reports the
|
|
@@ -640,7 +640,7 @@ var PostgresX402ChannelStorage = class {
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
/**
|
|
643
|
-
* Hold the fleet-wide self-relay submission lock for one chain submission
|
|
643
|
+
* Hold the fleet-wide self-relay submission lock for one chain submission.
|
|
644
644
|
*
|
|
645
645
|
* The session lock keeps one per-DVM gas EOA to one in-flight submission
|
|
646
646
|
* across the whole fleet — two machines submitting at once collide on the
|
|
@@ -997,14 +997,13 @@ var CreditLedger = class {
|
|
|
997
997
|
tempoSessionStore;
|
|
998
998
|
/**
|
|
999
999
|
* Postgres-backed: balances survive a restart and are shared across the
|
|
1000
|
-
* fleet, so this DVM may advertise credit
|
|
1000
|
+
* fleet, so this DVM may advertise credit.
|
|
1001
1001
|
*/
|
|
1002
1002
|
durable = true;
|
|
1003
1003
|
x402Settlements;
|
|
1004
1004
|
expiryReleaseOutbox;
|
|
1005
1005
|
/**
|
|
1006
1006
|
* Bind the durable x402 settlement state this ledger gates spending on
|
|
1007
|
-
* (internal-review).
|
|
1008
1007
|
*
|
|
1009
1008
|
* Late, because the settlement store is built with the batch-settlement
|
|
1010
1009
|
* server, which is built *after* the ledger it reads earned draws from. An
|
|
@@ -1016,11 +1015,11 @@ var CreditLedger = class {
|
|
|
1016
1015
|
}
|
|
1017
1016
|
/**
|
|
1018
1017
|
* Bind the durable outbox that reports credit-expiry releases and their
|
|
1019
|
-
* revivals to the platform
|
|
1018
|
+
* revivals to the platform.
|
|
1020
1019
|
*
|
|
1021
1020
|
* Held on the ledger rather than threaded through {@link fund} for the same
|
|
1022
1021
|
* reason as the gate above: the revival half fires from *every* funding path
|
|
1023
|
-
*
|
|
1022
|
+
* Cashu commit, x402 exact and channel, Tempo, the Lightning invoice
|
|
1024
1023
|
* settle, the implicit N=1 per-call payment — and a seam each of those has to
|
|
1025
1024
|
* remember to pass is a seam one of them will eventually forget.
|
|
1026
1025
|
*
|
|
@@ -1036,7 +1035,7 @@ var CreditLedger = class {
|
|
|
1036
1035
|
async init() {
|
|
1037
1036
|
await withSdkInitLock(this.pool, () => this.createTables());
|
|
1038
1037
|
}
|
|
1039
|
-
/** The boot DDL itself — always runs under {@link withSdkInitLock}
|
|
1038
|
+
/** The boot DDL itself — always runs under {@link withSdkInitLock}. */
|
|
1040
1039
|
async createTables() {
|
|
1041
1040
|
await this.pool.query(`
|
|
1042
1041
|
CREATE TABLE IF NOT EXISTS credits (
|
|
@@ -1314,7 +1313,7 @@ var CreditLedger = class {
|
|
|
1314
1313
|
);
|
|
1315
1314
|
}
|
|
1316
1315
|
/**
|
|
1317
|
-
* Give every open non-channel Bitcoin credit a funding lot
|
|
1316
|
+
* Give every open non-channel Bitcoin credit a funding lot.
|
|
1318
1317
|
*
|
|
1319
1318
|
* Runs inside the boot DDL, is guarded per credit by `NOT EXISTS`, and is
|
|
1320
1319
|
* therefore both the one-time migration and a standing self-heal for a
|
|
@@ -1325,12 +1324,12 @@ var CreditLedger = class {
|
|
|
1325
1324
|
* `{amount_micro, rail}` — no instrument amount at all — and is not written
|
|
1326
1325
|
* on every funding path, whereas `msats_remaining` **is** the credit's
|
|
1327
1326
|
* current unspent rail value, maintained pro rata on every draw since
|
|
1328
|
-
*
|
|
1327
|
+
* One synthetic lot pairing it with `balance_micro` therefore
|
|
1329
1328
|
* reproduces today's in-kind position exactly, and FIFO over a single lot is
|
|
1330
1329
|
* trivially correct. Historic per-funding rates are unrecoverable and would
|
|
1331
1330
|
* change nothing: only the remaining position is owed.
|
|
1332
1331
|
*
|
|
1333
|
-
* The semantics change is deliberately retroactive
|
|
1332
|
+
* The semantics change is deliberately retroactive — every
|
|
1334
1333
|
* current holder is first-party, so there is one regime and no legacy
|
|
1335
1334
|
* branch.
|
|
1336
1335
|
*/
|
|
@@ -1370,31 +1369,31 @@ var CreditLedger = class {
|
|
|
1370
1369
|
/**
|
|
1371
1370
|
* Create a credit, or top up an existing one (same `creditId`). Top-ups add
|
|
1372
1371
|
* to the balance and overwrite `expiry_ms` with the provided value — funding
|
|
1373
|
-
* an expired credit revives it (
|
|
1372
|
+
* an expired credit revives it (the caller-ownership contract carry-forward: the credit is a
|
|
1374
1373
|
* rolling buffer, not per-job escrow). The existing row's `caller_pubkey`
|
|
1375
1374
|
* and `currency` must match or the fund is refused with a typed error —
|
|
1376
1375
|
* without that check a top-up against someone else's `credit_id` would
|
|
1377
1376
|
* silently merge two callers' money.
|
|
1378
1377
|
*
|
|
1379
1378
|
* Pass `tx` (a client inside a caller-owned `BEGIN`) to commit the rail
|
|
1380
|
-
* receive and the ledger credit atomically (spec condition 3 — the
|
|
1379
|
+
* receive and the ledger credit atomically (spec condition 3 — the
|
|
1381
1380
|
* verifier does this). The ledger issues **no** transaction control on `tx`.
|
|
1382
1381
|
*
|
|
1383
1382
|
* Without `tx` it opens one of its own, because a funding is no longer a
|
|
1384
1383
|
* single statement: it upserts the credit, records its funding lot
|
|
1385
|
-
*
|
|
1384
|
+
* and reverses any standing expiry release — and that
|
|
1386
1385
|
* last leg restores balance and queues a report. A crash between the upsert
|
|
1387
1386
|
* and the reversal would leave a revived credit whose release still stands,
|
|
1388
1387
|
* which the sweep's own exclusion then makes permanent: `balance_micro > 0`
|
|
1389
1388
|
* but a standing release means it is neither drainable nor re-releasable.
|
|
1390
1389
|
*
|
|
1391
|
-
* `basis` records the rail value behind the fiat
|
|
1390
|
+
* `basis` records the rail value behind the fiat so each draw can
|
|
1392
1391
|
* be allocated its share of the rail-native amount actually received. A
|
|
1393
1392
|
* top-up on a different rail than the credit's is refused with
|
|
1394
1393
|
* `rail_mismatch`: sats and USDC microunits aren't summable, so a blended
|
|
1395
1394
|
* credit would have no coherent native basis to allocate from.
|
|
1396
1395
|
*
|
|
1397
|
-
* It is **required
|
|
1396
|
+
* It is **required**, in the type and again at runtime via
|
|
1398
1397
|
* {@link assertFundingBasis}. A basis-less fund wrote `rail = NULL`, and a
|
|
1399
1398
|
* draw against such a credit settles — a real debit — while
|
|
1400
1399
|
* `railAsFundingMethod` correctly declines to guess a rail, so `bookRevenue`
|
|
@@ -1405,7 +1404,7 @@ var CreditLedger = class {
|
|
|
1405
1404
|
* typed top-up via the `COALESCE` below.
|
|
1406
1405
|
*
|
|
1407
1406
|
* The rail-native **instrument** is pinned at first funding too, and both
|
|
1408
|
-
* channel guards are symmetric for the same reason
|
|
1407
|
+
* channel guards are symmetric for the same reason. A reusable
|
|
1409
1408
|
* channel — Tempo session or x402 batch-settlement — may only ever top up
|
|
1410
1409
|
* the credit it opened, and a credit opened by a one-shot (a Tempo charge, an
|
|
1411
1410
|
* x402 exact authorization) may never adopt one. The x402 half used to admit
|
|
@@ -1419,7 +1418,7 @@ var CreditLedger = class {
|
|
|
1419
1418
|
* one-credit-per-channel, not one-source-per-credit.
|
|
1420
1419
|
*
|
|
1421
1420
|
* An x402 channel deposit is additionally refused `settlement_pending` while
|
|
1422
|
-
* that channel carries an unresolved refund
|
|
1421
|
+
* that channel carries an unresolved refund — see the gate read
|
|
1423
1422
|
* below. This method is the authority on that rule, as it is on the binding
|
|
1424
1423
|
* rules above; every door preflights it where a refusal is still free.
|
|
1425
1424
|
*/
|
|
@@ -1592,12 +1591,12 @@ var CreditLedger = class {
|
|
|
1592
1591
|
}
|
|
1593
1592
|
/**
|
|
1594
1593
|
* Undo any expiry release this credit still carries, because a funding just
|
|
1595
|
-
* landed on it (
|
|
1594
|
+
* landed on it (the revival rule), restoring the balance the
|
|
1596
1595
|
* release took.
|
|
1597
1596
|
*
|
|
1598
1597
|
* A release records the credit's **final** undrawn remainder and zeroes it
|
|
1599
1598
|
* (see {@link releaseExpiredCreditLocked}). Funding adds to the balance and
|
|
1600
|
-
* overwrites `expiry_ms` (
|
|
1599
|
+
* overwrites `expiry_ms` (the caller-ownership contract carry-forward: the credit is a rolling
|
|
1601
1600
|
* buffer), so the moment money arrives the recorded remainder is no longer
|
|
1602
1601
|
* final: the release stops counting and its micro come back.
|
|
1603
1602
|
*
|
|
@@ -1616,8 +1615,8 @@ var CreditLedger = class {
|
|
|
1616
1615
|
* re-derives it.
|
|
1617
1616
|
*
|
|
1618
1617
|
* @returns the credit row as the restore left it, or undefined when there was
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1618
|
+
* nothing to reverse. The caller reads its snapshot off this rather than off
|
|
1619
|
+
* the funding upsert's `RETURNING`, which predates the restore.
|
|
1621
1620
|
*/
|
|
1622
1621
|
async reverseExpiryReleases(q, creditId, nowMs) {
|
|
1623
1622
|
const { rows } = await q.query(
|
|
@@ -1643,7 +1642,7 @@ var CreditLedger = class {
|
|
|
1643
1642
|
}
|
|
1644
1643
|
/**
|
|
1645
1644
|
* Release the undrawn remainder of every credit whose TTL has run out
|
|
1646
|
-
*
|
|
1645
|
+
* Returns the releases this pass recorded.
|
|
1647
1646
|
*
|
|
1648
1647
|
* **What is released.** The credit's whole `balance_micro`. Expiry ends
|
|
1649
1648
|
* spending but never ownership of the record, so the balance stays readable;
|
|
@@ -1660,7 +1659,7 @@ var CreditLedger = class {
|
|
|
1660
1659
|
* runs above the expiry check, so a lost response is still recoverable), so
|
|
1661
1660
|
* the remainder is not final while a hold is outstanding. Skipping costs one
|
|
1662
1661
|
* sweep interval and keeps the released figure exactly "what nothing bought";
|
|
1663
|
-
* holds do resolve — the orphan-draw watchdog
|
|
1662
|
+
* holds do resolve — the orphan-draw watchdog is what guarantees
|
|
1664
1663
|
* a stranded one still reaches a terminal state.
|
|
1665
1664
|
*
|
|
1666
1665
|
* **Idempotent** two ways. `release_id` is derived from the expiry instant,
|
|
@@ -1779,7 +1778,7 @@ var CreditLedger = class {
|
|
|
1779
1778
|
return row;
|
|
1780
1779
|
}
|
|
1781
1780
|
/**
|
|
1782
|
-
* Record this funding's in-kind basis as a lot
|
|
1781
|
+
* Record this funding's in-kind basis as a lot.
|
|
1783
1782
|
*
|
|
1784
1783
|
* Called from inside {@link fund}, on the same handle, so the lot shares
|
|
1785
1784
|
* whatever transaction the rail opened — `withCommitTx` for Cashu,
|
|
@@ -1839,11 +1838,11 @@ var CreditLedger = class {
|
|
|
1839
1838
|
* placed pre-expiry must stay recoverable after the credit expires, or the
|
|
1840
1839
|
* DVM holds a debit the caller can never reconcile. Fresh draws on an
|
|
1841
1840
|
* expired credit are refused with `credit_expired`; the balance stays
|
|
1842
|
-
* intact and readable (
|
|
1841
|
+
* intact and readable (the caller-ownership contract: expiry ends spending, never ownership).
|
|
1843
1842
|
*
|
|
1844
1843
|
* Pass `tx` (a client inside a caller-owned `BEGIN`) to place the hold in
|
|
1845
1844
|
* the same transaction as the rail commit and the `fund` upsert (spec
|
|
1846
|
-
* condition 3 — the
|
|
1845
|
+
* condition 3 — the implicit N=1 path). The ledger issues no
|
|
1847
1846
|
* transaction control on `tx`; the `SELECT … FOR UPDATE` row lock is still
|
|
1848
1847
|
* taken on the caller's transaction, so the locking invariant holds.
|
|
1849
1848
|
*/
|
|
@@ -1962,12 +1961,12 @@ var CreditLedger = class {
|
|
|
1962
1961
|
}
|
|
1963
1962
|
/**
|
|
1964
1963
|
* The unresolved refund on `channelId` that must stop this ledger effect, if
|
|
1965
|
-
* any
|
|
1964
|
+
* any.
|
|
1966
1965
|
*
|
|
1967
1966
|
* `undefined` whenever there is nothing to ask — an unbound credit, or a DVM
|
|
1968
1967
|
* with no durable settlement store, where a settlement row cannot exist.
|
|
1969
1968
|
*
|
|
1970
|
-
* Public since
|
|
1969
|
+
* Public since the behavior was introduced, so `/v1/credit`'s pre-payment preflight can ask the
|
|
1971
1970
|
* same question `fund` will ask from inside the rail transaction — one read,
|
|
1972
1971
|
* one answer, rather than a second copy of the rule in the routes.
|
|
1973
1972
|
*/
|
|
@@ -1976,7 +1975,7 @@ var CreditLedger = class {
|
|
|
1976
1975
|
return this.x402Settlements.pendingRefundSettlement(channelId, statuses);
|
|
1977
1976
|
}
|
|
1978
1977
|
/**
|
|
1979
|
-
* Grow a pending draw by `addAmountMicro`
|
|
1978
|
+
* Grow a pending draw by `addAmountMicro` — the ledger half of a
|
|
1980
1979
|
* mid-job `requestPayment` top-up. One job keeps **one** draw: the mid-job
|
|
1981
1980
|
* money funds the same credit and enlarges the hold the upfront leg placed,
|
|
1982
1981
|
* so the receipt's `ReceiptCredit` block countersigns the job's full cost
|
|
@@ -1995,7 +1994,7 @@ var CreditLedger = class {
|
|
|
1995
1994
|
* The increment's rail value comes from {@link growthRailValue}: earmarked
|
|
1996
1995
|
* to the funding that backs it when the caller names one (the mid-job case),
|
|
1997
1996
|
* pro-rata otherwise. Either way the draws of a credit keep summing to
|
|
1998
|
-
* precisely what the rails paid
|
|
1997
|
+
* precisely what the rails paid.
|
|
1999
1998
|
*
|
|
2000
1999
|
* **`ledger_seq` is not re-taken.** The per-credit sequence is gap-free
|
|
2001
2000
|
* (`credit_draws_seq_uidx`), so moving this draw forward would strand its
|
|
@@ -2013,8 +2012,8 @@ var CreditLedger = class {
|
|
|
2013
2012
|
* the whole transaction back on replay; x402/mpp collide on the
|
|
2014
2013
|
* `processed_payments` marker). Never call it outside a rail commit.
|
|
2015
2014
|
*
|
|
2016
|
-
* **`capMicro` bounds cumulative growth at what the job cumulatively asked
|
|
2017
|
-
*
|
|
2015
|
+
* **`capMicro` bounds cumulative growth at what the job cumulatively asked,**
|
|
2016
|
+
* and it is the only ceiling that can refuse a top-up: the
|
|
2018
2017
|
* available-balance check cannot, because the `fund` a moment earlier in
|
|
2019
2018
|
* this same transaction raised the balance by exactly the amount being
|
|
2020
2019
|
* drawn. Excess is **granted partially or not at all rather than thrown** —
|
|
@@ -2204,7 +2203,7 @@ var CreditLedger = class {
|
|
|
2204
2203
|
}
|
|
2205
2204
|
/**
|
|
2206
2205
|
* Release a pending draw: the hold evaporates, the balance is untouched —
|
|
2207
|
-
* this is how "no debit on job failure" is mechanically real (
|
|
2206
|
+
* this is how "no debit on job failure" is mechanically real (the credit lifecycle contract).
|
|
2208
2207
|
* Idempotent: releasing a released draw returns the original tuple. A
|
|
2209
2208
|
* settled draw cannot be released (`invalid_draw_state`) — un-settling
|
|
2210
2209
|
* booked revenue is a reconciliation problem, not a ledger verb.
|
|
@@ -2213,14 +2212,14 @@ var CreditLedger = class {
|
|
|
2213
2212
|
return this.resolveDraw({ ...args, to: "released" });
|
|
2214
2213
|
}
|
|
2215
2214
|
/**
|
|
2216
|
-
* Record a fund-only top-up under its client-generated `fundId
|
|
2215
|
+
* Record a fund-only top-up under its client-generated `fundId`.
|
|
2217
2216
|
* The deposit half of the evidence chain, and the top-up path's idempotency
|
|
2218
2217
|
* key: `PRIMARY KEY (credit_id, fund_id)` means a concurrent duplicate
|
|
2219
2218
|
* loses with a typed `funding_replayed` rather than crediting twice.
|
|
2220
2219
|
*
|
|
2221
2220
|
* Call it inside the same `tx` as {@link fund} — the rail commit, the
|
|
2222
2221
|
* funding record, and the balance increment must land together or not at
|
|
2223
|
-
* all (
|
|
2222
|
+
* all (the funding-commitment rule). Like `fund`, this issues no transaction
|
|
2224
2223
|
* control on `tx`; it is a single statement.
|
|
2225
2224
|
*
|
|
2226
2225
|
* This does **not** move money on its own. `fund` still does the crediting;
|
|
@@ -2295,7 +2294,7 @@ var CreditLedger = class {
|
|
|
2295
2294
|
return rows[0].receipt;
|
|
2296
2295
|
}
|
|
2297
2296
|
/**
|
|
2298
|
-
* Record the bolt11 issued for a `(creditId, fundId)` top-up
|
|
2297
|
+
* Record the bolt11 issued for a `(creditId, fundId)` top-up, or
|
|
2299
2298
|
* return the one already issued for it.
|
|
2300
2299
|
*
|
|
2301
2300
|
* **Returning the existing row is the point.** A caller re-polling an unpaid
|
|
@@ -2375,7 +2374,7 @@ var CreditLedger = class {
|
|
|
2375
2374
|
}
|
|
2376
2375
|
/**
|
|
2377
2376
|
* Apply an observed Lightning settlement to the ledger — **the exactly-once
|
|
2378
|
-
* boundary** (
|
|
2377
|
+
* boundary** (the funding-commitment rule for a rail whose commit happens
|
|
2379
2378
|
* off-box).
|
|
2380
2379
|
*
|
|
2381
2380
|
* One transaction covers the funding record, the balance, and the invoice's
|
|
@@ -2483,7 +2482,7 @@ var CreditLedger = class {
|
|
|
2483
2482
|
return this.getInvoice(args);
|
|
2484
2483
|
}
|
|
2485
2484
|
/**
|
|
2486
|
-
* Retire an invoice that **was paid** and can never be credited
|
|
2485
|
+
* Retire an invoice that **was paid** and can never be credited.
|
|
2487
2486
|
*
|
|
2488
2487
|
* Distinct from `expired` because the money is the opposite way round: an
|
|
2489
2488
|
* expired invoice was never paid and owes nobody anything, whereas a blocked
|
|
@@ -2514,15 +2513,15 @@ var CreditLedger = class {
|
|
|
2514
2513
|
return rows.length > 0 ? invoiceRecordFromRow(rows[0]) : void 0;
|
|
2515
2514
|
}
|
|
2516
2515
|
/**
|
|
2517
|
-
* The operator's queue: invoices the sweep gave up on
|
|
2516
|
+
* The operator's queue: invoices the sweep gave up on.
|
|
2518
2517
|
*
|
|
2519
2518
|
* **Keyset-paginated, not offset.** Blocked rows are terminal and never
|
|
2520
2519
|
* self-clear, so a row the operator declines to act on sits at the head of
|
|
2521
2520
|
* the age ordering forever; a fixed first page would starve everything
|
|
2522
|
-
* behind it on every run, which is the
|
|
2521
|
+
* behind it on every run, which is the shape one page up.
|
|
2523
2522
|
*
|
|
2524
2523
|
* `includeResolved` widens to the operator-resolved statuses so a run can be
|
|
2525
|
-
* audited after the fact
|
|
2524
|
+
* audited after the fact.
|
|
2526
2525
|
* Host-wide, like `listPendingDrains`: the ledger has no `dvm_id`, so on a
|
|
2527
2526
|
* multi-mount host one builder's admin credential reads every mount's rows.
|
|
2528
2527
|
*/
|
|
@@ -2547,7 +2546,7 @@ var CreditLedger = class {
|
|
|
2547
2546
|
}
|
|
2548
2547
|
/**
|
|
2549
2548
|
* Apply a blocked invoice's payment to a credit an operator named — the
|
|
2550
|
-
* repair for the one Lightning outcome the DVM cannot fix itself
|
|
2549
|
+
* repair for the one Lightning outcome the DVM cannot fix itself.
|
|
2551
2550
|
*
|
|
2552
2551
|
* Shaped statement-for-statement on {@link settleInvoice}, because it is the
|
|
2553
2552
|
* same money doing the same thing a different way: one transaction covering
|
|
@@ -2555,21 +2554,21 @@ var CreditLedger = class {
|
|
|
2555
2554
|
* outbox row, so the four can never disagree. Three deliberate differences:
|
|
2556
2555
|
*
|
|
2557
2556
|
* - **The lock is taken on `payment_hash`**, which is UNIQUE and is the
|
|
2558
|
-
*
|
|
2559
|
-
*
|
|
2560
|
-
*
|
|
2561
|
-
*
|
|
2562
|
-
*
|
|
2557
|
+
* identifier the operator actually holds (it is what the
|
|
2558
|
+
* `lightning_settlement_blocked` log carries and what names the payment in
|
|
2559
|
+
* their wallet). Invoice row first, credit row second via `fund`'s upsert —
|
|
2560
|
+
* the same order `settleInvoice` takes, which is what keeps a reconcile and
|
|
2561
|
+
* a concurrent settlement check from deadlocking against each other.
|
|
2563
2562
|
* - **The funding lands at `(targetCreditId, paymentHash)`, not the invoice's
|
|
2564
|
-
*
|
|
2565
|
-
*
|
|
2566
|
-
*
|
|
2567
|
-
*
|
|
2568
|
-
*
|
|
2569
|
-
*
|
|
2563
|
+
* own `(credit_id, fund_id)`.** That key is frequently the reason the row
|
|
2564
|
+
* is blocked at all — `funding_replayed_on_cashu` means something else
|
|
2565
|
+
* already holds it — and the operator's most natural target is that very
|
|
2566
|
+
* credit. The payment hash cannot collide with it, and it makes all three
|
|
2567
|
+
* references to this payment agree: `basis.fundingRef`, the deposit's
|
|
2568
|
+
* `funding_id`, and the funding row's `fund_id`.
|
|
2570
2569
|
* - **`written_off` is an accepted input status.** A write-off unwound
|
|
2571
|
-
*
|
|
2572
|
-
*
|
|
2570
|
+
* nothing, so an operator who closed a row by mistake must not need raw SQL
|
|
2571
|
+
* against a money table to reopen it.
|
|
2573
2572
|
*
|
|
2574
2573
|
* The invoice row's status — never the funding row — is the idempotency
|
|
2575
2574
|
* source of truth. `fund_id` is caller-chosen and the payment hash is
|
|
@@ -2677,7 +2676,7 @@ var CreditLedger = class {
|
|
|
2677
2676
|
}
|
|
2678
2677
|
/**
|
|
2679
2678
|
* Record that an operator reviewed a blocked invoice and chose not to credit
|
|
2680
|
-
* it
|
|
2679
|
+
* it — no ledger effect, purely a queue transition.
|
|
2681
2680
|
*
|
|
2682
2681
|
* A CAS on `blocked`, and idempotent: re-running returns the recorded row
|
|
2683
2682
|
* rather than overwriting the first note. It cannot capture a `reconciled`
|
|
@@ -2746,7 +2745,7 @@ var CreditLedger = class {
|
|
|
2746
2745
|
}
|
|
2747
2746
|
/**
|
|
2748
2747
|
* All pending holds on a credit, in `ledger_seq` order (no lock). Read
|
|
2749
|
-
* surface for the
|
|
2748
|
+
* surface for the sweeper wiring — a worker that dies mid-job
|
|
2750
2749
|
* leaves its hold `pending` until something releases it.
|
|
2751
2750
|
*/
|
|
2752
2751
|
async listPendingDraws(creditId) {
|
|
@@ -2758,7 +2757,7 @@ var CreditLedger = class {
|
|
|
2758
2757
|
}
|
|
2759
2758
|
/**
|
|
2760
2759
|
* One page of pending holds host-wide placed before `createdBeforeMs`,
|
|
2761
|
-
* oldest first (no lock). The orphan sweeper's read surface
|
|
2760
|
+
* oldest first (no lock). The orphan sweeper's read surface: a
|
|
2762
2761
|
* draw commits with its `job_id` before the job row is persisted, so a crash
|
|
2763
2762
|
* or a fail-closed refusal in that window strands a hold nothing can ever
|
|
2764
2763
|
* resolve — the only release path keys off the `credit_id`/`draw_id` written
|
|
@@ -2797,7 +2796,7 @@ var CreditLedger = class {
|
|
|
2797
2796
|
* Rail-native value the credit an x402 settlement channel funded has
|
|
2798
2797
|
* actually earned — the sum of its **settled** draws, in the credit's native
|
|
2799
2798
|
* atomic units (USDC micro on this rail). The batch-settlement claim job's
|
|
2800
|
-
* ceiling
|
|
2799
|
+
* ceiling: a channel is claimable up to what its credit's draws
|
|
2801
2800
|
* have earned, never up to the deposit that funded it.
|
|
2802
2801
|
*
|
|
2803
2802
|
* `undefined` when no credit is bound to the channel, which the claim job
|
|
@@ -2829,7 +2828,7 @@ var CreditLedger = class {
|
|
|
2829
2828
|
}
|
|
2830
2829
|
/**
|
|
2831
2830
|
* The credit an x402 settlement channel funded, if one is bound to it — the
|
|
2832
|
-
* binding is UNIQUE, so at most one row can answer
|
|
2831
|
+
* binding is UNIQUE, so at most one row can answer.
|
|
2833
2832
|
*
|
|
2834
2833
|
* The operator repair's entry point: a wedged settlement row carries the
|
|
2835
2834
|
* channel and an `effect_id`, and this is what turns them back into the
|
|
@@ -3008,10 +3007,9 @@ var CreditLedger = class {
|
|
|
3008
3007
|
async listX402CreditLosses(args) {
|
|
3009
3008
|
return this.readX402CreditLosses(this.pool, { limit: args?.limit ?? 50 });
|
|
3010
3009
|
}
|
|
3011
|
-
// ── Drains (internal-review) ─────────────────────────────────────────────────
|
|
3012
3010
|
/**
|
|
3013
3011
|
* Debit the caller's entire available balance into a drain liability
|
|
3014
|
-
* (
|
|
3012
|
+
* (the caller-ownership contract: expiry ends spending, never ownership — this is the
|
|
3015
3013
|
* builder-honored reclaim floor). Runs under the credit row lock: the
|
|
3016
3014
|
* amount is `balance − pending holds` read under `FOR UPDATE`, the balance
|
|
3017
3015
|
* is decremented in the same transaction, and the drain takes the next
|
|
@@ -3151,7 +3149,7 @@ var CreditLedger = class {
|
|
|
3151
3149
|
return rows.length > 0 ? drainRecordFromJoinRow(rows[0]) : void 0;
|
|
3152
3150
|
}
|
|
3153
3151
|
/**
|
|
3154
|
-
* One credit's undepleted funding lots, oldest first
|
|
3152
|
+
* One credit's undepleted funding lots, oldest first — the
|
|
3155
3153
|
* public read behind the reclaim's own arithmetic, for anything that needs
|
|
3156
3154
|
* to show its work.
|
|
3157
3155
|
*/
|
|
@@ -3160,7 +3158,7 @@ var CreditLedger = class {
|
|
|
3160
3158
|
}
|
|
3161
3159
|
/**
|
|
3162
3160
|
* What this DVM owes back in satoshis if every open non-channel Bitcoin
|
|
3163
|
-
* credit reclaimed right now
|
|
3161
|
+
* credit reclaimed right now — the deposit half of the hub
|
|
3164
3162
|
* balance, and the floor a payout sweep must never go below.
|
|
3165
3163
|
*
|
|
3166
3164
|
* Read entirely off the funding lots, at their own funding rates, with no
|
|
@@ -3255,7 +3253,7 @@ var CreditLedger = class {
|
|
|
3255
3253
|
}
|
|
3256
3254
|
/**
|
|
3257
3255
|
* One page of still-`pending` drains on a channel-backed credit, oldest
|
|
3258
|
-
* first (no lock) — the operator's repair queue
|
|
3256
|
+
* first (no lock) — the operator's repair queue.
|
|
3259
3257
|
*
|
|
3260
3258
|
* Keyset-paginated for the x402 settlement queue's reason: a wedged row
|
|
3261
3259
|
* never self-clears, so a caller that re-issues the same first page would
|
|
@@ -3271,10 +3269,10 @@ var CreditLedger = class {
|
|
|
3271
3269
|
* younger is in flight rather than stuck.
|
|
3272
3270
|
*
|
|
3273
3271
|
* The method filter is `'tempo'`, and it is the one line here worth a second
|
|
3274
|
-
* look: `init()` migrates the
|
|
3272
|
+
* look: `init()` migrates the legacy `'mpp'` spelling away and
|
|
3275
3273
|
* `DrainMethod` no longer carries it, so a query naming it matches nothing a
|
|
3276
|
-
* DVM has ever written. It named it anyway until
|
|
3277
|
-
*
|
|
3274
|
+
* DVM has ever written. It named it anyway until rename sweep and
|
|
3275
|
+
* live rung caught it independently — the whole operator queue
|
|
3278
3276
|
* read empty in production while every route test stayed green, because
|
|
3279
3277
|
* those run on `MemoryCreditLedger`, which filters on the typed value. The
|
|
3280
3278
|
* two implementations of this one predicate must be read together.
|
|
@@ -3307,7 +3305,7 @@ var CreditLedger = class {
|
|
|
3307
3305
|
}
|
|
3308
3306
|
/**
|
|
3309
3307
|
* Record that an operator reviewed a floor-refused channel drain and is not
|
|
3310
|
-
* booking it
|
|
3308
|
+
* booking it. Books nothing anywhere — no status change, no
|
|
3311
3309
|
* balance movement, no platform report.
|
|
3312
3310
|
*
|
|
3313
3311
|
* A single-statement CAS on `written_off_at IS NULL`, so the first note on
|
|
@@ -3450,7 +3448,7 @@ var CreditLedger = class {
|
|
|
3450
3448
|
* loss, so the caller's re-poll keeps returning the same token either way.
|
|
3451
3449
|
*
|
|
3452
3450
|
* Returns `replayed` because this is a **terminal** transition and the money
|
|
3453
|
-
* has left at exactly one of these calls
|
|
3451
|
+
* has left at exactly one of these calls: the platform drain
|
|
3454
3452
|
* report must be emitted by that caller and no other. Pass `tx` to write the
|
|
3455
3453
|
* report through the same transaction as the CAS.
|
|
3456
3454
|
*/
|
|
@@ -3511,7 +3509,6 @@ var CreditLedger = class {
|
|
|
3511
3509
|
[args.creditId, args.drainId, JSON.stringify([args.receipt])]
|
|
3512
3510
|
);
|
|
3513
3511
|
}
|
|
3514
|
-
// ── Internals ─────────────────────────────────────────────────────────
|
|
3515
3512
|
async readDrain(q, creditId, drainId) {
|
|
3516
3513
|
const { rows } = await q.query(
|
|
3517
3514
|
`SELECT * FROM credit_drains WHERE credit_id = $1 AND drain_id = $2`,
|
|
@@ -3544,7 +3541,7 @@ var CreditLedger = class {
|
|
|
3544
3541
|
);
|
|
3545
3542
|
}
|
|
3546
3543
|
/**
|
|
3547
|
-
* Price a reclaim in kind and say which lots it takes
|
|
3544
|
+
* Price a reclaim in kind and say which lots it takes.
|
|
3548
3545
|
*
|
|
3549
3546
|
* The debits are returned whether or not the reclaim can be priced, and the
|
|
3550
3547
|
* caller applies them either way: the money is leaving the credit, so the
|
|
@@ -3553,13 +3550,13 @@ var CreditLedger = class {
|
|
|
3553
3550
|
*
|
|
3554
3551
|
* `owedSats` is `null` where {@link isInKindDepletion} refuses — the lots
|
|
3555
3552
|
* are short of the balance, or the covering lots carry no sats basis (a
|
|
3556
|
-
* credit
|
|
3553
|
+
* legacy credit whose funding recorded no sats basis. That row is priced off a live rate by the
|
|
3557
3554
|
* admin surface instead, which is what *every* row did before this change,
|
|
3558
3555
|
* so the fallback is the old behaviour rather than a new failure mode.
|
|
3559
3556
|
*
|
|
3560
|
-
* What it publishes is **net of the delivery reserve
|
|
3557
|
+
* What it publishes is **net of the delivery reserve**: handing a
|
|
3561
3558
|
* refund over costs a mint fee and, when the notes have to be minted just in
|
|
3562
|
-
* time, a Lightning hop. The caller carries that cost per
|
|
3559
|
+
* time, a Lightning hop. The caller carries that cost per and a
|
|
3563
3560
|
* flat reserve is how they carry it without the figure moving — an
|
|
3564
3561
|
* actual-fee true-up could only be applied after the promise was made. The
|
|
3565
3562
|
* debits stay gross because they are denominated in micro and are what
|
|
@@ -3575,7 +3572,7 @@ var CreditLedger = class {
|
|
|
3575
3572
|
};
|
|
3576
3573
|
}
|
|
3577
3574
|
/**
|
|
3578
|
-
* This credit's undepleted funding lots, oldest first
|
|
3575
|
+
* This credit's undepleted funding lots, oldest first.
|
|
3579
3576
|
*
|
|
3580
3577
|
* Ordered in SQL on the same `(created_at, lot_id)` key the partial index
|
|
3581
3578
|
* carries, so FIFO is the index's own order rather than something a reader
|
|
@@ -3739,7 +3736,7 @@ var CreditLedger = class {
|
|
|
3739
3736
|
/**
|
|
3740
3737
|
* Held-but-unresolved totals for a credit, in all three units at once — the
|
|
3741
3738
|
* fiat micro that defines available balance plus the rail-value remainders
|
|
3742
|
-
* a new draw allocates against
|
|
3739
|
+
* a new draw allocates against. One round-trip, since every
|
|
3743
3740
|
* caller needs the micro sum anyway.
|
|
3744
3741
|
*/
|
|
3745
3742
|
async pendingSums(q, creditId) {
|
|
@@ -3814,7 +3811,7 @@ function isFundingRail(rail) {
|
|
|
3814
3811
|
}
|
|
3815
3812
|
function assertFundingBasis(basis) {
|
|
3816
3813
|
if (!basis) {
|
|
3817
|
-
throw new CreditLedgerError("invalid_basis", "basis is required
|
|
3814
|
+
throw new CreditLedgerError("invalid_basis", "basis is required");
|
|
3818
3815
|
}
|
|
3819
3816
|
if (!isFundingRail(basis.rail)) {
|
|
3820
3817
|
throw new CreditLedgerError(
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
// src/sdk/step-cache.ts
|
|
6
6
|
var StepCache = class _StepCache {
|
|
7
7
|
cache = /* @__PURE__ */ new Map();
|
|
8
|
-
/** Check if a step result is cached. */
|
|
9
8
|
has(id) {
|
|
10
9
|
return this.cache.has(id);
|
|
11
10
|
}
|
|
@@ -19,7 +18,6 @@ var StepCache = class _StepCache {
|
|
|
19
18
|
if (record === void 0) throw new Error(`StepCache: no cached result for step "${id}"`);
|
|
20
19
|
return record;
|
|
21
20
|
}
|
|
22
|
-
/** Cache a step result. */
|
|
23
21
|
set(id, value, costs) {
|
|
24
22
|
this.cache.set(id, {
|
|
25
23
|
id,
|