@oobe-protocol-labs/synapse-sap-sdk 0.15.0 → 0.15.1

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.
Files changed (151) hide show
  1. package/dist/cjs/client.js +1 -1
  2. package/dist/cjs/client.js.map +1 -1
  3. package/dist/esm/client.js +1 -1
  4. package/dist/esm/client.js.map +1 -1
  5. package/package.json +1 -1
  6. package/dist/esm/instructions/memory.d.ts +0 -8
  7. package/dist/esm/instructions/memory.d.ts.map +0 -1
  8. package/dist/esm/instructions/memory.js +0 -234
  9. package/dist/esm/instructions/memory.js.map +0 -1
  10. package/dist/types/constants/addresses.d.ts +0 -117
  11. package/dist/types/constants/addresses.d.ts.map +0 -1
  12. package/dist/types/constants/index.d.ts +0 -31
  13. package/dist/types/constants/index.d.ts.map +0 -1
  14. package/dist/types/constants/limits.d.ts +0 -149
  15. package/dist/types/constants/limits.d.ts.map +0 -1
  16. package/dist/types/constants/network.d.ts +0 -81
  17. package/dist/types/constants/network.d.ts.map +0 -1
  18. package/dist/types/constants/payments.d.ts +0 -121
  19. package/dist/types/constants/payments.d.ts.map +0 -1
  20. package/dist/types/constants/programs.d.ts +0 -69
  21. package/dist/types/constants/programs.d.ts.map +0 -1
  22. package/dist/types/constants/seeds.d.ts +0 -82
  23. package/dist/types/constants/seeds.d.ts.map +0 -1
  24. package/dist/types/core/client.d.ts +0 -467
  25. package/dist/types/core/client.d.ts.map +0 -1
  26. package/dist/types/core/connection.d.ts +0 -305
  27. package/dist/types/core/connection.d.ts.map +0 -1
  28. package/dist/types/core/index.d.ts +0 -20
  29. package/dist/types/core/index.d.ts.map +0 -1
  30. package/dist/types/errors/index.d.ts +0 -335
  31. package/dist/types/errors/index.d.ts.map +0 -1
  32. package/dist/types/events/geyser.d.ts +0 -150
  33. package/dist/types/events/geyser.d.ts.map +0 -1
  34. package/dist/types/events/index.d.ts +0 -248
  35. package/dist/types/events/index.d.ts.map +0 -1
  36. package/dist/types/idl/index.d.ts +0 -70
  37. package/dist/types/idl/index.d.ts.map +0 -1
  38. package/dist/types/index.d.ts +0 -86
  39. package/dist/types/index.d.ts.map +0 -1
  40. package/dist/types/modules/agent.d.ts +0 -156
  41. package/dist/types/modules/agent.d.ts.map +0 -1
  42. package/dist/types/modules/attestation.d.ts +0 -96
  43. package/dist/types/modules/attestation.d.ts.map +0 -1
  44. package/dist/types/modules/base.d.ts +0 -215
  45. package/dist/types/modules/base.d.ts.map +0 -1
  46. package/dist/types/modules/escrow-v2.d.ts +0 -285
  47. package/dist/types/modules/escrow-v2.d.ts.map +0 -1
  48. package/dist/types/modules/feedback.d.ts +0 -105
  49. package/dist/types/modules/feedback.d.ts.map +0 -1
  50. package/dist/types/modules/index.d.ts +0 -27
  51. package/dist/types/modules/index.d.ts.map +0 -1
  52. package/dist/types/modules/indexing.d.ts +0 -200
  53. package/dist/types/modules/indexing.d.ts.map +0 -1
  54. package/dist/types/modules/ledger.d.ts +0 -150
  55. package/dist/types/modules/ledger.d.ts.map +0 -1
  56. package/dist/types/modules/receipt.d.ts +0 -91
  57. package/dist/types/modules/receipt.d.ts.map +0 -1
  58. package/dist/types/modules/staking.d.ts +0 -51
  59. package/dist/types/modules/staking.d.ts.map +0 -1
  60. package/dist/types/modules/subscription.d.ts +0 -33
  61. package/dist/types/modules/subscription.d.ts.map +0 -1
  62. package/dist/types/modules/tools.d.ts +0 -172
  63. package/dist/types/modules/tools.d.ts.map +0 -1
  64. package/dist/types/modules/vault.d.ts +0 -240
  65. package/dist/types/modules/vault.d.ts.map +0 -1
  66. package/dist/types/parser/client.d.ts +0 -123
  67. package/dist/types/parser/client.d.ts.map +0 -1
  68. package/dist/types/parser/complete.d.ts +0 -90
  69. package/dist/types/parser/complete.d.ts.map +0 -1
  70. package/dist/types/parser/index.d.ts +0 -40
  71. package/dist/types/parser/index.d.ts.map +0 -1
  72. package/dist/types/parser/inner.d.ts +0 -114
  73. package/dist/types/parser/inner.d.ts.map +0 -1
  74. package/dist/types/parser/instructions.d.ts +0 -76
  75. package/dist/types/parser/instructions.d.ts.map +0 -1
  76. package/dist/types/parser/transaction.d.ts +0 -77
  77. package/dist/types/parser/transaction.d.ts.map +0 -1
  78. package/dist/types/parser/types.d.ts +0 -154
  79. package/dist/types/parser/types.d.ts.map +0 -1
  80. package/dist/types/pda/index.d.ts +0 -527
  81. package/dist/types/pda/index.d.ts.map +0 -1
  82. package/dist/types/plugin/index.d.ts +0 -171
  83. package/dist/types/plugin/index.d.ts.map +0 -1
  84. package/dist/types/plugin/protocols.d.ts +0 -152
  85. package/dist/types/plugin/protocols.d.ts.map +0 -1
  86. package/dist/types/plugin/schemas.d.ts +0 -829
  87. package/dist/types/plugin/schemas.d.ts.map +0 -1
  88. package/dist/types/postgres/adapter.d.ts +0 -355
  89. package/dist/types/postgres/adapter.d.ts.map +0 -1
  90. package/dist/types/postgres/index.d.ts +0 -24
  91. package/dist/types/postgres/index.d.ts.map +0 -1
  92. package/dist/types/postgres/serializers.d.ts +0 -30
  93. package/dist/types/postgres/serializers.d.ts.map +0 -1
  94. package/dist/types/postgres/sync.d.ts +0 -156
  95. package/dist/types/postgres/sync.d.ts.map +0 -1
  96. package/dist/types/postgres/types.d.ts +0 -167
  97. package/dist/types/postgres/types.d.ts.map +0 -1
  98. package/dist/types/registries/builder.d.ts +0 -333
  99. package/dist/types/registries/builder.d.ts.map +0 -1
  100. package/dist/types/registries/discovery.d.ts +0 -333
  101. package/dist/types/registries/discovery.d.ts.map +0 -1
  102. package/dist/types/registries/fairscale.d.ts +0 -680
  103. package/dist/types/registries/fairscale.d.ts.map +0 -1
  104. package/dist/types/registries/index.d.ts +0 -52
  105. package/dist/types/registries/index.d.ts.map +0 -1
  106. package/dist/types/registries/metaplex-bridge.d.ts +0 -488
  107. package/dist/types/registries/metaplex-bridge.d.ts.map +0 -1
  108. package/dist/types/registries/session.d.ts +0 -317
  109. package/dist/types/registries/session.d.ts.map +0 -1
  110. package/dist/types/registries/x402.d.ts +0 -523
  111. package/dist/types/registries/x402.d.ts.map +0 -1
  112. package/dist/types/types/accounts.d.ts +0 -817
  113. package/dist/types/types/accounts.d.ts.map +0 -1
  114. package/dist/types/types/common.d.ts +0 -166
  115. package/dist/types/types/common.d.ts.map +0 -1
  116. package/dist/types/types/endpoint.d.ts +0 -161
  117. package/dist/types/types/endpoint.d.ts.map +0 -1
  118. package/dist/types/types/enums.d.ts +0 -353
  119. package/dist/types/types/enums.d.ts.map +0 -1
  120. package/dist/types/types/index.d.ts +0 -29
  121. package/dist/types/types/index.d.ts.map +0 -1
  122. package/dist/types/types/instructions.d.ts +0 -400
  123. package/dist/types/types/instructions.d.ts.map +0 -1
  124. package/dist/types/utils/anchor-errors.d.ts +0 -61
  125. package/dist/types/utils/anchor-errors.d.ts.map +0 -1
  126. package/dist/types/utils/endpoint-validator.d.ts +0 -110
  127. package/dist/types/utils/endpoint-validator.d.ts.map +0 -1
  128. package/dist/types/utils/escrow-validation.d.ts +0 -145
  129. package/dist/types/utils/escrow-validation.d.ts.map +0 -1
  130. package/dist/types/utils/hash.d.ts +0 -75
  131. package/dist/types/utils/hash.d.ts.map +0 -1
  132. package/dist/types/utils/index.d.ts +0 -36
  133. package/dist/types/utils/index.d.ts.map +0 -1
  134. package/dist/types/utils/merchant-validator.d.ts +0 -176
  135. package/dist/types/utils/merchant-validator.d.ts.map +0 -1
  136. package/dist/types/utils/network-normalizer.d.ts +0 -120
  137. package/dist/types/utils/network-normalizer.d.ts.map +0 -1
  138. package/dist/types/utils/priority-fee.d.ts +0 -205
  139. package/dist/types/utils/priority-fee.d.ts.map +0 -1
  140. package/dist/types/utils/rpc-strategy.d.ts +0 -179
  141. package/dist/types/utils/rpc-strategy.d.ts.map +0 -1
  142. package/dist/types/utils/schemas.d.ts +0 -351
  143. package/dist/types/utils/schemas.d.ts.map +0 -1
  144. package/dist/types/utils/serialization.d.ts +0 -69
  145. package/dist/types/utils/serialization.d.ts.map +0 -1
  146. package/dist/types/utils/validation.d.ts +0 -29
  147. package/dist/types/utils/validation.d.ts.map +0 -1
  148. package/dist/types/utils/volume-curve.d.ts +0 -60
  149. package/dist/types/utils/volume-curve.d.ts.map +0 -1
  150. package/dist/types/utils/x402-direct.d.ts +0 -114
  151. package/dist/types/utils/x402-direct.d.ts.map +0 -1
@@ -1,523 +0,0 @@
1
- /**
2
- * @module registries/x402
3
- * @description x402 payment flow registry — high-level helpers for
4
- * the complete x402 HTTP micropayment lifecycle.
5
- *
6
- * Implements the x402 payment standard on SAP:
7
- *
8
- * ┌──────────┐ HTTP 402 ┌──────────┐
9
- * │ Client │ ──────────────→│ Agent │
10
- * └────┬─────┘ └────┬─────┘
11
- * │ 1. Discover pricing │
12
- * │ 2. Create/fund escrow │
13
- * │ 3. Call via x402 header │
14
- * │ │
15
- * │ 4. Agent serves request │
16
- * │ 5. Agent settles onchain │
17
- * │ ← PaymentSettledEvent ← │
18
- * │ 6. Client verifies │
19
- * └───────────────────────────┘
20
- *
21
- * This registry provides:
22
- * - Pricing estimation with volume curve support
23
- * - x402 HTTP header generation
24
- * - Escrow lifecycle management
25
- * - Settlement verification
26
- * - Balance/expiry monitoring
27
- *
28
- * @category Registries
29
- * @since v0.1.0
30
- *
31
- * @example
32
- * ```ts
33
- * const x402 = client.x402;
34
- *
35
- * // === CLIENT SIDE ===
36
- *
37
- * // 1. Estimate cost before committing
38
- * const estimate = x402.estimateCost(agentWallet, 100);
39
- *
40
- * // 2. Prepare payment (creates escrow + deposits)
41
- * const ctx = await x402.preparePayment(agentWallet, {
42
- * pricePerCall: 1000,
43
- * maxCalls: 100,
44
- * deposit: 100_000,
45
- * });
46
- *
47
- * // 3. Build x402 HTTP headers for API calls
48
- * const headers = x402.buildPaymentHeaders(ctx);
49
- *
50
- * // 4. Check balance
51
- * const balance = await x402.getBalance(agentWallet);
52
- *
53
- * // === AGENT SIDE ===
54
- *
55
- * // 5. Settle after serving calls
56
- * const receipt = await x402.settle(depositorWallet, 5, serviceData);
57
- *
58
- * // 6. Batch settle for efficiency
59
- * const batchReceipt = await x402.settleBatch(depositorWallet, settlements);
60
- *
61
- * // 7. Verify a settlement TX
62
- * const verified = await x402.verifySettlement(txSignature);
63
- * ```
64
- */
65
- import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
66
- import { BaseModule } from "../modules/base";
67
- import { BN } from "@coral-xyz/anchor";
68
- import type { SapProgram } from "../modules/base";
69
- import type { SapNetworkId } from "../constants/network";
70
- import type { EscrowAccountData, EscrowAccountV2Data, VolumeCurveBreakpoint } from "../types";
71
- import type { SettleOptions } from "../utils/priority-fee";
72
- export type { SettleOptions } from "../utils/priority-fee";
73
- /**
74
- * @interface CostEstimate
75
- * @name CostEstimate
76
- * @description Cost estimation result from {@link X402Registry.estimateCost} or
77
- * {@link X402Registry.calculateCost}. Includes total cost, effective price per call,
78
- * and per-tier breakdown when volume curves apply.
79
- * @category Registries
80
- * @since v0.1.0
81
- */
82
- export interface CostEstimate {
83
- /** Total cost in smallest token unit. */
84
- readonly totalCost: BN;
85
- /** Number of calls estimated. */
86
- readonly calls: number;
87
- /** Effective price per call (weighted average). */
88
- readonly effectivePricePerCall: BN;
89
- /** Whether volume curve applies. */
90
- readonly hasVolumeCurve: boolean;
91
- /** Breakdown by tier (if volume curve). */
92
- readonly tiers: Array<{
93
- readonly calls: number;
94
- readonly pricePerCall: BN;
95
- readonly subtotal: BN;
96
- }>;
97
- }
98
- /**
99
- * @interface PaymentContext
100
- * @name PaymentContext
101
- * @description x402 payment context after escrow creation via {@link X402Registry.preparePayment}.
102
- * Contains all information needed to build x402 HTTP headers and track the payment flow.
103
- * @category Registries
104
- * @since v0.1.0
105
- */
106
- export interface PaymentContext {
107
- /** Escrow PDA address. */
108
- readonly escrowPda: PublicKey;
109
- /** Agent PDA address. */
110
- readonly agentPda: PublicKey;
111
- /** Agent wallet. */
112
- readonly agentWallet: PublicKey;
113
- /** Depositor (client) wallet. */
114
- readonly depositorWallet: PublicKey;
115
- /** Price per call in smallest token unit. */
116
- readonly pricePerCall: BN;
117
- /** Max calls allowed. */
118
- readonly maxCalls: BN;
119
- /** Escrow creation TX signature. */
120
- readonly txSignature: TransactionSignature;
121
- /**
122
- * Network identifier for the `X-Payment-Network` header.
123
- * Persisted at escrow creation so every subsequent
124
- * `buildPaymentHeaders(ctx)` call uses the correct value.
125
- *
126
- * @default SapNetwork.SOLANA_MAINNET
127
- * @since v0.4.3
128
- */
129
- readonly networkIdentifier: string;
130
- }
131
- /**
132
- * @interface PreparePaymentOptions
133
- * @name PreparePaymentOptions
134
- * @description Options for preparing an x402 payment via {@link X402Registry.preparePayment}.
135
- * Defines pricing, deposit, expiry, volume curve, and token configuration.
136
- * @category Registries
137
- * @since v0.1.0
138
- */
139
- export interface PreparePaymentOptions {
140
- /** Base price per call (smallest token unit). */
141
- readonly pricePerCall: number | string | BN;
142
- /** Max calls allowed (0 = unlimited). */
143
- readonly maxCalls?: number | string | BN;
144
- /** Initial deposit amount (smallest token unit). */
145
- readonly deposit: number | string | BN;
146
- /** Expiry timestamp in unix seconds (0 = never). */
147
- readonly expiresAt?: number | string | BN;
148
- /** Volume curve breakpoints. */
149
- readonly volumeCurve?: Array<{
150
- afterCalls: number;
151
- pricePerCall: number | string | BN;
152
- }>;
153
- /** SPL token mint (null = native SOL). */
154
- readonly tokenMint?: PublicKey | null;
155
- /** Token decimals (default: 9 for SOL). */
156
- readonly tokenDecimals?: number;
157
- /**
158
- * Network identifier written into the `X-Payment-Network` header.
159
- *
160
- * Accepts any {@link SapNetworkId} constant or a custom string.
161
- * Defaults to `SapNetwork.SOLANA_MAINNET` (`"solana:mainnet-beta"`).
162
- *
163
- * @example
164
- * ```ts
165
- * import { SapNetwork } from "@synapse-sap/sdk";
166
- *
167
- * // Use genesis-hash form for Kamiyo / Helius x402
168
- * const ctx = await x402.preparePayment(agentWallet, {
169
- * pricePerCall: 1000,
170
- * deposit: 100_000,
171
- * networkIdentifier: SapNetwork.SOLANA_MAINNET_GENESIS,
172
- * });
173
- * ```
174
- *
175
- * @default SapNetwork.SOLANA_MAINNET
176
- * @since v0.4.3
177
- */
178
- readonly networkIdentifier?: SapNetworkId | string;
179
- }
180
- /**
181
- * @interface X402Headers
182
- * @name X402Headers
183
- * @description x402 HTTP headers for API requests.
184
- * Include these headers when calling an agent’s x402 endpoint.
185
- * Built by {@link X402Registry.buildPaymentHeaders} or
186
- * {@link X402Registry.buildPaymentHeadersFromEscrow}.
187
- * @category Registries
188
- * @since v0.1.0
189
- */
190
- export interface X402Headers {
191
- /** x402 protocol header. */
192
- readonly "X-Payment-Protocol": "SAP-x402";
193
- /** Escrow PDA address (base58). */
194
- readonly "X-Payment-Escrow": string;
195
- /** Agent PDA address (base58). */
196
- readonly "X-Payment-Agent": string;
197
- /** Client wallet address (base58). */
198
- readonly "X-Payment-Depositor": string;
199
- /** Max calls remaining. */
200
- readonly "X-Payment-MaxCalls": string;
201
- /** Price per call. */
202
- readonly "X-Payment-PricePerCall": string;
203
- /** SAP program ID. */
204
- readonly "X-Payment-Program": string;
205
- /** Solana cluster. */
206
- readonly "X-Payment-Network": string;
207
- }
208
- /**
209
- * @interface EscrowBalance
210
- * @name EscrowBalance
211
- * @description Escrow balance and status returned by {@link X402Registry.getBalance}.
212
- * Includes current balance, deposit/settlement totals, remaining calls,
213
- * expiry status, and affordable call estimate.
214
- * @category Registries
215
- * @since v0.1.0
216
- */
217
- export interface EscrowBalance {
218
- /** Current balance. */
219
- readonly balance: BN;
220
- /** Total deposited. */
221
- readonly totalDeposited: BN;
222
- /** Total settled. */
223
- readonly totalSettled: BN;
224
- /** Total calls settled. */
225
- readonly totalCallsSettled: BN;
226
- /** Calls remaining (maxCalls - settled, or Infinity if unlimited). */
227
- readonly callsRemaining: number;
228
- /** Is the escrow expired? */
229
- readonly isExpired: boolean;
230
- /** Estimated calls affordable with current balance. */
231
- readonly affordableCalls: number;
232
- }
233
- /**
234
- * @interface SettlementResult
235
- * @name SettlementResult
236
- * @description Settlement result with verification data from {@link X402Registry.settle}.
237
- * Contains the transaction signature, calls settled, amount transferred,
238
- * and the service hash used.
239
- * @category Registries
240
- * @since v0.1.0
241
- */
242
- export interface SettlementResult {
243
- /** Transaction signature. */
244
- readonly txSignature: TransactionSignature;
245
- /** Calls settled. */
246
- readonly callsSettled: number;
247
- /** Amount transferred. */
248
- readonly amount: BN;
249
- /** Service hash used. */
250
- readonly serviceHash: number[];
251
- }
252
- /**
253
- * @interface BatchSettlementResult
254
- * @name BatchSettlementResult
255
- * @description Batch settlement result from {@link X402Registry.settleBatch}.
256
- * Aggregates totals across all individual settlements in the batch.
257
- * @category Registries
258
- * @since v0.1.0
259
- */
260
- export interface BatchSettlementResult {
261
- /** Transaction signature. */
262
- readonly txSignature: TransactionSignature;
263
- /** Total calls settled. */
264
- readonly totalCalls: number;
265
- /** Total amount transferred. */
266
- readonly totalAmount: BN;
267
- /** Number of individual settlements in batch. */
268
- readonly settlementCount: number;
269
- }
270
- /**
271
- * @name X402Registry
272
- * @description x402 payment flow registry for the SAP network.
273
- *
274
- * Provides the complete x402 HTTP micropayment lifecycle: pricing
275
- * estimation, escrow management, HTTP header generation, settlement,
276
- * and balance monitoring. Used by both clients (payers) and agents (payees).
277
- *
278
- * @category Registries
279
- * @since v0.1.0
280
- *
281
- * @example
282
- * ```ts
283
- * const x402 = client.x402;
284
- *
285
- * // Client: prepare payment and build headers
286
- * const ctx = await x402.preparePayment(agentWallet, {
287
- * pricePerCall: 1000, maxCalls: 100, deposit: 100_000,
288
- * });
289
- * const headers = x402.buildPaymentHeaders(ctx);
290
- *
291
- * // Agent: settle calls after serving
292
- * const receipt = await x402.settle(depositorWallet, 5, "service-data");
293
- * ```
294
- */
295
- export declare class X402Registry extends BaseModule {
296
- private readonly wallet;
297
- constructor(program: SapProgram);
298
- /**
299
- * @name estimateCost
300
- * @description Estimate the cost of N calls to an agent.
301
- * Reads the escrow data if it exists, falls back to the agent’s pricing.
302
- * Supports volume curve pricing for tiered cost calculation.
303
- *
304
- * @param agentWallet - Agent wallet address.
305
- * @param calls - Number of calls to estimate.
306
- * @param opts - Optional: provide pricing directly to avoid on-chain fetch.
307
- * @param opts.pricePerCall - Base price per call.
308
- * @param opts.volumeCurve - Volume curve breakpoints.
309
- * @param opts.totalCallsBefore - Total calls already settled (for curve offset).
310
- * @returns A {@link CostEstimate} with total cost and per-tier breakdown.
311
- * @since v0.1.0
312
- */
313
- estimateCost(agentWallet: PublicKey, calls: number, opts?: {
314
- pricePerCall?: BN;
315
- volumeCurve?: VolumeCurveBreakpoint[];
316
- totalCallsBefore?: number;
317
- }): Promise<CostEstimate>;
318
- /**
319
- * @name calculateCost
320
- * @description Pure cost calculation (no network calls).
321
- * Implements the same tiered pricing logic as the on-chain program.
322
- *
323
- * @param basePrice - Base price per call in smallest token unit.
324
- * @param volumeCurve - Volume curve breakpoints.
325
- * @param totalCallsBefore - Total calls already settled (cursor offset).
326
- * @param calls - Number of calls to calculate cost for.
327
- * @returns A {@link CostEstimate} with total cost and per-tier breakdown.
328
- * @since v0.1.0
329
- */
330
- calculateCost(basePrice: BN, volumeCurve: VolumeCurveBreakpoint[], totalCallsBefore: number, calls: number): CostEstimate;
331
- /**
332
- * @name preparePayment
333
- * @description Prepare an x402 payment flow — creates and funds an escrow.
334
- * Derives the escrow PDA, sends the `createEscrow` instruction, and returns
335
- * a {@link PaymentContext} for building x402 headers.
336
- *
337
- * @param agentWallet - The agent’s wallet public key.
338
- * @param opts - Payment options (price, max calls, deposit, etc.).
339
- * @returns A {@link PaymentContext} with escrow details and transaction signature.
340
- * @since v0.1.0
341
- * @deprecated Since v0.7.0 — Creates a V1 escrow. Use `client.escrowV2.create()` for
342
- * V2 escrows with dispute windows, co-signing, and settlement security.
343
- *
344
- * @example
345
- * ```ts
346
- * const ctx = await x402.preparePayment(agentWallet, {
347
- * pricePerCall: 1000,
348
- * maxCalls: 100,
349
- * deposit: 100_000,
350
- * });
351
- * ```
352
- */
353
- preparePayment(agentWallet: PublicKey, opts: PreparePaymentOptions): Promise<PaymentContext>;
354
- /**
355
- * @name addFunds
356
- * @description Add more funds to an existing escrow.
357
- *
358
- * @param agentWallet - Agent wallet of the escrow.
359
- * @param amount - Amount to deposit in smallest token unit.
360
- * @returns The transaction signature.
361
- * @since v0.1.0
362
- * @deprecated Since v0.7.0 — Operates on V1 escrows only. Use `client.escrowV2.deposit()` instead.
363
- */
364
- addFunds(agentWallet: PublicKey, amount: number | string | BN): Promise<TransactionSignature>;
365
- /**
366
- * @name withdrawFunds
367
- * @description Withdraw remaining funds from an escrow.
368
- *
369
- * @param agentWallet - Agent wallet of the escrow.
370
- * @param amount - Amount to withdraw in smallest token unit.
371
- * @returns The transaction signature.
372
- * @since v0.1.0
373
- * @deprecated Since v0.7.0 — Operates on V1 escrows only. Use `client.escrowV2.withdraw()` instead.
374
- */
375
- withdrawFunds(agentWallet: PublicKey, amount: number | string | BN): Promise<TransactionSignature>;
376
- /**
377
- * @name closeEscrow
378
- * @description Close an empty escrow (balance must be 0).
379
- * Reclaims the rent-exempt lamports.
380
- *
381
- * @param agentWallet - Agent wallet of the escrow.
382
- * @returns The transaction signature.
383
- * @since v0.1.0
384
- * @deprecated Since v0.7.0 — Operates on V1 escrows only. Use `client.escrowV2.close()` instead.
385
- */
386
- closeEscrow(agentWallet: PublicKey): Promise<TransactionSignature>;
387
- /**
388
- * @name buildPaymentHeaders
389
- * @description Build x402 HTTP headers for API requests.
390
- * Include these headers when calling an agent’s x402 endpoint.
391
- *
392
- * @param ctx - Payment context from {@link X402Registry.preparePayment}.
393
- * @param opts - Optional settings.
394
- * @param opts.network - Solana cluster name (defaults to `"mainnet-beta"`).
395
- * @returns An {@link X402Headers} object ready to merge into HTTP requests.
396
- * @since v0.1.0
397
- */
398
- buildPaymentHeaders(ctx: PaymentContext, opts?: {
399
- network?: string;
400
- }): X402Headers;
401
- /**
402
- * @name buildPaymentHeadersFromEscrow
403
- * @description Build x402 headers directly from an agent wallet (fetches escrow data).
404
- * Convenience method that fetches the escrow account on-chain.
405
- *
406
- * @param agentWallet - Agent wallet to look up the escrow for.
407
- * @param opts - Optional settings.
408
- * @param opts.network - Network identifier for the `X-Payment-Network` header.
409
- * Defaults to `SapNetwork.SOLANA_MAINNET`.
410
- * @returns An {@link X402Headers} object, or `null` if no escrow exists.
411
- * @since v0.1.0
412
- */
413
- buildPaymentHeadersFromEscrow(agentWallet: PublicKey, opts?: {
414
- network?: SapNetworkId | string;
415
- }): Promise<X402Headers | null>;
416
- /**
417
- * @name settle
418
- * @description Settle calls — agent claims payment for calls served.
419
- * Must be called by the agent owner wallet. Calculates the settlement
420
- * amount using the escrow’s pricing and volume curve.
421
- *
422
- * @param depositorWallet - The client wallet that funded the escrow.
423
- * @param callsToSettle - Number of calls to settle.
424
- * @param serviceData - Raw service data (auto-hashed to `service_hash`).
425
- * @param opts - Optional {@link SettleOptions} for priority fees and RPC tuning.
426
- * @returns A {@link SettlementResult} with transaction details and amount.
427
- * @since v0.1.0
428
- * @updated v0.6.2 — Added optional `opts` parameter for priority fees.
429
- *
430
- * @example
431
- * ```ts
432
- * // Default (no priority fee)
433
- * const receipt = await x402.settle(depositor, 1, "data");
434
- *
435
- * // Fast settlement with priority fee
436
- * import { FAST_SETTLE_OPTIONS } from "@synapse-sap/sdk";
437
- * const receipt = await x402.settle(depositor, 1, "data", FAST_SETTLE_OPTIONS);
438
- *
439
- * // Custom priority fee
440
- * const receipt = await x402.settle(depositor, 1, "data", {
441
- * priorityFeeMicroLamports: 10_000,
442
- * computeUnits: 100_000,
443
- * skipPreflight: true,
444
- * });
445
- * ```
446
- */
447
- settle(depositorWallet: PublicKey, callsToSettle: number, serviceData: string | Buffer | Uint8Array, opts?: SettleOptions): Promise<SettlementResult>;
448
- /**
449
- * @name settleBatch
450
- * @description Batch settle — process up to 10 settlements in one TX.
451
- * Must be called by the agent owner wallet. More gas-efficient than
452
- * individual settlements.
453
- *
454
- * Optionally accepts {@link SettleOptions} to configure priority fees,
455
- * compute budget, and RPC behavior for faster confirmation.
456
- *
457
- * @param depositorWallet - The client wallet that funded the escrow.
458
- * @param entries - Array of `{ calls, serviceData }` settlement entries.
459
- * @param opts - Optional {@link SettleOptions} for priority fees and RPC tuning.
460
- * @returns A {@link BatchSettlementResult} with aggregated totals.
461
- * @since v0.1.0
462
- * @updated v0.6.2 — Added optional `opts` parameter for priority fees.
463
- *
464
- * @example
465
- * ```ts
466
- * import { FAST_BATCH_SETTLE_OPTIONS } from "@synapse-sap/sdk";
467
- * const receipt = await x402.settleBatch(depositor, entries, FAST_BATCH_SETTLE_OPTIONS);
468
- * ```
469
- */
470
- settleBatch(depositorWallet: PublicKey, entries: Array<{
471
- calls: number;
472
- serviceData: string | Buffer | Uint8Array;
473
- }>, opts?: SettleOptions): Promise<BatchSettlementResult>;
474
- /**
475
- * @name getBalance
476
- * @description Get the current escrow balance and status.
477
- * Returns balance, deposit/settlement totals, remaining calls,
478
- * expiry status, and affordable call estimate.
479
- *
480
- * @param agentWallet - Agent wallet of the escrow.
481
- * @param depositor - Depositor wallet (defaults to caller).
482
- * @returns An {@link EscrowBalance}, or `null` if no escrow exists.
483
- * @since v0.1.0
484
- */
485
- getBalance(agentWallet: PublicKey, depositor?: PublicKey): Promise<EscrowBalance | null>;
486
- /**
487
- * @name hasEscrow
488
- * @description Check if an escrow exists for a given agent + depositor pair.
489
- *
490
- * @param agentWallet - Agent wallet to check.
491
- * @param depositor - Depositor wallet (defaults to caller).
492
- * @returns `true` if the escrow account exists on-chain.
493
- * @since v0.1.0
494
- */
495
- hasEscrow(agentWallet: PublicKey, depositor?: PublicKey): Promise<boolean>;
496
- /**
497
- * @name fetchEscrow
498
- * @description Fetch the raw escrow account data.
499
- *
500
- * @param agentWallet - Agent wallet of the escrow.
501
- * @param depositor - Depositor wallet (defaults to caller).
502
- * @returns The raw {@link EscrowAccountData}, or `null` if not found.
503
- * @since v0.1.0
504
- */
505
- fetchEscrow(agentWallet: PublicKey, depositor?: PublicKey): Promise<EscrowAccountData | EscrowAccountV2Data | null>;
506
- /**
507
- * @name fetchNullable
508
- * @description Fetch an on-chain account by name and PDA. Returns `null` if not found.
509
- * @param name - Anchor account discriminator name.
510
- * @param pda - Account public key to fetch.
511
- * @returns The deserialized account data, or `null` if the account does not exist.
512
- * @private
513
- */
514
- private fetchNullable;
515
- /**
516
- * @name resolveEscrow
517
- * @description Try to find an escrow: V2 (nonce=0) first, then V1 fallback.
518
- * Returns the escrow data, PDA, and version indicator.
519
- * @private
520
- */
521
- private resolveEscrow;
522
- }
523
- //# sourceMappingURL=x402.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../../src/registries/x402.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAuB,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,qBAAqB,EAEtB,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM3D;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAC;IACnC,oCAAoC;IACpC,QAAQ,CAAC,cAAc,EAAE,OA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