@dvmkit/sdk 0.17.0 → 0.17.1

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.
@@ -1174,6 +1174,9 @@ function pinAskFiat(args) {
1174
1174
  return { currency: args.currency, amountMicro: Math.max(1, rounded) };
1175
1175
  }
1176
1176
  function fundedMicroFor(priceFiat, paidMsats, requiredMsats) {
1177
+ if (!Number.isFinite(requiredMsats) || requiredMsats <= 0) {
1178
+ throw new Error(`fundedMicroFor needs a positive reference price in msats (got ${requiredMsats})`);
1179
+ }
1177
1180
  if (paidMsats === requiredMsats) return priceFiat.amountMicro;
1178
1181
  return Math.round(priceFiat.amountMicro * paidMsats / requiredMsats);
1179
1182
  }
@@ -5801,11 +5804,12 @@ async function verifyAccumulatorReceipt(opts, mints, requiredMsats, ledgerCtx) {
5801
5804
  let credited;
5802
5805
  const headerless = !opts.requestId && opts.nut24 !== void 0;
5803
5806
  const previousRequired = headerless ? opts.nut24?.previousRequiredMsats : void 0;
5804
- const requiredFor = (paidMsats) => requiredMsats !== void 0 && paidMsats < requiredMsats && previousRequired !== void 0 && paidMsats >= previousRequired ? previousRequired : requiredMsats;
5805
- const held = (ctx, paidMsats) => ({
5806
- ...ctx,
5807
- requiredMsats: requiredFor(paidMsats) ?? ctx.requiredMsats
5808
- });
5807
+ const heldAt = (paidMsats) => requiredMsats !== void 0 && paidMsats < requiredMsats && previousRequired !== void 0 && paidMsats >= previousRequired ? previousRequired : void 0;
5808
+ const requiredFor = (paidMsats) => heldAt(paidMsats) ?? requiredMsats;
5809
+ const held = (ctx, paidMsats) => {
5810
+ const previous = heldAt(paidMsats);
5811
+ return previous === void 0 ? ctx : { ...ctx, requiredMsats: previous };
5812
+ };
5809
5813
  const signedFund = ledgerCtx?.creditEnvelope?.fund;
5810
5814
  const beforeCommit = ledgerCtx && signedFund ? (accepted) => {
5811
5815
  const expected = fundedMicroFor(
@@ -61,7 +61,7 @@ import {
61
61
  verifyUpfrontPayment,
62
62
  x402RequiredUsdcMicro,
63
63
  x402SettledShare
64
- } from "../chunk-4QYADZFN.js";
64
+ } from "../chunk-YRQMDRI4.js";
65
65
  import "../chunk-XRLKGCAW.js";
66
66
  import {
67
67
  PayoutReporter
@@ -82,7 +82,7 @@ import {
82
82
  toCreditView,
83
83
  unknownRouteNotFound,
84
84
  writeOffHostedTempoCloseReport
85
- } from "../chunk-4QYADZFN.js";
85
+ } from "../chunk-YRQMDRI4.js";
86
86
  import {
87
87
  MemoryProcessedPaymentStore,
88
88
  PostgresProcessedPaymentStore,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvmkit/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "SDK for building Digital Vending Machines: pay-per-use HTTPS services AI agents can find, pay, and call with no account or API key",
5
5
  "author": "DVM Technologies Ltd",
6
6
  "keywords": [