uvd-x402-sdk 2.45.0 → 2.47.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 +88 -0
- package/dist/adapters/index.d.mts +3 -3
- package/dist/adapters/index.d.ts +3 -3
- package/dist/backend/index.d.mts +57 -2
- package/dist/backend/index.d.ts +57 -2
- package/dist/backend/index.js +58 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +58 -1
- package/dist/backend/index.mjs.map +1 -1
- package/dist/{index-DgChnK_c.d.mts → index-CVW8AhRX.d.mts} +1 -1
- package/dist/{index-DgChnK_c.d.ts → index-CVW8AhRX.d.ts} +1 -1
- package/dist/{index-BidnFGw_.d.mts → index-Cic-RnwJ.d.mts} +1 -1
- package/dist/{index-H64xdjKh.d.ts → index-DVJ9S8lP.d.ts} +1 -1
- package/dist/index.d.mts +401 -5
- package/dist/index.d.ts +401 -5
- package/dist/index.js +427 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +416 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{ows-DTDixPzO.d.ts → ows-C-KmORG9.d.ts} +1 -1
- package/dist/{ows-CYIVd4xO.d.mts → ows-Z9v4GxOZ.d.mts} +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/xrpl/index.d.mts +1 -1
- package/dist/providers/xrpl/index.d.ts +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/{wallet-0cX9Pw2F.d.mts → wallet-w7BnImDG.d.mts} +1 -1
- package/dist/{wallet-0cX9Pw2F.d.ts → wallet-w7BnImDG.d.ts} +1 -1
- package/package.json +38 -13
- package/src/backend/index.ts +92 -1
- package/src/erc8128.ts +443 -0
- package/src/escrow-preauth.ts +416 -0
- package/src/events.ts +15 -0
- package/src/index.ts +36 -0
package/README.md
CHANGED
|
@@ -13,9 +13,11 @@ Users sign a message or transaction, and the Ultravioleta facilitator handles on
|
|
|
13
13
|
- **Type-Safe**: Full TypeScript support
|
|
14
14
|
- **React & Wagmi**: First-class integrations
|
|
15
15
|
- **Signing Wallet Adapters**: EnvKeyAdapter (server/CLI), OWSWalletAdapter (Open Wallet Standard), or bring your own
|
|
16
|
+
- **ERC-8128 Signed Requests**: Authenticate HTTP requests with a wallet (RFC 9421 + EIP-191) — no API keys
|
|
16
17
|
- **ERC-8004 Trustless Agents**: On-chain reputation and identity across 20 networks (18 EVM + 2 Solana)
|
|
17
18
|
- **Escrow & Refunds**: Hold payments with dispute resolution
|
|
18
19
|
- **Advanced Escrow**: Full escrow lifecycle (authorize, release, refund, charge) with SigningWalletAdapter support
|
|
20
|
+
- **Escrow Pre-Auth**: Sign-on-assignment `X-Payment-Auth` builder (`buildEscrowPreAuth`) — vector-pinned parity with the Python SDK and Execution Market
|
|
19
21
|
- **Commerce Scheme**: `'commerce'` scheme alias for marketplace integrations (identical to `'escrow'` on-chain)
|
|
20
22
|
- **`/accepts` Negotiation**: Discover facilitator capabilities before constructing payments
|
|
21
23
|
- **Bazaar Discovery**: Register and discover paid resources across the x402 network
|
|
@@ -586,6 +588,69 @@ class MyAdapter implements SigningWalletAdapter {
|
|
|
586
588
|
}
|
|
587
589
|
```
|
|
588
590
|
|
|
591
|
+
## ERC-8128 Signed Requests
|
|
592
|
+
|
|
593
|
+
Authenticate HTTP requests with a wallet instead of an API key. The SDK builds the RFC 9421 signature base, signs it with EIP-191 personal_sign, and produces the `Signature`, `Signature-Input`, and (for bodies) `Content-Digest` headers. Used by APIs that only accept wallet signing, like [Execution Market](https://execution.market).
|
|
594
|
+
|
|
595
|
+
Wire format is pinned by golden vectors (`src/erc8128.vectors.json`): `alg="eip191"`, keyid always lowercase (`erc8128:{chainId}:{address}`), params in the order `created;expires;nonce;keyid;alg`.
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
import { createSignedFetch, EnvKeyAdapter } from 'uvd-x402-sdk';
|
|
599
|
+
|
|
600
|
+
// Auto-signing fetch: fetches a fresh nonce and signs every request
|
|
601
|
+
const signedFetch = createSignedFetch({
|
|
602
|
+
wallet: new EnvKeyAdapter(), // or privateKey: process.env.KEY!
|
|
603
|
+
apiBase: 'https://api.execution.market',
|
|
604
|
+
chainId: 8453, // Base (default)
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
const resp = await signedFetch('/api/v1/tasks', {
|
|
608
|
+
method: 'POST',
|
|
609
|
+
body: JSON.stringify({ title: 'test' }),
|
|
610
|
+
});
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
For manual control, sign a single request (the nonce is single-use — fetch one per request):
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
import { fetchNonce, signRequestWithWallet, EnvKeyAdapter } from 'uvd-x402-sdk';
|
|
617
|
+
|
|
618
|
+
const wallet = new EnvKeyAdapter();
|
|
619
|
+
const nonce = await fetchNonce('https://api.execution.market');
|
|
620
|
+
const headers = await signRequestWithWallet(wallet, {
|
|
621
|
+
method: 'POST',
|
|
622
|
+
url: 'https://api.execution.market/api/v1/tasks',
|
|
623
|
+
body: '{"title":"test"}',
|
|
624
|
+
nonce,
|
|
625
|
+
});
|
|
626
|
+
// headers = { Signature, 'Signature-Input', 'Content-Digest' } — merge into your request
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
Also available: `signRequest` (raw private key) and `signRequestWithSigner` (callback-based, for browser wallets / out-of-process signers where the key never leaves the signer), plus `buildSignatureBase` / `buildSignatureParams` to reproduce the exact signed bytes externally.
|
|
630
|
+
|
|
631
|
+
## Escrow Pre-Auth (sign-on-assignment)
|
|
632
|
+
|
|
633
|
+
Build and sign the EIP-3009 `ReceiveWithAuthorization` that locks a bounty in the x402r AuthCaptureEscrow, packed as the raw-JSON `X-Payment-Auth` wrapper the facilitator's `/settle` expects. Used by marketplaces on the escrow rail (e.g. [Execution Market](https://execution.market)'s universal escrow).
|
|
634
|
+
|
|
635
|
+
The EIP-3009 nonce is `AuthCaptureEscrow.getHash(paymentInfo)`, which **includes the receiver** — the signature cryptographically commits to the chosen worker, so it can only be created AT ASSIGNMENT. The wire format is pinned by golden vectors (`src/escrow-preauth.vectors.json`) shared with the Python SDK and Execution Market's dashboard/mobile suites.
|
|
636
|
+
|
|
637
|
+
```typescript
|
|
638
|
+
import { buildEscrowPreAuth, EnvKeyAdapter } from 'uvd-x402-sdk';
|
|
639
|
+
|
|
640
|
+
// Escrow config as published by the marketplace server
|
|
641
|
+
// (e.g. Execution Market's GET /api/v1/h2a/payment-config).
|
|
642
|
+
const paymentAuth = await buildEscrowPreAuth(new EnvKeyAdapter(), {
|
|
643
|
+
networkConfig: config.escrow.networks.base,
|
|
644
|
+
payerWallet: '0xPublisher...',
|
|
645
|
+
workerWallet: '0xWorker...', // escrow receiver — committed by the nonce
|
|
646
|
+
bountyAtomic: '100000', // $0.10 in 6-decimal USDC
|
|
647
|
+
reviewDeadlineSec: taskDeadline, // release window outlasts it
|
|
648
|
+
});
|
|
649
|
+
// Send as the X-Payment-Auth header (raw JSON, NOT base64).
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
Any `SigningWalletAdapter` works as the signer (only `signTypedData` is used); browser wallets can pass a minimal `{ signTypedData }` wrapper. Validation fails loud instead of falling back: incomplete network config, unknown tier, bounty outside the on-chain deposit limit ($100), or a `maxFeeBps` below the operator's 1300 bps all throw before anything is signed. `computeEscrowNonce` is exported to reproduce `AuthCaptureEscrow.getHash` externally.
|
|
653
|
+
|
|
589
654
|
## Multi-Stablecoin (EVM)
|
|
590
655
|
|
|
591
656
|
```typescript
|
|
@@ -1098,6 +1163,29 @@ const body = buildVerifyRequestV2(
|
|
|
1098
1163
|
> error that names no field. If you see it, check the envelope shape first, not
|
|
1099
1164
|
> the fields inside it.
|
|
1100
1165
|
|
|
1166
|
+
## Metrics and history (`getStats` / `getTransactions`)
|
|
1167
|
+
|
|
1168
|
+
```typescript
|
|
1169
|
+
const stats = await client.getStats();
|
|
1170
|
+
for (const row of stats.byNetworkAndAsset) {
|
|
1171
|
+
// Use the row's OWN decimals. USDC is 6 nearly everywhere and 18 on BSC —
|
|
1172
|
+
// scaling by a constant 6 overstates BSC volume by 10^12.
|
|
1173
|
+
console.log(row.network, row.settlesOk, row.volumeAtomic, row.decimals);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
const recent = await client.getTransactions({ limit: 20, network: 'base' });
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
> **An index, not a ledger.** Records are written best-effort *after*
|
|
1180
|
+
> settlement, so an outage loses rows while payments proceed — verify anything
|
|
1181
|
+
> that matters against the transaction hash. Counting starts when the operator
|
|
1182
|
+
> enabled the store, so earlier operations are **unknown, not zero**. And unless
|
|
1183
|
+
> failure publishing is on, operations that error are not recorded at all, so a
|
|
1184
|
+
> 100% success rate means "no failures were recorded".
|
|
1185
|
+
>
|
|
1186
|
+
> `getTransactions` has **no pagination**: it returns the newest N (capped at
|
|
1187
|
+
> 200), walking back at most 30 days.
|
|
1188
|
+
|
|
1101
1189
|
## Live Traffic Stream (`GET /events`)
|
|
1102
1190
|
|
|
1103
1191
|
The facilitator emits one Server-Sent Event per operation it handles, so you can
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { X as X402Version, b as PaymentResult } from '../index-
|
|
2
|
-
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-
|
|
3
|
-
import '../wallet-
|
|
1
|
+
import { X as X402Version, b as PaymentResult } from '../index-CVW8AhRX.mjs';
|
|
2
|
+
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-Z9v4GxOZ.mjs';
|
|
3
|
+
import '../wallet-w7BnImDG.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* uvd-x402-sdk - Wagmi/Viem Adapter
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { X as X402Version, b as PaymentResult } from '../index-
|
|
2
|
-
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-
|
|
3
|
-
import '../wallet-
|
|
1
|
+
import { X as X402Version, b as PaymentResult } from '../index-CVW8AhRX.js';
|
|
2
|
+
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-C-KmORG9.js';
|
|
3
|
+
import '../wallet-w7BnImDG.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* uvd-x402-sdk - Wagmi/Viem Adapter
|
package/dist/backend/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SigningWalletAdapter } from '../wallet-
|
|
2
|
-
import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-
|
|
1
|
+
import { S as SigningWalletAdapter } from '../wallet-w7BnImDG.mjs';
|
|
2
|
+
import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-CVW8AhRX.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Payment requirements sent to the facilitator
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SigningWalletAdapter } from '../wallet-
|
|
2
|
-
import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-
|
|
1
|
+
import { S as SigningWalletAdapter } from '../wallet-w7BnImDG.js';
|
|
2
|
+
import { e as X402Header, X as X402Version, f as X402PayloadData } from '../index-CVW8AhRX.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Payment requirements sent to the facilitator
|
|
@@ -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
|
@@ -1227,9 +1227,15 @@ var FacilitatorClient = class {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
}
|
|
1229
1229
|
const result = await response.json();
|
|
1230
|
+
const transactionHash = result.transaction ?? result.transactionHash ?? result.transaction_hash;
|
|
1231
|
+
if (result.success && !transactionHash) {
|
|
1232
|
+
console.warn(
|
|
1233
|
+
"[x402] settle reported success but carried no transaction hash under transaction/transactionHash/transaction_hash \u2014 treat delivery as unconfirmed"
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1230
1236
|
return {
|
|
1231
1237
|
success: true,
|
|
1232
|
-
transactionHash
|
|
1238
|
+
transactionHash,
|
|
1233
1239
|
network: result.network
|
|
1234
1240
|
};
|
|
1235
1241
|
} catch (error) {
|
|
@@ -1320,6 +1326,57 @@ var FacilitatorClient = class {
|
|
|
1320
1326
|
}
|
|
1321
1327
|
return await response.json();
|
|
1322
1328
|
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Aggregated totals per network and asset (`GET /api/stats`).
|
|
1331
|
+
*
|
|
1332
|
+
* **An index, not a ledger.** Records are written best-effort AFTER
|
|
1333
|
+
* settlement, so an outage loses rows while payments proceed — verify
|
|
1334
|
+
* anything that matters against the transaction hash. Counting starts when
|
|
1335
|
+
* the operator enabled the store, so earlier operations are UNKNOWN, not
|
|
1336
|
+
* zero. And unless `X402_EVENTS_PUBLISH_FAILURES=true`, operations that ERROR
|
|
1337
|
+
* are not recorded at all: a 100% success rate means "no failures were
|
|
1338
|
+
* recorded".
|
|
1339
|
+
*
|
|
1340
|
+
* `volumeAtomic` is a STRING (u256-shaped; a JS number loses precision above
|
|
1341
|
+
* 2^53) and each row carries its own `decimals`. **Use that, never a
|
|
1342
|
+
* constant** — USDC is 6 decimals nearly everywhere and 18 on BSC, so scaling
|
|
1343
|
+
* by 6 there overstates volume by 10^12. `decimals` is null when the asset is
|
|
1344
|
+
* unrecognised; render the atomic value rather than guessing a scale.
|
|
1345
|
+
*/
|
|
1346
|
+
async getStats() {
|
|
1347
|
+
const response = await fetch(`${this.baseUrl}/api/stats`, { method: "GET" });
|
|
1348
|
+
if (!response.ok) {
|
|
1349
|
+
const errorText = await response.text();
|
|
1350
|
+
throw new Error(`GET /api/stats failed: ${response.status} - ${errorText}`);
|
|
1351
|
+
}
|
|
1352
|
+
return await response.json();
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Recent recorded operations, newest first (`GET /transactions`).
|
|
1356
|
+
*
|
|
1357
|
+
* There is **no pagination and no cursor**: this returns the newest N,
|
|
1358
|
+
* walking back at most 30 days. With 10,000 rows you get the newest 200, not
|
|
1359
|
+
* page one of fifty. `limit` is clamped to 200 by the facilitator.
|
|
1360
|
+
*
|
|
1361
|
+
* `network` matches the canonical slug `/supported` uses, which is not always
|
|
1362
|
+
* the alias you may send — `skale` is accepted inbound but records say
|
|
1363
|
+
* `skale-base`.
|
|
1364
|
+
*/
|
|
1365
|
+
async getTransactions(options = {}) {
|
|
1366
|
+
const params = new URLSearchParams();
|
|
1367
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
1368
|
+
if (options.network) params.set("network", options.network);
|
|
1369
|
+
const query = params.toString();
|
|
1370
|
+
const response = await fetch(
|
|
1371
|
+
`${this.baseUrl}/transactions${query ? `?${query}` : ""}`,
|
|
1372
|
+
{ method: "GET" }
|
|
1373
|
+
);
|
|
1374
|
+
if (!response.ok) {
|
|
1375
|
+
const errorText = await response.text();
|
|
1376
|
+
throw new Error(`GET /transactions failed: ${response.status} - ${errorText}`);
|
|
1377
|
+
}
|
|
1378
|
+
return await response.json();
|
|
1379
|
+
}
|
|
1323
1380
|
/**
|
|
1324
1381
|
* Get the facilitator's blocked/sanctioned addresses
|
|
1325
1382
|
*
|