@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
|
|
5805
|
-
const
|
|
5806
|
-
|
|
5807
|
-
|
|
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(
|
package/dist/internal/server.js
CHANGED
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvmkit/sdk",
|
|
3
|
-
"version": "0.17.
|
|
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": [
|