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/README.md +23 -0
- package/dist/backend/index.d.mts +55 -0
- package/dist/backend/index.d.ts +55 -0
- package/dist/backend/index.js +51 -0
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +51 -0
- package/dist/backend/index.mjs.map +1 -1
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +70 -0
- package/src/events.ts +15 -0
package/README.md
CHANGED
|
@@ -1098,6 +1098,29 @@ const body = buildVerifyRequestV2(
|
|
|
1098
1098
|
> error that names no field. If you see it, check the envelope shape first, not
|
|
1099
1099
|
> the fields inside it.
|
|
1100
1100
|
|
|
1101
|
+
## Metrics and history (`getStats` / `getTransactions`)
|
|
1102
|
+
|
|
1103
|
+
```typescript
|
|
1104
|
+
const stats = await client.getStats();
|
|
1105
|
+
for (const row of stats.byNetworkAndAsset) {
|
|
1106
|
+
// Use the row's OWN decimals. USDC is 6 nearly everywhere and 18 on BSC —
|
|
1107
|
+
// scaling by a constant 6 overstates BSC volume by 10^12.
|
|
1108
|
+
console.log(row.network, row.settlesOk, row.volumeAtomic, row.decimals);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
const recent = await client.getTransactions({ limit: 20, network: 'base' });
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
> **An index, not a ledger.** Records are written best-effort *after*
|
|
1115
|
+
> settlement, so an outage loses rows while payments proceed — verify anything
|
|
1116
|
+
> that matters against the transaction hash. Counting starts when the operator
|
|
1117
|
+
> enabled the store, so earlier operations are **unknown, not zero**. And unless
|
|
1118
|
+
> failure publishing is on, operations that error are not recorded at all, so a
|
|
1119
|
+
> 100% success rate means "no failures were recorded".
|
|
1120
|
+
>
|
|
1121
|
+
> `getTransactions` has **no pagination**: it returns the newest N (capped at
|
|
1122
|
+
> 200), walking back at most 30 days.
|
|
1123
|
+
|
|
1101
1124
|
## Live Traffic Stream (`GET /events`)
|
|
1102
1125
|
|
|
1103
1126
|
The facilitator emits one Server-Sent Event per operation it handles, so you can
|
package/dist/backend/index.d.mts
CHANGED
|
@@ -442,6 +442,61 @@ declare class FacilitatorClient {
|
|
|
442
442
|
}>;
|
|
443
443
|
[key: string]: unknown;
|
|
444
444
|
}>;
|
|
445
|
+
/**
|
|
446
|
+
* Aggregated totals per network and asset (`GET /api/stats`).
|
|
447
|
+
*
|
|
448
|
+
* **An index, not a ledger.** Records are written best-effort AFTER
|
|
449
|
+
* settlement, so an outage loses rows while payments proceed — verify
|
|
450
|
+
* anything that matters against the transaction hash. Counting starts when
|
|
451
|
+
* the operator enabled the store, so earlier operations are UNKNOWN, not
|
|
452
|
+
* zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
|
|
453
|
+
* are not recorded at all: a 100% success rate means "no failures were
|
|
454
|
+
* recorded".
|
|
455
|
+
*
|
|
456
|
+
* `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
|
|
457
|
+
* 2^53) and each row carries its own `decimals`. **Use that, never a
|
|
458
|
+
* constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
|
|
459
|
+
* by 6 there overstates volume by 10^12. `decimals` is null when the asset is
|
|
460
|
+
* unrecognised; render the atomic value rather than guessing a scale.
|
|
461
|
+
*/
|
|
462
|
+
getStats(): Promise<{
|
|
463
|
+
totals: {
|
|
464
|
+
settlesOk: number;
|
|
465
|
+
settlesFailed: number;
|
|
466
|
+
verifies: number;
|
|
467
|
+
networks: number;
|
|
468
|
+
};
|
|
469
|
+
byNetworkAndAsset: Array<{
|
|
470
|
+
network: string;
|
|
471
|
+
asset: string;
|
|
472
|
+
settlesOk: number;
|
|
473
|
+
settlesFailed: number;
|
|
474
|
+
verifies: number;
|
|
475
|
+
volumeAtomic: string;
|
|
476
|
+
decimals: number | null;
|
|
477
|
+
lastTs: number;
|
|
478
|
+
}>;
|
|
479
|
+
[key: string]: unknown;
|
|
480
|
+
}>;
|
|
481
|
+
/**
|
|
482
|
+
* Recent recorded operations, newest first (`GET /transactions`).
|
|
483
|
+
*
|
|
484
|
+
* There is **no pagination and no cursor**: this returns the newest N,
|
|
485
|
+
* walking back at most 30 days. With 10,000 rows you get the newest 200, not
|
|
486
|
+
* page one of fifty. `limit` is clamped to 200 by the facilitator.
|
|
487
|
+
*
|
|
488
|
+
* `network` matches the canonical slug `/supported` uses, which is not always
|
|
489
|
+
* the alias you may send — `skale` is accepted inbound but records say
|
|
490
|
+
* `skale-base`.
|
|
491
|
+
*/
|
|
492
|
+
getTransactions(options?: {
|
|
493
|
+
limit?: number;
|
|
494
|
+
network?: string;
|
|
495
|
+
}): Promise<{
|
|
496
|
+
transactions: Array<Record<string, unknown>>;
|
|
497
|
+
count: number;
|
|
498
|
+
[key: string]: unknown;
|
|
499
|
+
}>;
|
|
445
500
|
/**
|
|
446
501
|
* Get the facilitator's blocked/sanctioned addresses
|
|
447
502
|
*
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -442,6 +442,61 @@ declare class FacilitatorClient {
|
|
|
442
442
|
}>;
|
|
443
443
|
[key: string]: unknown;
|
|
444
444
|
}>;
|
|
445
|
+
/**
|
|
446
|
+
* Aggregated totals per network and asset (`GET /api/stats`).
|
|
447
|
+
*
|
|
448
|
+
* **An index, not a ledger.** Records are written best-effort AFTER
|
|
449
|
+
* settlement, so an outage loses rows while payments proceed — verify
|
|
450
|
+
* anything that matters against the transaction hash. Counting starts when
|
|
451
|
+
* the operator enabled the store, so earlier operations are UNKNOWN, not
|
|
452
|
+
* zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
|
|
453
|
+
* are not recorded at all: a 100% success rate means "no failures were
|
|
454
|
+
* recorded".
|
|
455
|
+
*
|
|
456
|
+
* `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
|
|
457
|
+
* 2^53) and each row carries its own `decimals`. **Use that, never a
|
|
458
|
+
* constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
|
|
459
|
+
* by 6 there overstates volume by 10^12. `decimals` is null when the asset is
|
|
460
|
+
* unrecognised; render the atomic value rather than guessing a scale.
|
|
461
|
+
*/
|
|
462
|
+
getStats(): Promise<{
|
|
463
|
+
totals: {
|
|
464
|
+
settlesOk: number;
|
|
465
|
+
settlesFailed: number;
|
|
466
|
+
verifies: number;
|
|
467
|
+
networks: number;
|
|
468
|
+
};
|
|
469
|
+
byNetworkAndAsset: Array<{
|
|
470
|
+
network: string;
|
|
471
|
+
asset: string;
|
|
472
|
+
settlesOk: number;
|
|
473
|
+
settlesFailed: number;
|
|
474
|
+
verifies: number;
|
|
475
|
+
volumeAtomic: string;
|
|
476
|
+
decimals: number | null;
|
|
477
|
+
lastTs: number;
|
|
478
|
+
}>;
|
|
479
|
+
[key: string]: unknown;
|
|
480
|
+
}>;
|
|
481
|
+
/**
|
|
482
|
+
* Recent recorded operations, newest first (`GET /transactions`).
|
|
483
|
+
*
|
|
484
|
+
* There is **no pagination and no cursor**: this returns the newest N,
|
|
485
|
+
* walking back at most 30 days. With 10,000 rows you get the newest 200, not
|
|
486
|
+
* page one of fifty. `limit` is clamped to 200 by the facilitator.
|
|
487
|
+
*
|
|
488
|
+
* `network` matches the canonical slug `/supported` uses, which is not always
|
|
489
|
+
* the alias you may send — `skale` is accepted inbound but records say
|
|
490
|
+
* `skale-base`.
|
|
491
|
+
*/
|
|
492
|
+
getTransactions(options?: {
|
|
493
|
+
limit?: number;
|
|
494
|
+
network?: string;
|
|
495
|
+
}): Promise<{
|
|
496
|
+
transactions: Array<Record<string, unknown>>;
|
|
497
|
+
count: number;
|
|
498
|
+
[key: string]: unknown;
|
|
499
|
+
}>;
|
|
445
500
|
/**
|
|
446
501
|
* Get the facilitator's blocked/sanctioned addresses
|
|
447
502
|
*
|
package/dist/backend/index.js
CHANGED
|
@@ -1320,6 +1320,57 @@ var FacilitatorClient = class {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
return await response.json();
|
|
1322
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Aggregated totals per network and asset (`GET /api/stats`).
|
|
1325
|
+
*
|
|
1326
|
+
* **An index, not a ledger.** Records are written best-effort AFTER
|
|
1327
|
+
* settlement, so an outage loses rows while payments proceed — verify
|
|
1328
|
+
* anything that matters against the transaction hash. Counting starts when
|
|
1329
|
+
* the operator enabled the store, so earlier operations are UNKNOWN, not
|
|
1330
|
+
* zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
|
|
1331
|
+
* are not recorded at all: a 100% success rate means "no failures were
|
|
1332
|
+
* recorded".
|
|
1333
|
+
*
|
|
1334
|
+
* `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
|
|
1335
|
+
* 2^53) and each row carries its own `decimals`. **Use that, never a
|
|
1336
|
+
* constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
|
|
1337
|
+
* by 6 there overstates volume by 10^12. `decimals` is null when the asset is
|
|
1338
|
+
* unrecognised; render the atomic value rather than guessing a scale.
|
|
1339
|
+
*/
|
|
1340
|
+
async getStats() {
|
|
1341
|
+
const response = await fetch(`${this.baseUrl}/api/stats`, { method: "GET" });
|
|
1342
|
+
if (!response.ok) {
|
|
1343
|
+
const errorText = await response.text();
|
|
1344
|
+
throw new Error(`GET /api/stats failed: ${response.status} - ${errorText}`);
|
|
1345
|
+
}
|
|
1346
|
+
return await response.json();
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Recent recorded operations, newest first (`GET /transactions`).
|
|
1350
|
+
*
|
|
1351
|
+
* There is **no pagination and no cursor**: this returns the newest N,
|
|
1352
|
+
* walking back at most 30 days. With 10,000 rows you get the newest 200, not
|
|
1353
|
+
* page one of fifty. `limit` is clamped to 200 by the facilitator.
|
|
1354
|
+
*
|
|
1355
|
+
* `network` matches the canonical slug `/supported` uses, which is not always
|
|
1356
|
+
* the alias you may send — `skale` is accepted inbound but records say
|
|
1357
|
+
* `skale-base`.
|
|
1358
|
+
*/
|
|
1359
|
+
async getTransactions(options = {}) {
|
|
1360
|
+
const params = new URLSearchParams();
|
|
1361
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1362
|
+
if (options.network) params.set("network", options.network);
|
|
1363
|
+
const query = params.toString();
|
|
1364
|
+
const response = await fetch(
|
|
1365
|
+
`${this.baseUrl}/transactions${query ? `?${query}` : ""}`,
|
|
1366
|
+
{ method: "GET" }
|
|
1367
|
+
);
|
|
1368
|
+
if (!response.ok) {
|
|
1369
|
+
const errorText = await response.text();
|
|
1370
|
+
throw new Error(`GET /transactions failed: ${response.status} - ${errorText}`);
|
|
1371
|
+
}
|
|
1372
|
+
return await response.json();
|
|
1373
|
+
}
|
|
1323
1374
|
/**
|
|
1324
1375
|
* Get the facilitator's blocked/sanctioned addresses
|
|
1325
1376
|
*
|