uvd-x402-sdk 2.45.0 → 2.46.0

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/dist/index.d.mts CHANGED
@@ -189,6 +189,20 @@ interface TrafficEvent {
189
189
  description?: string;
190
190
  /** Payment scheme: `exact`, `escrow`, `commerce`, `upto`. */
191
191
  scheme?: string;
192
+ /**
193
+ * Why the operation failed, as a BOUNDED CATEGORY — never the error text.
194
+ *
195
+ * Present only on operations that errored, and only where the operator set
196
+ * `X402_EVENTS_PUBLISH_FAILURES=true`. A closed set (`contract_revert`,
197
+ * `invalid_signature`, `insufficient_funds`, `invalid_timing`,
198
+ * `blocked_address`, …, `other`) precisely so it can never carry an address
199
+ * or an RPC URL.
200
+ *
201
+ * Note the distinction it makes visible: `ok: false` with no `error` means the
202
+ * operation RESOLVED and came back negative; `error` set means it blew up.
203
+ * Before this existed the second case produced no event at all.
204
+ */
205
+ error?: string;
192
206
  }
193
207
  /** Raised when the stream cannot be opened. Carries the HTTP status. */
194
208
  declare class TrafficStreamError extends Error {
package/dist/index.d.ts CHANGED
@@ -189,6 +189,20 @@ interface TrafficEvent {
189
189
  description?: string;
190
190
  /** Payment scheme: `exact`, `escrow`, `commerce`, `upto`. */
191
191
  scheme?: string;
192
+ /**
193
+ * Why the operation failed, as a BOUNDED CATEGORY — never the error text.
194
+ *
195
+ * Present only on operations that errored, and only where the operator set
196
+ * `X402_EVENTS_PUBLISH_FAILURES=true`. A closed set (`contract_revert`,
197
+ * `invalid_signature`, `insufficient_funds`, `invalid_timing`,
198
+ * `blocked_address`, …, `other`) precisely so it can never carry an address
199
+ * or an RPC URL.
200
+ *
201
+ * Note the distinction it makes visible: `ok: false` with no `error` means the
202
+ * operation RESOLVED and came back negative; `error` set means it blew up.
203
+ * Before this existed the second case produced no event at all.
204
+ */
205
+ error?: string;
192
206
  }
193
207
  /** Raised when the stream cannot be opened. Carries the HTTP status. */
194
208
  declare class TrafficStreamError extends Error {
package/dist/index.js CHANGED
@@ -2489,6 +2489,7 @@ function parseTrafficEvent(frame) {
2489
2489
  if (typeof raw.payTo === "string") event.payTo = raw.payTo;
2490
2490
  if (typeof raw.description === "string") event.description = raw.description;
2491
2491
  if (typeof raw.scheme === "string") event.scheme = raw.scheme;
2492
+ if (typeof raw.error === "string") event.error = raw.error;
2492
2493
  return event;
2493
2494
  }
2494
2495
  function matchesFilters(event, options) {
@@ -2833,6 +2834,57 @@ var FacilitatorClient = class {
2833
2834
  }
2834
2835
  return await response.json();
2835
2836
  }
2837
+ /**
2838
+ * Aggregated totals per network and asset (`GET /api/stats`).
2839
+ *
2840
+ * **An index, not a ledger.** Records are written best-effort AFTER
2841
+ * settlement, so an outage loses rows while payments proceed — verify
2842
+ * anything that matters against the transaction hash. Counting starts when
2843
+ * the operator enabled the store, so earlier operations are UNKNOWN, not
2844
+ * zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
2845
+ * are not recorded at all: a 100% success rate means "no failures were
2846
+ * recorded".
2847
+ *
2848
+ * `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
2849
+ * 2^53) and each row carries its own `decimals`. **Use that, never a
2850
+ * constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
2851
+ * by 6 there overstates volume by 10^12. `decimals` is null when the asset is
2852
+ * unrecognised; render the atomic value rather than guessing a scale.
2853
+ */
2854
+ async getStats() {
2855
+ const response = await fetch(`${this.baseUrl}/api/stats`, { method: "GET" });
2856
+ if (!response.ok) {
2857
+ const errorText = await response.text();
2858
+ throw new Error(`GET /api/stats failed: ${response.status} - ${errorText}`);
2859
+ }
2860
+ return await response.json();
2861
+ }
2862
+ /**
2863
+ * Recent recorded operations, newest first (`GET /transactions`).
2864
+ *
2865
+ * There is **no pagination and no cursor**: this returns the newest N,
2866
+ * walking back at most 30 days. With 10,000 rows you get the newest 200, not
2867
+ * page one of fifty. `limit` is clamped to 200 by the facilitator.
2868
+ *
2869
+ * `network` matches the canonical slug `/supported` uses, which is not always
2870
+ * the alias you may send — `skale` is accepted inbound but records say
2871
+ * `skale-base`.
2872
+ */
2873
+ async getTransactions(options = {}) {
2874
+ const params = new URLSearchParams();
2875
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
2876
+ if (options.network) params.set("network", options.network);
2877
+ const query = params.toString();
2878
+ const response = await fetch(
2879
+ `${this.baseUrl}/transactions${query ? `?${query}` : ""}`,
2880
+ { method: "GET" }
2881
+ );
2882
+ if (!response.ok) {
2883
+ const errorText = await response.text();
2884
+ throw new Error(`GET /transactions failed: ${response.status} - ${errorText}`);
2885
+ }
2886
+ return await response.json();
2887
+ }
2836
2888
  /**
2837
2889
  * Get the facilitator's blocked/sanctioned addresses
2838
2890
  *