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.
@@ -1318,6 +1318,57 @@ var FacilitatorClient = class {
1318
1318
  }
1319
1319
  return await response.json();
1320
1320
  }
1321
+ /**
1322
+ * Aggregated totals per network and asset (`GET /api/stats`).
1323
+ *
1324
+ * **An index, not a ledger.** Records are written best-effort AFTER
1325
+ * settlement, so an outage loses rows while payments proceed — verify
1326
+ * anything that matters against the transaction hash. Counting starts when
1327
+ * the operator enabled the store, so earlier operations are UNKNOWN, not
1328
+ * zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
1329
+ * are not recorded at all: a 100% success rate means "no failures were
1330
+ * recorded".
1331
+ *
1332
+ * `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
1333
+ * 2^53) and each row carries its own `decimals`. **Use that, never a
1334
+ * constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
1335
+ * by 6 there overstates volume by 10^12. `decimals` is null when the asset is
1336
+ * unrecognised; render the atomic value rather than guessing a scale.
1337
+ */
1338
+ async getStats() {
1339
+ const response = await fetch(`${this.baseUrl}/api/stats`, { method: "GET" });
1340
+ if (!response.ok) {
1341
+ const errorText = await response.text();
1342
+ throw new Error(`GET /api/stats failed: ${response.status} - ${errorText}`);
1343
+ }
1344
+ return await response.json();
1345
+ }
1346
+ /**
1347
+ * Recent recorded operations, newest first (`GET /transactions`).
1348
+ *
1349
+ * There is **no pagination and no cursor**: this returns the newest N,
1350
+ * walking back at most 30 days. With 10,000 rows you get the newest 200, not
1351
+ * page one of fifty. `limit` is clamped to 200 by the facilitator.
1352
+ *
1353
+ * `network` matches the canonical slug `/supported` uses, which is not always
1354
+ * the alias you may send — `skale` is accepted inbound but records say
1355
+ * `skale-base`.
1356
+ */
1357
+ async getTransactions(options = {}) {
1358
+ const params = new URLSearchParams();
1359
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
1360
+ if (options.network) params.set("network", options.network);
1361
+ const query = params.toString();
1362
+ const response = await fetch(
1363
+ `${this.baseUrl}/transactions${query ? `?${query}` : ""}`,
1364
+ { method: "GET" }
1365
+ );
1366
+ if (!response.ok) {
1367
+ const errorText = await response.text();
1368
+ throw new Error(`GET /transactions failed: ${response.status} - ${errorText}`);
1369
+ }
1370
+ return await response.json();
1371
+ }
1321
1372
  /**
1322
1373
  * Get the facilitator's blocked/sanctioned addresses
1323
1374
  *