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.mjs CHANGED
@@ -2487,6 +2487,7 @@ function parseTrafficEvent(frame) {
2487
2487
  if (typeof raw.payTo === "string") event.payTo = raw.payTo;
2488
2488
  if (typeof raw.description === "string") event.description = raw.description;
2489
2489
  if (typeof raw.scheme === "string") event.scheme = raw.scheme;
2490
+ if (typeof raw.error === "string") event.error = raw.error;
2490
2491
  return event;
2491
2492
  }
2492
2493
  function matchesFilters(event, options) {
@@ -2831,6 +2832,57 @@ var FacilitatorClient = class {
2831
2832
  }
2832
2833
  return await response.json();
2833
2834
  }
2835
+ /**
2836
+ * Aggregated totals per network and asset (`GET /api/stats`).
2837
+ *
2838
+ * **An index, not a ledger.** Records are written best-effort AFTER
2839
+ * settlement, so an outage loses rows while payments proceed — verify
2840
+ * anything that matters against the transaction hash. Counting starts when
2841
+ * the operator enabled the store, so earlier operations are UNKNOWN, not
2842
+ * zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
2843
+ * are not recorded at all: a 100% success rate means "no failures were
2844
+ * recorded".
2845
+ *
2846
+ * `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
2847
+ * 2^53) and each row carries its own `decimals`. **Use that, never a
2848
+ * constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
2849
+ * by 6 there overstates volume by 10^12. `decimals` is null when the asset is
2850
+ * unrecognised; render the atomic value rather than guessing a scale.
2851
+ */
2852
+ async getStats() {
2853
+ const response = await fetch(`${this.baseUrl}/api/stats`, { method: "GET" });
2854
+ if (!response.ok) {
2855
+ const errorText = await response.text();
2856
+ throw new Error(`GET /api/stats failed: ${response.status} - ${errorText}`);
2857
+ }
2858
+ return await response.json();
2859
+ }
2860
+ /**
2861
+ * Recent recorded operations, newest first (`GET /transactions`).
2862
+ *
2863
+ * There is **no pagination and no cursor**: this returns the newest N,
2864
+ * walking back at most 30 days. With 10,000 rows you get the newest 200, not
2865
+ * page one of fifty. `limit` is clamped to 200 by the facilitator.
2866
+ *
2867
+ * `network` matches the canonical slug `/supported` uses, which is not always
2868
+ * the alias you may send — `skale` is accepted inbound but records say
2869
+ * `skale-base`.
2870
+ */
2871
+ async getTransactions(options = {}) {
2872
+ const params = new URLSearchParams();
2873
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
2874
+ if (options.network) params.set("network", options.network);
2875
+ const query = params.toString();
2876
+ const response = await fetch(
2877
+ `${this.baseUrl}/transactions${query ? `?${query}` : ""}`,
2878
+ { method: "GET" }
2879
+ );
2880
+ if (!response.ok) {
2881
+ const errorText = await response.text();
2882
+ throw new Error(`GET /transactions failed: ${response.status} - ${errorText}`);
2883
+ }
2884
+ return await response.json();
2885
+ }
2834
2886
  /**
2835
2887
  * Get the facilitator's blocked/sanctioned addresses
2836
2888
  *