@dvmkit/sdk 0.6.0-rc.1 → 0.7.0-rc.2

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 (74) hide show
  1. package/README.md +2 -0
  2. package/dist/{chunk-PLG4XER6.js → chunk-26W6GPCD.js} +48 -6
  3. package/dist/{chunk-FI4CST2D.js → chunk-2OM2QPBE.js} +6 -8
  4. package/dist/{chunk-IWQHUSMO.js → chunk-62FI3NJF.js} +78 -2
  5. package/dist/{chunk-VHNPVGSA.js → chunk-6STC5TCP.js} +3 -3
  6. package/dist/{chunk-N5RZ5HVB.js → chunk-72V5DTEC.js} +2 -2
  7. package/dist/chunk-A262WVYX.js +6 -0
  8. package/dist/{chunk-HHBDBMEO.js → chunk-A6CXKAQV.js} +186 -93
  9. package/dist/{chunk-QR2EF2NI.js → chunk-AQ7OX5NX.js} +2 -2
  10. package/dist/{chunk-RLTSCKRI.js → chunk-BPYMEMQX.js} +50 -3
  11. package/dist/{chunk-BYCEKO65.js → chunk-CLIAFTUR.js} +102 -13
  12. package/dist/{chunk-GAOAYHZA.js → chunk-DNG4KGSC.js} +3 -3
  13. package/dist/{chunk-Z4ZT5LNT.js → chunk-GSLS4464.js} +3 -3
  14. package/dist/{chunk-7ZUKL4IV.js → chunk-H5FVVEEN.js} +17 -6
  15. package/dist/{chunk-IXR5RFK7.js → chunk-HCE4MPZ5.js} +1 -1
  16. package/dist/{chunk-FYRR2UEZ.js → chunk-I555L2WK.js} +1 -1
  17. package/dist/{chunk-EQLA4FFY.js → chunk-IIZQNDQU.js} +3 -3
  18. package/dist/{chunk-FUJ36YDV.js → chunk-KXWROQGK.js} +24 -1
  19. package/dist/{chunk-ETXDTUJO.js → chunk-LAKP6FUI.js} +55 -0
  20. package/dist/{chunk-X7EZ5CLI.js → chunk-MON76YBJ.js} +3 -3
  21. package/dist/chunk-OFSOLHRX.js +120 -0
  22. package/dist/{chunk-IV6Q7NRW.js → chunk-RAGX6VG7.js} +2 -2
  23. package/dist/{chunk-KA6VN5FK.js → chunk-RXPHMS4C.js} +3 -3
  24. package/dist/{chunk-JH3SX3LY.js → chunk-SPYEJXI7.js} +6 -6
  25. package/dist/{chunk-P6QON7ER.js → chunk-TRNMTTPX.js} +1 -1
  26. package/dist/{chunk-RCM3P2HE.js → chunk-UKD3R2KU.js} +55 -4
  27. package/dist/chunk-USL7ZEXN.js +17 -0
  28. package/dist/{chunk-OQA7IHI4.js → chunk-VB5OLOZH.js} +403 -235
  29. package/dist/{content-retention-BTGSQRfP.d.ts → content-retention-CbnouEnh.d.ts} +1 -1
  30. package/dist/{credit-ledger-MI2H7NEC.js → credit-ledger-7Z7LOCTN.js} +4 -5
  31. package/dist/{credit-menu-BAsrRu3z.d.ts → credit-menu-BO8yJppy.d.ts} +4 -4
  32. package/dist/{fx-BgDmyTdd.d.ts → fx-DSOZQ2z7.d.ts} +1 -1
  33. package/dist/index.d.ts +5 -5
  34. package/dist/index.js +236 -16
  35. package/dist/internal/caller.d.ts +4495 -7305
  36. package/dist/internal/caller.js +4415 -8122
  37. package/dist/internal/index.js +1 -1
  38. package/dist/internal/server.d.ts +7 -7
  39. package/dist/internal/server.js +27 -32
  40. package/dist/{job-store-BVeF5_Jq.d.ts → job-store-BJRlmq2Q.d.ts} +1 -1
  41. package/dist/{lightning-backend-40fIzz1W.d.ts → lightning-backend-f16-fsYK.d.ts} +4 -2
  42. package/dist/memory-credit-ledger-3WOS74UH.js +11 -0
  43. package/dist/{mpp-setup-RF5FXGGV.js → mpp-setup-XB4KATMU.js} +2 -2
  44. package/dist/{payout-reporter-3Y2U55ZX.js → payout-reporter-WT7XYW42.js} +2 -2
  45. package/dist/{postgres-consumed-credential-store-BUVCAPLS.js → postgres-consumed-credential-store-W7UP33AH.js} +3 -3
  46. package/dist/{postgres-job-store-VHLQBJZC.js → postgres-job-store-3KGUGFRD.js} +2 -2
  47. package/dist/{postgres-replay-store-ARZSQ45X.js → postgres-replay-store-CVNJJOQG.js} +2 -2
  48. package/dist/{pricing-XT2IAPNE.js → pricing-QAVZUTZR.js} +12 -12
  49. package/dist/{revenue-reporter-MAERPYGK.js → revenue-reporter-7UR3W2SD.js} +2 -2
  50. package/dist/server/index.d.ts +10 -10
  51. package/dist/server/index.js +46 -53
  52. package/dist/{step-cache-CPdH1hei.d.ts → step-cache-CJFiZU3n.d.ts} +1 -1
  53. package/dist/{tempo-charge-store-Q3D7KYMH.js → tempo-charge-store-GA6CED6O.js} +2 -2
  54. package/dist/{tempo-session-store-ZRNCOX7P.js → tempo-session-store-WZWQRITB.js} +3 -3
  55. package/dist/testing/index.d.ts +3 -3
  56. package/dist/testing/index.js +6 -7
  57. package/dist/{usd-AWlrwlM5.d.ts → usd-DmHHg0_4.d.ts} +1 -1
  58. package/dist/{x402-R6HPBY5D.js → x402-ZU4GML7Z.js} +9 -30
  59. package/package.json +3 -2
  60. package/dist/chunk-66HGCPBU.js +0 -25
  61. package/dist/chunk-AT6V3SY7.js +0 -102
  62. package/dist/chunk-B2IROPQF.js +0 -1844
  63. package/dist/chunk-CZULM42S.js +0 -143
  64. package/dist/chunk-GFY5FRX3.js +0 -218
  65. package/dist/chunk-HCLVYZUZ.js +0 -244
  66. package/dist/chunk-LE74UEV7.js +0 -1071
  67. package/dist/chunk-LIRAHP7B.js +0 -53
  68. package/dist/chunk-MZRJR2CW.js +0 -776
  69. package/dist/chunk-OFVV37XC.js +0 -57
  70. package/dist/chunk-PAIM66YA.js +0 -347
  71. package/dist/chunk-UOCZXO2Z.js +0 -1663
  72. package/dist/memory-credit-ledger-W2BAUYJP.js +0 -12
  73. package/dist/tempo-lifecycle-ZBBLFBMH.js +0 -15
  74. package/dist/tempo-wallet-B5XXV3YH.js +0 -40
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PostgresReplayStore
3
- } from "../chunk-VHNPVGSA.js";
3
+ } from "../chunk-6STC5TCP.js";
4
4
  import {
5
5
  PostgresKVStore
6
6
  } from "../chunk-V5ZRATJH.js";
@@ -18,7 +18,7 @@ import {
18
18
  parseNwcUri,
19
19
  validateX402Env,
20
20
  withNwcPool
21
- } from "../chunk-FI4CST2D.js";
21
+ } from "../chunk-2OM2QPBE.js";
22
22
  import {
23
23
  MemoryKVStore
24
24
  } from "../chunk-SDK6KDJN.js";
@@ -63,6 +63,7 @@ import {
63
63
  initLockPubkeyTable,
64
64
  initWalletAccumulatorTable,
65
65
  installAdminContentRoutes,
66
+ isTestMintUrl,
66
67
  parseClientCapabilities,
67
68
  parseClientCompatibility,
68
69
  parseDvmClient,
@@ -79,29 +80,31 @@ import {
79
80
  stripProtocolEnvelope,
80
81
  toCreditView,
81
82
  unknownRouteNotFound
82
- } from "../chunk-HHBDBMEO.js";
83
+ } from "../chunk-A6CXKAQV.js";
83
84
  import {
84
- MemoryProcessedPaymentStore,
85
- PostgresProcessedPaymentStore,
86
- ProcessedPaymentReplayError
87
- } from "../chunk-XRLKGCAW.js";
88
- import "../chunk-PLG4XER6.js";
85
+ TEMPO_MODERATO_CHAIN_ID,
86
+ TEMPO_MODERATO_RPC,
87
+ TEMPO_SETTLEMENT_DEFAULT_LOW_BALANCE_MICRO,
88
+ TempoSettlementReadiness,
89
+ resolveTempoNetwork
90
+ } from "../chunk-HCE4MPZ5.js";
91
+ import "../chunk-26W6GPCD.js";
89
92
  import {
90
93
  MemoryCreditLedger
91
- } from "../chunk-FYRR2UEZ.js";
94
+ } from "../chunk-I555L2WK.js";
92
95
  import {
93
96
  PostgresJobStore
94
- } from "../chunk-EQLA4FFY.js";
97
+ } from "../chunk-IIZQNDQU.js";
95
98
  import "../chunk-YG7G4DPZ.js";
96
99
  import {
97
100
  SignedRequestError,
98
101
  createDefaultReplayStore,
99
102
  createSignedRequestVerifier,
100
103
  signedRequestInput
101
- } from "../chunk-N5RZ5HVB.js";
104
+ } from "../chunk-72V5DTEC.js";
102
105
  import {
103
106
  isStreamableJobStore
104
- } from "../chunk-IV6Q7NRW.js";
107
+ } from "../chunk-RAGX6VG7.js";
105
108
  import {
106
109
  ContentHoldError,
107
110
  baselineContentExpiry,
@@ -109,35 +112,28 @@ import {
109
112
  isContentHoldStore
110
113
  } from "../chunk-AFV77S4C.js";
111
114
  import {
115
+ IMPLICIT_CREDIT_TTL_MS,
112
116
  generateEphemeralReceiptKey,
113
- isTestMintUrl,
114
117
  receiptPubkeyFromSecret
115
- } from "../chunk-OQA7IHI4.js";
118
+ } from "../chunk-VB5OLOZH.js";
116
119
  import {
117
120
  X402_DEFAULT_FACILITATOR,
118
121
  X402_DEFAULT_NETWORK,
122
+ resolveRpcOverride,
119
123
  x402NetworkToCaip2
120
- } from "../chunk-IWQHUSMO.js";
121
- import {
122
- IMPLICIT_CREDIT_TTL_MS
123
- } from "../chunk-PAIM66YA.js";
124
- import {
125
- resolveRpcOverride
126
- } from "../chunk-CZULM42S.js";
124
+ } from "../chunk-62FI3NJF.js";
127
125
  import {
128
126
  SIGNED_REQUEST_AUTH_ID,
129
127
  SIGNED_REQUEST_STATEMENT_VERSION,
130
128
  signedRequestStatementHeader
131
- } from "../chunk-RCM3P2HE.js";
132
- import "../chunk-OFVV37XC.js";
129
+ } from "../chunk-UKD3R2KU.js";
133
130
  import {
134
131
  initLoggers
135
- } from "../chunk-QR2EF2NI.js";
136
- import "../chunk-66HGCPBU.js";
137
- import "../chunk-FUJ36YDV.js";
132
+ } from "../chunk-AQ7OX5NX.js";
133
+ import "../chunk-KXWROQGK.js";
138
134
  import "../chunk-BQJIFRAZ.js";
139
- import "../chunk-BYCEKO65.js";
140
- import "../chunk-AT6V3SY7.js";
135
+ import "../chunk-USL7ZEXN.js";
136
+ import "../chunk-CLIAFTUR.js";
141
137
  import {
142
138
  CreditLedger,
143
139
  CreditLedgerError,
@@ -145,28 +141,25 @@ import {
145
141
  PostgresX402ChannelStorage,
146
142
  X402RelaySubmissionLockError,
147
143
  allocateDrawValue
148
- } from "../chunk-JH3SX3LY.js";
149
- import {
150
- SDK_INIT_ADVISORY_LOCK,
151
- withSdkInitLock
152
- } from "../chunk-COYKJRMM.js";
144
+ } from "../chunk-SPYEJXI7.js";
153
145
  import {
154
146
  applyRetryToPool
155
- } from "../chunk-P6QON7ER.js";
147
+ } from "../chunk-TRNMTTPX.js";
156
148
  import {
157
149
  assertSupportedX402Network
158
- } from "../chunk-RLTSCKRI.js";
159
- import "../chunk-LIRAHP7B.js";
160
- import {
161
- TEMPO_MODERATO_CHAIN_ID,
162
- TEMPO_MODERATO_RPC,
163
- TEMPO_SETTLEMENT_DEFAULT_LOW_BALANCE_MICRO,
164
- TempoSettlementReadiness,
165
- resolveTempoNetwork
166
- } from "../chunk-IXR5RFK7.js";
150
+ } from "../chunk-BPYMEMQX.js";
167
151
  import {
168
152
  diagnosticConsole
169
- } from "../chunk-ETXDTUJO.js";
153
+ } from "../chunk-LAKP6FUI.js";
154
+ import {
155
+ MemoryProcessedPaymentStore,
156
+ PostgresProcessedPaymentStore,
157
+ ProcessedPaymentReplayError
158
+ } from "../chunk-XRLKGCAW.js";
159
+ import {
160
+ SDK_INIT_ADVISORY_LOCK,
161
+ withSdkInitLock
162
+ } from "../chunk-COYKJRMM.js";
170
163
 
171
164
  // src/sdk/server/cashu-env.ts
172
165
  async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
@@ -1153,7 +1146,7 @@ function createDVMHost(opts = {}) {
1153
1146
  });
1154
1147
  applyRetryToPool(pool, "dvm-host");
1155
1148
  pgPool = pool;
1156
- const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-VHLQBJZC.js");
1149
+ const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-3KGUGFRD.js");
1157
1150
  const pgJobStore = new PostgresJobStore2(pool);
1158
1151
  pendingInits.push(pgJobStore.init(), pgJobStore.initStreaming());
1159
1152
  jobStore = pgJobStore;
@@ -1246,11 +1239,11 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1246
1239
  let tempoChargeBackend = "user-supplied";
1247
1240
  const mppTempoRecipient = envMaybe.DVMKIT_TEMPO_RECIPIENT;
1248
1241
  if (!mpp && mppTempoRecipient) {
1249
- const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-RF5FXGGV.js");
1242
+ const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-XB4KATMU.js");
1250
1243
  tempoChargeBackend = pgPool ? "postgres" : "memory";
1251
1244
  let tempoCharge;
1252
1245
  if (pgPool) {
1253
- const { PostgresTempoChargeStore } = await import("../tempo-charge-store-Q3D7KYMH.js");
1246
+ const { PostgresTempoChargeStore } = await import("../tempo-charge-store-GA6CED6O.js");
1254
1247
  const chargeStore = new PostgresTempoChargeStore(pgPool);
1255
1248
  tempoChargeStore = chargeStore;
1256
1249
  pendingInits.push(chargeStore.init());
@@ -1270,7 +1263,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1270
1263
  { createPublicClient, createWalletClient, erc20Abi, http },
1271
1264
  { tempo: tempoMainnet, tempoModerato }
1272
1265
  ] = await Promise.all([
1273
- import("../tempo-session-store-ZRNCOX7P.js"),
1266
+ import("../tempo-session-store-WZWQRITB.js"),
1274
1267
  import("viem/accounts"),
1275
1268
  import("viem"),
1276
1269
  import("viem/chains")
@@ -1423,7 +1416,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1423
1416
  }
1424
1417
  }
1425
1418
  const fxSource = envMaybe.DVMKIT_FX_SOURCE;
1426
- const { createFxFetcher, resolveFxSourceFromEnv, warmFxSnapshot } = await import("../pricing-XT2IAPNE.js");
1419
+ const { createFxFetcher, resolveFxSourceFromEnv, warmFxSnapshot } = await import("../pricing-QAVZUTZR.js");
1427
1420
  const fxFetcher = opts.fx ?? createFxFetcher({ source: resolveFxSourceFromEnv(envMaybe) });
1428
1421
  const hostRailConfigured = (opts.paymentMethods?.length ?? 0) > 0 || (effectiveMints?.length ?? 0) > 0 || !!x402WithDualServe || !!mpp;
1429
1422
  if (mounts.some((entry) => mountNeedsFx(entry, hostRailConfigured))) warmFxSnapshot(fxFetcher);
@@ -1433,7 +1426,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1433
1426
  assertReceiptIdentity(envMaybe, opts.builder, receiptKey, cashuOpts.dvmId, opts.devMode);
1434
1427
  let sharedPgReplayStore;
1435
1428
  if (pgPool) {
1436
- const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-ARZSQ45X.js");
1429
+ const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-CVNJJOQG.js");
1437
1430
  const store2 = new PostgresReplayStore2(pgPool);
1438
1431
  pendingInits.push(store2.init());
1439
1432
  sharedPgReplayStore = store2;
@@ -1461,13 +1454,13 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1461
1454
  }
1462
1455
  let sharedPgConsumedStore;
1463
1456
  if (pgPool) {
1464
- const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-BUVCAPLS.js");
1457
+ const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-W7UP33AH.js");
1465
1458
  const consumedStore = new PostgresConsumedCredentialStore(pgPool);
1466
1459
  pendingInits.push(consumedStore.init());
1467
1460
  sharedPgConsumedStore = consumedStore;
1468
1461
  }
1469
1462
  if (pgPool) {
1470
- const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-MI2H7NEC.js");
1463
+ const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-7Z7LOCTN.js");
1471
1464
  const pgLedger = new CreditLedger2(pgPool, tempoSessionStore);
1472
1465
  pendingInits.push(pgLedger.init());
1473
1466
  creditLedger = pgLedger;
@@ -1476,7 +1469,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1476
1469
  pendingInits.push(pgProcessed.init());
1477
1470
  processedPayments = pgProcessed;
1478
1471
  } else {
1479
- const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-W2BAUYJP.js");
1472
+ const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-3WOS74UH.js");
1480
1473
  creditLedger = disposableCashu?.ledger ?? new MemoryCreditLedger2();
1481
1474
  const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-GKMAWOM3.js");
1482
1475
  processedPayments = new MemoryProcessedPaymentStore2();
@@ -5761,4 +5761,4 @@ declare class StepCache {
5761
5761
  static deserialize(records: StepRecord[]): StepCache;
5762
5762
  }
5763
5763
 
5764
- export { type X402Version as $, type ApprovalContent as A, SignedRequestError as B, type Currency as C, type DVMConfig as D, type SignedRequestFailure as E, type SignedRequestReplayStore as F, type SignedRequestSignOpts as G, type SignedRequestStatementHeader as H, type IncomingMessage as I, type JobCost as J, type KVStore as K, type Logger as L, type SignedRequestVerifier as M, createSignedRequestVerifier as N, isZodSchema as O, type PaymentContent as P, type QuoteConfig as Q, type ResolvedCreditConfig as R, type SDKJobContext as S, signedRequestStatementHeader as T, UnsupportedCurrencyError as U, validateCurrency as V, type JsonValue as W, type FundingReceipt as X, type JobReceipt as Y, type ZodLike as Z, type PaymentRequired as _, type DVMDescriptor as a, isDrainReceipt as a$, type MppxCredential as a0, type Message as a1, type MessageType as a2, type MppxChallenge as a3, X402_BATCH_SETTLEMENT_SCHEME as a4, X402_EXACT_SCHEME as a5, type DrainReceipt as a6, type ReceiptCredit as a7, type X402Wallet as a8, type ResourceInfo as a9, type UnsignedFundingReceipt as aA, type UnsignedJobReceipt as aB, type VerifyResponse as aC, type WorkingContent as aD, type X402Config$1 as aE, type X402ResponseBody as aF, type X402SelfRelayRpcFailureReason as aG, X402_DEFAULT_NETWORK as aH, X402_V1_VERSION as aI, X402_VERSION as aJ, buildPaymentRequiredV2 as aK, buildPaymentRequirements as aL, caip2ToX402Network as aM, canonicalRequestPath as aN, canonicaliseForSigning as aO, canonicalize as aP, chainIdFromCaip2 as aQ, computeResultHash as aR, decodePayment as aS, decodePaymentRequiredHeader as aT, encodePayment as aU, encodePaymentRequiredHeader as aV, encodeSettleResponseHeader as aW, exactEvmAuthorization as aX, isArtifactMessage as aY, isCancelMessage as aZ, isCompleteMessage as a_, type BuildPaymentRequirementsOpts as aa, type CapabilityDescriptor as ab, type CashuMode as ac, type CompleteContent as ad, type DrainReceiptEvent as ae, type ExactEvmPayload as af, type ExactEvmPayloadAuthorization as ag, type FundingMethod as ah, type MessageFrom as ai, type PaymentPayload as aj, type PaymentPayloadV1 as ak, type PaymentPayloadV2 as al, type PaymentRequestContent as am, type PaymentRequiredV2 as an, type PaymentRequirements as ao, type PaymentRequirementsV1 as ap, type PaymentRequirementsV2 as aq, type PromptContent as ar, RAIL_REFUNDABLE as as, type ReceiptOutcome as at, type ReceiptPayment as au, type SettleResponse as av, StepCache as aw, type StepRecord as ax, type TextContent as ay, type UnsignedDrainReceipt as az, type ArtifactContent as b, type DrawRecord as b$, isFundingReceipt as b0, isPaymentRequestMessage as b1, isPromptMessage as b2, isSignedJobReceipt as b3, isTextMessage as b4, isWorkingMessage as b5, paymentRequiredV2FromV1 as b6, signDrainReceipt as b7, signFundingReceipt as b8, signReceipt as b9, _testing as bA, createDefaultReplayStore as bB, depleteLots as bC, fifoOrder as bD, inKindDrawMsats as bE, isInKindDepletion as bF, isNonChannelBitcoinRail as bG, lotOwedSats as bH, netOwedSats as bI, wrapMppx as bJ, type CreditDrainEnqueue as bK, HostedSettlementReportObligations as bL, type DVMAuthScheme as bM, type CreditLedgerLike as bN, type X402RefundSettlementGate as bO, type CreditSnapshot as bP, type DrawResult as bQ, type X402SettlementStatus as bR, type X402UnresolvedRefund as bS, type GrownDrawResult as bT, type DrawResolution as bU, type FundingRecord as bV, type CreditInvoiceRecord as bW, type InvoiceSettlement as bX, type BlockedInvoiceCursor as bY, type InvoiceReconciliation as bZ, type InvoiceWriteOff as b_, usdcContractByCaip2 as ba, usdcContractFor as bb, usdcDomainNameFor as bc, usdcDomainVersionFor as bd, verifyDrainReceipt as be, verifyFundingReceipt as bf, verifyReceipt as bg, x402NetworkToCaip2 as bh, type X402ExactVersionSupport as bi, type X402Receipt as bj, type TransactionalPayoutHook as bk, type CashuMeltCompleted as bl, type CreditDepositPayload as bm, type CreditDrainPayload as bn, type FundingLot as bo, type LotDebit as bp, type LotDepletion as bq, type MppxServer as br, NON_CHANNEL_BITCOIN_RAILS as bs, type NonChannelBitcoinRail as bt, PayoutReporter as bu, PostgresTempoSessionStore as bv, RevenueReporter as bw, SIGNED_ENVELOPE_FIELDS as bx, SIGNED_ENVELOPE_TYPES as by, type X402TrackedChannel as bz, type CancelContent as c, type X402BatchSettlementConfig as c$, type StalePendingDrawCursor as c0, type TempoCreditLossEvidence as c1, type CreditLedgerQuerier as c2, type TempoCreditLoss as c3, type X402CreditLossEvidence as c4, type X402CreditLoss as c5, type DrainMethod as c6, type DrainRequestResult as c7, type BitcoinDepositLiability as c8, type CreditDrainRecord as c9, type JobTerminalReportPayload as cA, PostgresX402ChannelStorage as cB, type ReplayStoreBackend as cC, type RevenueSkippedNoRailPayload as cD, type RevenueSkippedNoRailReason as cE, type Secp256k1AuthOpts as cF, type X402ChannelStorageOpts as cG, type X402RelayLockHolder as cH, type X402RelaySubmissionLock as cI, X402RelaySubmissionLockError as cJ, allocateDrawValue as cK, clientCompatibilityAttributes as cL, clientCompatibilityMiddleware as cM, clientUpgradeRequired as cN, parseClientCapabilities as cO, parseClientCompatibility as cP, parseDvmClient as cQ, parseProtocolVersion as cR, requireClientCompatibility as cS, secp256k1Auth as cT, signedRequestInput as cU, type HostedIntent as cV, type X402SettlementIntent as cW, type HostedFundingReservation as cX, type X402SettlementCursor as cY, type X402SettlementWriteOff as cZ, type X402FacilitatorAuth as c_, type ChannelDrainCursor as ca, type DrainWriteOff as cb, type DrainReleaseResult as cc, type DrainFulfilment as cd, type DrainTransitionResult as ce, HostingCleanupFence as cf, CLIENT_COMPATIBILITY_HEADERS as cg, type ClientCompatibility as ch, type ClientCompatibilityEnv as ci, type ClientCompatibilityGate as cj, type ClientCompatibilityRequirement as ck, type ClientSemVer as cl, type CreditFundingBasis as cm, type CreditInvoiceStatus as cn, CreditLedger as co, CreditLedgerError as cp, type CreditLedgerErrorCode as cq, type CreditLedgerErrorDetails as cr, type CreditLedgerPool as cs, type CreditStatus as ct, DRAIN_DELIVERY_RESERVE_SATS as cu, DVM_PROTOCOL_VERSION as cv, type DrainConflictReason as cw, type DrawRailValue as cx, type DrawStatus as cy, type JobCostReportPayload as cz, type CanonicalEnvelope as d, type X402PayoutObserver as d0, type CreditDepositEnqueue as d1, type X402SettlementReconciliationReason as d2, type CreditDrawReleaseEnqueue as d3, type CreateSignedRequestVerifierOpts as e, type CreditConfig as f, type CreditView as g, DEFAULT_CREDIT_MAX as h, DEFAULT_CREDIT_MIN as i, DEFAULT_CREDIT_TTL_SECONDS as j, DEFAULT_JOB_RETENTION_DAYS as k, type DVMRouteContext as l, type InputType as m, InvalidCurrencyError as n, type PaymentMethod as o, type PriceValue as p, type ProgressContent as q, type PromptOpts as r, type QuoteContext as s, type QuoteResult as t, type ResponseContent as u, type SDKPaymentRequestOpts as v, SIGNED_REQUEST_AUTH_ID as w, SIGNED_REQUEST_STATEMENT_VERSION as x, type SignedRequestAudience as y, type SignedRequestDomain as z };
5764
+ export { type JobReceipt as $, type ApprovalContent as A, SignedRequestError as B, type Currency as C, type DVMConfig as D, type SignedRequestFailure as E, type SignedRequestReplayStore as F, type SignedRequestSignOpts as G, type SignedRequestStatementHeader as H, type IncomingMessage as I, type JobCost as J, type KVStore as K, type Logger as L, type SignedRequestVerifier as M, createSignedRequestVerifier as N, isZodSchema as O, type PaymentContent as P, type QuoteConfig as Q, type ResolvedCreditConfig as R, type SDKJobContext as S, signedRequestStatementHeader as T, UnsupportedCurrencyError as U, validateCurrency as V, type JsonValue as W, X402_BATCH_SETTLEMENT_SCHEME as X, X402_EXACT_SCHEME as Y, type ZodLike as Z, type FundingReceipt as _, type DVMDescriptor as a, isDrainReceipt as a$, type MessageType as a0, type X402Version as a1, type MppxCredential as a2, type PaymentRequired as a3, type Message as a4, type MppxChallenge as a5, type ReceiptCredit as a6, type DrainReceipt as a7, type X402Wallet as a8, type PaymentRequirementsV1 as a9, type UnsignedFundingReceipt as aA, type UnsignedJobReceipt as aB, type VerifyResponse as aC, type WorkingContent as aD, type X402Config$1 as aE, type X402ResponseBody as aF, type X402SelfRelayRpcFailureReason as aG, X402_DEFAULT_NETWORK as aH, X402_V1_VERSION as aI, X402_VERSION as aJ, buildPaymentRequiredV2 as aK, buildPaymentRequirements as aL, caip2ToX402Network as aM, canonicalRequestPath as aN, canonicaliseForSigning as aO, canonicalize as aP, chainIdFromCaip2 as aQ, computeResultHash as aR, decodePayment as aS, decodePaymentRequiredHeader as aT, encodePayment as aU, encodePaymentRequiredHeader as aV, encodeSettleResponseHeader as aW, exactEvmAuthorization as aX, isArtifactMessage as aY, isCancelMessage as aZ, isCompleteMessage as a_, type PaymentRequirementsV2 as aa, type BuildPaymentRequirementsOpts as ab, type CapabilityDescriptor as ac, type CashuMode as ad, type CompleteContent as ae, type DrainReceiptEvent as af, type ExactEvmPayload as ag, type ExactEvmPayloadAuthorization as ah, type FundingMethod as ai, type MessageFrom as aj, type PaymentPayload as ak, type PaymentPayloadV1 as al, type PaymentPayloadV2 as am, type PaymentRequestContent as an, type PaymentRequiredV2 as ao, type PaymentRequirements as ap, type PromptContent as aq, RAIL_REFUNDABLE as ar, type ReceiptOutcome as as, type ReceiptPayment as at, type ResourceInfo as au, type SettleResponse as av, StepCache as aw, type StepRecord as ax, type TextContent as ay, type UnsignedDrainReceipt as az, type ArtifactContent as b, type DrawRecord as b$, isFundingReceipt as b0, isPaymentRequestMessage as b1, isPromptMessage as b2, isSignedJobReceipt as b3, isTextMessage as b4, isWorkingMessage as b5, paymentRequiredV2FromV1 as b6, signDrainReceipt as b7, signFundingReceipt as b8, signReceipt as b9, _testing as bA, createDefaultReplayStore as bB, depleteLots as bC, fifoOrder as bD, inKindDrawMsats as bE, isInKindDepletion as bF, isNonChannelBitcoinRail as bG, lotOwedSats as bH, netOwedSats as bI, wrapMppx as bJ, type CreditDrainEnqueue as bK, HostedSettlementReportObligations as bL, type DVMAuthScheme as bM, type CreditLedgerLike as bN, type X402RefundSettlementGate as bO, type CreditSnapshot as bP, type DrawResult as bQ, type X402SettlementStatus as bR, type X402UnresolvedRefund as bS, type GrownDrawResult as bT, type DrawResolution as bU, type FundingRecord as bV, type CreditInvoiceRecord as bW, type InvoiceSettlement as bX, type BlockedInvoiceCursor as bY, type InvoiceReconciliation as bZ, type InvoiceWriteOff as b_, usdcContractByCaip2 as ba, usdcContractFor as bb, usdcDomainNameFor as bc, usdcDomainVersionFor as bd, verifyDrainReceipt as be, verifyFundingReceipt as bf, verifyReceipt as bg, x402NetworkToCaip2 as bh, type X402ExactVersionSupport as bi, type X402Receipt as bj, type TransactionalPayoutHook as bk, type CashuMeltCompleted as bl, type CreditDepositPayload as bm, type CreditDrainPayload as bn, type FundingLot as bo, type LotDebit as bp, type LotDepletion as bq, type MppxServer as br, NON_CHANNEL_BITCOIN_RAILS as bs, type NonChannelBitcoinRail as bt, PayoutReporter as bu, PostgresTempoSessionStore as bv, RevenueReporter as bw, SIGNED_ENVELOPE_FIELDS as bx, SIGNED_ENVELOPE_TYPES as by, type X402TrackedChannel as bz, type CancelContent as c, type X402BatchSettlementConfig as c$, type StalePendingDrawCursor as c0, type TempoCreditLossEvidence as c1, type CreditLedgerQuerier as c2, type TempoCreditLoss as c3, type X402CreditLossEvidence as c4, type X402CreditLoss as c5, type DrainMethod as c6, type DrainRequestResult as c7, type BitcoinDepositLiability as c8, type CreditDrainRecord as c9, type JobTerminalReportPayload as cA, PostgresX402ChannelStorage as cB, type ReplayStoreBackend as cC, type RevenueSkippedNoRailPayload as cD, type RevenueSkippedNoRailReason as cE, type Secp256k1AuthOpts as cF, type X402ChannelStorageOpts as cG, type X402RelayLockHolder as cH, type X402RelaySubmissionLock as cI, X402RelaySubmissionLockError as cJ, allocateDrawValue as cK, clientCompatibilityAttributes as cL, clientCompatibilityMiddleware as cM, clientUpgradeRequired as cN, parseClientCapabilities as cO, parseClientCompatibility as cP, parseDvmClient as cQ, parseProtocolVersion as cR, requireClientCompatibility as cS, secp256k1Auth as cT, signedRequestInput as cU, type HostedIntent as cV, type X402SettlementIntent as cW, type HostedFundingReservation as cX, type X402SettlementCursor as cY, type X402SettlementWriteOff as cZ, type X402FacilitatorAuth as c_, type ChannelDrainCursor as ca, type DrainWriteOff as cb, type DrainReleaseResult as cc, type DrainFulfilment as cd, type DrainTransitionResult as ce, HostingCleanupFence as cf, CLIENT_COMPATIBILITY_HEADERS as cg, type ClientCompatibility as ch, type ClientCompatibilityEnv as ci, type ClientCompatibilityGate as cj, type ClientCompatibilityRequirement as ck, type ClientSemVer as cl, type CreditFundingBasis as cm, type CreditInvoiceStatus as cn, CreditLedger as co, CreditLedgerError as cp, type CreditLedgerErrorCode as cq, type CreditLedgerErrorDetails as cr, type CreditLedgerPool as cs, type CreditStatus as ct, DRAIN_DELIVERY_RESERVE_SATS as cu, DVM_PROTOCOL_VERSION as cv, type DrainConflictReason as cw, type DrawRailValue as cx, type DrawStatus as cy, type JobCostReportPayload as cz, type CanonicalEnvelope as d, type X402PayoutObserver as d0, type CreditDepositEnqueue as d1, type X402SettlementReconciliationReason as d2, type CreditDrawReleaseEnqueue as d3, type CreateSignedRequestVerifierOpts as e, type CreditConfig as f, type CreditView as g, DEFAULT_CREDIT_MAX as h, DEFAULT_CREDIT_MIN as i, DEFAULT_CREDIT_TTL_SECONDS as j, DEFAULT_JOB_RETENTION_DAYS as k, type DVMRouteContext as l, type InputType as m, InvalidCurrencyError as n, type PaymentMethod as o, type PriceValue as p, type ProgressContent as q, type PromptOpts as r, type QuoteContext as s, type QuoteResult as t, type ResponseContent as u, type SDKPaymentRequestOpts as v, SIGNED_REQUEST_AUTH_ID as w, SIGNED_REQUEST_STATEMENT_VERSION as x, type SignedRequestAudience as y, type SignedRequestDomain as z };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  PostgresTempoChargeStore
3
- } from "./chunk-KA6VN5FK.js";
3
+ } from "./chunk-RXPHMS4C.js";
4
4
  import "./chunk-YG7G4DPZ.js";
5
+ import "./chunk-LAKP6FUI.js";
5
6
  import "./chunk-COYKJRMM.js";
6
- import "./chunk-ETXDTUJO.js";
7
7
  export {
8
8
  PostgresTempoChargeStore
9
9
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  PostgresTempoSessionStore,
3
3
  assertMonotonicTransition
4
- } from "./chunk-X7EZ5CLI.js";
4
+ } from "./chunk-MON76YBJ.js";
5
5
  import "./chunk-YG7G4DPZ.js";
6
+ import "./chunk-TRNMTTPX.js";
7
+ import "./chunk-LAKP6FUI.js";
6
8
  import "./chunk-COYKJRMM.js";
7
- import "./chunk-P6QON7ER.js";
8
- import "./chunk-ETXDTUJO.js";
9
9
  export {
10
10
  PostgresTempoSessionStore,
11
11
  assertMonotonicTransition
@@ -1,6 +1,6 @@
1
- import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-BTGSQRfP.js';
2
- import { Y as JobReceipt, a1 as Message, a2 as MessageType, K as KVStore, L as Logger, u as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-CPdH1hei.js';
3
- import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-BVeF5_Jq.js';
1
+ import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-CbnouEnh.js';
2
+ import { $ as JobReceipt, a4 as Message, a0 as MessageType, K as KVStore, L as Logger, u as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-CJFiZU3n.js';
3
+ import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-BJRlmq2Q.js';
4
4
  import 'hono';
5
5
  import 'mppx';
6
6
  import '@x402/core/server';
@@ -4,21 +4,20 @@ import {
4
4
  import {
5
5
  MemoryJobStore,
6
6
  createInstrumentedFetch
7
- } from "../chunk-IV6Q7NRW.js";
7
+ } from "../chunk-RAGX6VG7.js";
8
8
  import {
9
9
  JobCancelledError
10
10
  } from "../chunk-AFV77S4C.js";
11
11
  import {
12
12
  createNoopLogger
13
- } from "../chunk-QR2EF2NI.js";
14
- import "../chunk-66HGCPBU.js";
15
- import "../chunk-FUJ36YDV.js";
13
+ } from "../chunk-AQ7OX5NX.js";
14
+ import "../chunk-KXWROQGK.js";
16
15
  import "../chunk-BQJIFRAZ.js";
16
+ import "../chunk-USL7ZEXN.js";
17
17
  import {
18
18
  validateCurrency
19
- } from "../chunk-BYCEKO65.js";
20
- import "../chunk-AT6V3SY7.js";
21
- import "../chunk-ETXDTUJO.js";
19
+ } from "../chunk-CLIAFTUR.js";
20
+ import "../chunk-LAKP6FUI.js";
22
21
 
23
22
  // src/sdk/testing/test-context.ts
24
23
  function createTestContext(opts) {
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-CPdH1hei.js';
1
+ import { C as Currency } from './step-cache-CJFiZU3n.js';
2
2
 
3
3
  /**
4
4
  * Thrown by `fiatToSatsCeil` / `satsToFiat` when the supplied `ratePerBtc` is
@@ -1,22 +1,13 @@
1
1
  import {
2
- connectedX402Payer,
3
2
  ensureAddress,
4
3
  generateX402PrivateKey,
5
4
  getX402Balance,
6
- loadX402Wallet,
7
- removeX402Wallet,
8
- repinX402WalletNetwork,
9
- resolveX402Asset,
10
- saveX402Wallet,
11
- tryX402Payment,
12
- x402WrongAssetHint
13
- } from "./chunk-LE74UEV7.js";
14
- import "./chunk-B2IROPQF.js";
15
- import "./chunk-MZRJR2CW.js";
5
+ resolveX402Asset
6
+ } from "./chunk-OFSOLHRX.js";
16
7
  import {
17
8
  verifyX402Payment
18
- } from "./chunk-7ZUKL4IV.js";
19
- import "./chunk-PLG4XER6.js";
9
+ } from "./chunk-H5FVVEEN.js";
10
+ import "./chunk-26W6GPCD.js";
20
11
  import {
21
12
  X402_DEFAULT_FACILITATOR,
22
13
  X402_DEFAULT_NETWORK,
@@ -35,13 +26,8 @@ import {
35
26
  paymentRequiredV2FromV1,
36
27
  usdcContractByCaip2,
37
28
  x402NetworkToCaip2
38
- } from "./chunk-IWQHUSMO.js";
39
- import "./chunk-PAIM66YA.js";
40
- import "./chunk-CZULM42S.js";
41
- import "./chunk-OFVV37XC.js";
42
- import "./chunk-66HGCPBU.js";
43
- import "./chunk-FUJ36YDV.js";
44
- import "./chunk-AT6V3SY7.js";
29
+ } from "./chunk-62FI3NJF.js";
30
+ import "./chunk-KXWROQGK.js";
45
31
  import {
46
32
  X402_NETWORKS,
47
33
  assertSupportedX402Network,
@@ -49,8 +35,8 @@ import {
49
35
  x402NetworkLabel,
50
36
  x402NetworkListForCopy,
51
37
  x402SupportedNetworksHint
52
- } from "./chunk-RLTSCKRI.js";
53
- import "./chunk-LIRAHP7B.js";
38
+ } from "./chunk-BPYMEMQX.js";
39
+ import "./chunk-LAKP6FUI.js";
54
40
  export {
55
41
  X402_DEFAULT_FACILITATOR,
56
42
  X402_DEFAULT_NETWORK,
@@ -62,7 +48,6 @@ export {
62
48
  buildPaymentRequirements,
63
49
  caip2ToX402Network,
64
50
  chainIdFromCaip2,
65
- connectedX402Payer,
66
51
  decodePayment,
67
52
  decodePaymentRequiredHeader,
68
53
  encodePayment,
@@ -72,19 +57,13 @@ export {
72
57
  exactEvmAuthorization,
73
58
  generateX402PrivateKey,
74
59
  getX402Balance,
75
- loadX402Wallet,
76
60
  paymentRequiredV2FromV1,
77
- removeX402Wallet,
78
- repinX402WalletNetwork,
79
61
  resolveX402Asset,
80
- saveX402Wallet,
81
- tryX402Payment,
82
62
  usdcContractByCaip2,
83
63
  verifyX402Payment,
84
64
  x402NetworkByCaip2,
85
65
  x402NetworkLabel,
86
66
  x402NetworkListForCopy,
87
67
  x402NetworkToCaip2,
88
- x402SupportedNetworksHint,
89
- x402WrongAssetHint
68
+ x402SupportedNetworksHint
90
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvmkit/sdk",
3
- "version": "0.6.0-rc.1",
3
+ "version": "0.7.0-rc.2",
4
4
  "description": "SDK for building accountless, pay-per-use Digital Vending Machines",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -61,7 +61,8 @@
61
61
  "test:db": "vitest run --config vitest.db.config.ts",
62
62
  "typecheck": "tsc --noEmit",
63
63
  "typecheck:scripts": "tsc --noEmit --project tsconfig.scripts.json",
64
- "verify": "node scripts/verify.mjs"
64
+ "verify": "node scripts/verify.mjs",
65
+ "check:ownership": "node scripts/check-caller-ownership.mjs"
65
66
  },
66
67
  "dependencies": {
67
68
  "@cashu/cashu-ts": "4.10.2",
@@ -1,25 +0,0 @@
1
- // src/lib/caller-loggers.ts
2
- var callerLoggers = buildNoopLoggers();
3
- function initCallerLoggers(nextLoggers) {
4
- callerLoggers = nextLoggers;
5
- }
6
- function buildNoopLoggers() {
7
- const noopLogger = {
8
- // eslint-disable-next-line @typescript-eslint/no-empty-function -- standalone caller has no exporter
9
- info() {
10
- },
11
- async span(_name, _attrs, fn) {
12
- return fn();
13
- }
14
- };
15
- return {
16
- cashu: noopLogger,
17
- lightning: noopLogger,
18
- x402: noopLogger
19
- };
20
- }
21
-
22
- export {
23
- callerLoggers,
24
- initCallerLoggers
25
- };
@@ -1,102 +0,0 @@
1
- // src/sdk/pricing/usd.ts
2
- var InvalidFxRateError = class extends Error {
3
- code = "invalid_fx_rate";
4
- ratePerBtc;
5
- constructor(ratePerBtc) {
6
- super(
7
- `invalid fx rate ${String(ratePerBtc)} \u2014 expected a finite positive number of fiat per BTC`
8
- );
9
- this.ratePerBtc = ratePerBtc;
10
- }
11
- };
12
- function fiatToSatsCeil(amount, ratePerBtc) {
13
- if (!Number.isFinite(ratePerBtc) || ratePerBtc <= 0) {
14
- throw new InvalidFxRateError(ratePerBtc);
15
- }
16
- if (!Number.isFinite(amount) || amount < 0) return 0;
17
- return Math.ceil(amount * 1e8 / ratePerBtc);
18
- }
19
- function satsToFiat(sats, ratePerBtc) {
20
- if (!Number.isFinite(ratePerBtc) || ratePerBtc <= 0) {
21
- throw new InvalidFxRateError(ratePerBtc);
22
- }
23
- return sats / 1e8 * ratePerBtc;
24
- }
25
- var InvalidUsdPriceError = class extends Error {
26
- constructor(field, value, detail) {
27
- super(`${field}: ${detail}`);
28
- this.field = field;
29
- this.value = value;
30
- this.name = "InvalidUsdPriceError";
31
- }
32
- field;
33
- value;
34
- code = "invalid_usd_price";
35
- };
36
- function parseUsdPrice(value, field) {
37
- if (!USD_PRICE_RE.test(value)) {
38
- throw new InvalidUsdPriceError(
39
- field,
40
- value,
41
- `${JSON.stringify(value)} is not a USD price literal. Use a "$X.XX" string, e.g. "$0.05".`
42
- );
43
- }
44
- const usd = parseFloat(value.slice(1));
45
- if (!Number.isFinite(usd) || usd < MIN_USD_PRICE) {
46
- throw new InvalidUsdPriceError(
47
- field,
48
- value,
49
- `${JSON.stringify(value)} is below ${MIN_USD_PRICE_LITERAL}, the smallest price the wire can carry \u2014 every price surface rounds to four decimals, so this would advertise as $0 and then charge anyway. Charge at least ${MIN_USD_PRICE_LITERAL}, or omit the price for a free capability.`
50
- );
51
- }
52
- if (roundUsd(usd) !== usd) {
53
- throw new InvalidUsdPriceError(
54
- field,
55
- value,
56
- `${JSON.stringify(value)} carries more than four decimal places. Every price surface rounds to four, so this would advertise ${formatUsd(roundUsd(usd))} and charge something else. Use at most four decimals.`
57
- );
58
- }
59
- if (!Number.isSafeInteger(Math.round(usd * 1e6))) {
60
- throw new InvalidUsdPriceError(
61
- field,
62
- value,
63
- `${JSON.stringify(value)} is too large to denominate. Use an amount under $9,007,199,254.`
64
- );
65
- }
66
- return usd;
67
- }
68
- function roundUsd(usd) {
69
- return Math.round(usd * 1e4) / 1e4;
70
- }
71
- function formatUsd(usd) {
72
- if (usd === 0) return "$0.00";
73
- if (usd >= 0.01) return `$${usd.toFixed(2)}`;
74
- return `$${usd.toFixed(4)}`;
75
- }
76
- function formatFiat(amount, currency) {
77
- const code = currency.toUpperCase();
78
- const symbol = FIAT_SYMBOLS[currency] ?? "";
79
- const digits = currency === "jpy" ? 0 : amount >= 0.01 || amount === 0 ? 2 : 4;
80
- const body = `${amount.toFixed(digits)} ${code}`;
81
- return symbol ? `${symbol}${body}` : body;
82
- }
83
- var USD_PRICE_RE = /^\$\d+(\.\d+)?$/;
84
- var MIN_USD_PRICE = 1e-4;
85
- var MIN_USD_PRICE_LITERAL = '"$0.0001"';
86
- var FIAT_SYMBOLS = {
87
- usd: "$",
88
- eur: "\u20AC",
89
- gbp: "\xA3",
90
- jpy: "\xA5"
91
- };
92
-
93
- export {
94
- InvalidFxRateError,
95
- fiatToSatsCeil,
96
- satsToFiat,
97
- InvalidUsdPriceError,
98
- parseUsdPrice,
99
- roundUsd,
100
- formatUsd,
101
- formatFiat
102
- };