@cosmosapp/pay_sdk 1.2.0 → 2.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +0 -75
  3. package/NOTICE +8 -0
  4. package/README.md +15 -18
  5. package/dist/chunk-AYVWYEOK.js +62 -0
  6. package/dist/chunk-AYVWYEOK.js.map +1 -0
  7. package/dist/{chunk-TZDZBVFS.js → chunk-TM4HAKWE.js} +5 -3
  8. package/dist/chunk-TM4HAKWE.js.map +1 -0
  9. package/dist/cosmosProvider-CFASjnd5.d.cts +100 -0
  10. package/dist/cosmosProvider-CFASjnd5.d.ts +100 -0
  11. package/dist/index.cjs +739 -3
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +618 -6
  14. package/dist/index.d.ts +618 -6
  15. package/dist/index.js +731 -5
  16. package/dist/index.js.map +1 -1
  17. package/dist/intent-input-BtUp3tFN.d.cts +1697 -0
  18. package/dist/intent-input-BtUp3tFN.d.ts +1697 -0
  19. package/dist/swk/index.cjs +170 -0
  20. package/dist/swk/index.cjs.map +1 -0
  21. package/dist/swk/index.d.cts +207 -0
  22. package/dist/swk/index.d.ts +207 -0
  23. package/dist/swk/index.js +106 -0
  24. package/dist/swk/index.js.map +1 -0
  25. package/dist/web/index.cjs +129 -2
  26. package/dist/web/index.cjs.map +1 -1
  27. package/dist/web/index.d.cts +49 -4
  28. package/dist/web/index.d.ts +49 -4
  29. package/dist/web/index.js +67 -4
  30. package/dist/web/index.js.map +1 -1
  31. package/llms/03-quickstart.md +4 -4
  32. package/llms/05-payment-intents.md +6 -2
  33. package/llms/08-products-customers.md +1 -1
  34. package/llms/13-types-reference.md +1 -1
  35. package/llms/14-recipes.md +14 -8
  36. package/llms/llms-full.txt +26 -16
  37. package/package.json +17 -6
  38. package/dist/chunk-TZDZBVFS.js.map +0 -1
  39. package/dist/intent-input-Ch8ogEg-.d.cts +0 -750
  40. package/dist/intent-input-Ch8ogEg-.d.ts +0 -750
@@ -1,750 +0,0 @@
1
- /**
2
- * A typed, extensible catalog of Stellar assets.
3
- *
4
- * Instead of hunting down an asset's issuer (or pasting the wrong one), use the
5
- * built-in catalog — `Assets.USDC`, `Assets.EURC`, `Assets.XLM` — which carries
6
- * the verified issuer for you. Need something else? `defineAsset(...)` makes a
7
- * typed asset you can reuse. And a plain code string still works everywhere.
8
- *
9
- * ⚠️ Issuers are network-specific. The {@link Assets} catalog targets **mainnet**;
10
- * {@link TestnetAssets} carries the testnet issuers. Bare code strings (e.g.
11
- * `'USDC'`) are treated as *code only* (no issuer) for backwards compatibility —
12
- * use the catalog object or `defineAsset` when you want the issuer filled in.
13
- */
14
- /** A fully-described Stellar asset. */
15
- interface AssetDefinition {
16
- /** Asset code, e.g. `USDC`. Use `XLM` (or omit the issuer) for native lumens. */
17
- code: string;
18
- /** Issuer account (`G…`). `null`/omitted means the native asset (XLM). */
19
- issuer?: string | null;
20
- /** Optional Soroban contract id (`C…`) for the SAC / token contract. */
21
- contract?: string;
22
- /** Human-readable name. */
23
- name?: string;
24
- /** Network the `issuer` is valid on. */
25
- network?: 'public' | 'testnet';
26
- }
27
- /** Anything accepted where an asset is expected: a code string or a definition. */
28
- type AssetRef = string | AssetDefinition;
29
- /** Normalized asset: a code plus a concrete issuer (or `null` for native). */
30
- interface ResolvedAsset {
31
- /** `XLM` for the native asset, otherwise the asset code. */
32
- code: string;
33
- /** Issuer `G…`, or `null` for the native asset. */
34
- issuer: string | null;
35
- /** Optional Soroban contract id. */
36
- contract?: string;
37
- }
38
- /**
39
- * Built-in **mainnet** assets with verified issuers. Extend with your own via
40
- * {@link defineAsset}. Issuers sourced from the official issuers (Circle for
41
- * USDC/EURC).
42
- */
43
- declare const Assets: {
44
- /** Native lumens. */
45
- readonly XLM: AssetDefinition;
46
- /** USD Coin by Circle (mainnet). */
47
- readonly USDC: {
48
- readonly code: "USDC";
49
- readonly issuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN";
50
- readonly name: "USD Coin";
51
- readonly network: "public";
52
- };
53
- /** Euro Coin by Circle (mainnet). */
54
- readonly EURC: {
55
- readonly code: "EURC";
56
- readonly issuer: "GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2";
57
- readonly name: "Euro Coin";
58
- readonly network: "public";
59
- };
60
- };
61
- /** Built-in **testnet** assets (Circle's Test SDF Network issuers). */
62
- declare const TestnetAssets: {
63
- readonly XLM: AssetDefinition;
64
- readonly USDC: {
65
- readonly code: "USDC";
66
- readonly issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5";
67
- readonly name: "USD Coin";
68
- readonly network: "testnet";
69
- };
70
- readonly EURC: {
71
- readonly code: "EURC";
72
- readonly issuer: "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO";
73
- readonly name: "Euro Coin";
74
- readonly network: "testnet";
75
- };
76
- };
77
- /** Whether a reference denotes the native asset (XLM). */
78
- declare function isNativeAsset(ref: AssetRef): boolean;
79
- /**
80
- * Create a reusable, typed custom asset. Validates the issuer/contract format so
81
- * a typo surfaces immediately rather than on-chain.
82
- *
83
- * @example
84
- * const AQUA = defineAsset({ code: 'AQUA', issuer: 'GBNZ...', name: 'Aquarius' });
85
- * await client.paymentIntents.createPay({ destination, amount: '5', asset: AQUA });
86
- */
87
- declare function defineAsset(def: AssetDefinition): AssetDefinition;
88
- /**
89
- * Normalize an {@link AssetRef} into `{ code, issuer, contract }`.
90
- *
91
- * - A bare string is treated as *code only* (`issuer: null`) — pass a catalog
92
- * object or `defineAsset(...)` result when you want the issuer included.
93
- * - The native asset normalizes to `{ code: 'XLM', issuer: null }`.
94
- */
95
- declare function resolveAsset(ref: AssetRef): ResolvedAsset;
96
-
97
- /**
98
- * Type definitions for the Cosmos Pay Payments API.
99
- *
100
- * These mirror the server's OpenAPI schema (Stellar SEP-7 payment intents,
101
- * webhooks, products, customers and analytics). Every type is exported so
102
- * TypeScript consumers get full intellisense; JavaScript consumers can ignore
103
- * them entirely.
104
- */
105
-
106
- /** Lifecycle state of a payment intent. */
107
- declare const PaymentIntentStatus: {
108
- readonly Pending: "PENDING";
109
- readonly Submitted: "SUBMITTED";
110
- readonly Succeeded: "SUCCEEDED";
111
- readonly Failed: "FAILED";
112
- readonly Cancelled: "CANCELLED";
113
- readonly Expired: "EXPIRED";
114
- };
115
- type PaymentIntentStatus = (typeof PaymentIntentStatus)[keyof typeof PaymentIntentStatus];
116
- /** SEP-7 operation a payment intent represents. */
117
- declare const PaymentIntentKind: {
118
- /** Source account is known → unsigned XDR + `web+stellar:tx` URI. */
119
- readonly Tx: "TX";
120
- /** No source → `web+stellar:pay` URI only (wallet picks the source). */
121
- readonly Pay: "PAY";
122
- };
123
- type PaymentIntentKind = (typeof PaymentIntentKind)[keyof typeof PaymentIntentKind];
124
- /** Domain events an integrator can subscribe a webhook to. */
125
- declare const WebhookEventType: {
126
- readonly PaymentIntentCreated: "PAYMENT_INTENT_CREATED";
127
- readonly PaymentIntentUpdated: "PAYMENT_INTENT_UPDATED";
128
- readonly PaymentIntentSucceeded: "PAYMENT_INTENT_SUCCEEDED";
129
- readonly PaymentIntentFailed: "PAYMENT_INTENT_FAILED";
130
- readonly PaymentIntentCancelled: "PAYMENT_INTENT_CANCELLED";
131
- readonly PaymentIntentDeleted: "PAYMENT_INTENT_DELETED";
132
- };
133
- type WebhookEventType = (typeof WebhookEventType)[keyof typeof WebhookEventType];
134
- /** Delivery state of a single webhook attempt. */
135
- declare const WebhookDeliveryStatus: {
136
- readonly Pending: "PENDING";
137
- readonly Succeeded: "SUCCEEDED";
138
- readonly Failed: "FAILED";
139
- };
140
- type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus];
141
- /** Product billing kind. */
142
- declare const ProductKind: {
143
- readonly Recurring: "recurring";
144
- readonly OneTime: "one_time";
145
- readonly Link: "link";
146
- };
147
- type ProductKind = (typeof ProductKind)[keyof typeof ProductKind];
148
- /** Lifecycle state of a swap. */
149
- declare const SwapStatus: {
150
- readonly Pending: "PENDING";
151
- readonly Submitted: "SUBMITTED";
152
- readonly Succeeded: "SUCCEEDED";
153
- readonly Failed: "FAILED";
154
- readonly Expired: "EXPIRED";
155
- };
156
- type SwapStatus = (typeof SwapStatus)[keyof typeof SwapStatus];
157
- /** Body for `POST /v1/payment-intents/tx`. */
158
- interface CreateTxPaymentIntentOptions {
159
- /** Payer's Stellar account — the transaction source. A registered address-book name also works. */
160
- source: string;
161
- /** Payee's Stellar account. A registered address-book name also works. */
162
- destination: string;
163
- /** Amount as a decimal string (max 7 decimals). */
164
- amount: string;
165
- /**
166
- * Typed asset (e.g. `Assets.USDC` or `defineAsset(...)`) — fills `assetCode`
167
- * and `assetIssuer` for you. Takes a back seat to explicit code/issuer below.
168
- */
169
- asset?: AssetRef;
170
- /** Asset code. Omit (or `XLM`/`native`) for native lumens. */
171
- assetCode?: string;
172
- /** Issuer account for a non-native asset. */
173
- assetIssuer?: string;
174
- /** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
175
- memo?: string;
176
- /** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
177
- msg?: string;
178
- /** SEP-7 `callback` where the wallet POSTs the signed XDR, e.g. `url:https://...`. */
179
- callback?: string;
180
- }
181
- /** Body for `POST /v1/payment-intents/pay`. */
182
- interface CreatePayPaymentIntentOptions {
183
- /** Payee's Stellar account. A registered address-book name also works. */
184
- destination: string;
185
- /** Amount the destination should receive. Omit to let the user enter it (e.g. donations). */
186
- amount?: string;
187
- /**
188
- * Typed asset (e.g. `Assets.USDC` or `defineAsset(...)`) — fills `assetCode`
189
- * and `assetIssuer` for you. Takes a back seat to explicit code/issuer below.
190
- */
191
- asset?: AssetRef;
192
- /** Asset code the destination receives. Omit for native lumens (XLM). */
193
- assetCode?: string;
194
- /** Issuer account for a non-native asset. */
195
- assetIssuer?: string;
196
- /** MEMO_ID (numeric uint64) for idempotency + on-chain identification. Auto-generated when omitted. */
197
- memo?: string;
198
- /** SEP-7 `msg`: shown to the user in their wallet (≤ 300 chars). */
199
- msg?: string;
200
- /** SEP-7 `callback`, e.g. `url:https://...`. */
201
- callback?: string;
202
- }
203
- /** Body for `PATCH /v1/payment-intents/:id`. */
204
- interface UpdatePaymentIntentOptions {
205
- status?: PaymentIntentStatus;
206
- /** Stellar transaction hash once the signed tx is submitted. */
207
- txHash?: string;
208
- /** Merchant reference. */
209
- reference?: string;
210
- }
211
- /** Query for `GET /v1/payment-intents`. */
212
- interface ListPaymentIntentsOptions {
213
- status?: PaymentIntentStatus;
214
- /** Page size (max 100, default 20). */
215
- take?: number;
216
- /** Offset (default 0). */
217
- skip?: number;
218
- }
219
- /** Raw payment intent payload returned by the API. */
220
- interface PaymentIntentData {
221
- id: string;
222
- kind: PaymentIntentKind;
223
- status: PaymentIntentStatus;
224
- network: string;
225
- source: string | null;
226
- destination: string;
227
- amount: string | null;
228
- asset: string;
229
- assetIssuer: string | null;
230
- memo: string;
231
- msg: string | null;
232
- callback: string | null;
233
- xdr: string | null;
234
- uri: string;
235
- qr: string;
236
- txHash: string | null;
237
- reference: string | null;
238
- createdAt: string;
239
- updatedAt: string;
240
- }
241
- /** Raw paginated list of payment intents. */
242
- interface PaymentIntentListData {
243
- data: PaymentIntentData[];
244
- total: number;
245
- take: number;
246
- skip: number;
247
- }
248
- /** Body for `POST /v1/payment-intents/:id/validate`. */
249
- interface ValidatePaymentIntentOptions {
250
- /** Hash of the submitted Stellar transaction to validate against this intent. */
251
- txHash: string;
252
- }
253
- /** Raw outcome of a validation attempt. */
254
- interface ValidationOutcomeData {
255
- valid: boolean;
256
- status: PaymentIntentStatus;
257
- reason?: string | null;
258
- paymentIntent?: PaymentIntentData;
259
- }
260
- /** Raw `{ id, deleted }` response. */
261
- interface DeletedData {
262
- id: string;
263
- deleted: boolean;
264
- }
265
- /** Body for `POST /v1/webhooks`. */
266
- interface CreateWebhookEndpointOptions {
267
- /** HTTPS URL that will receive POSTed event notifications. */
268
- url: string;
269
- description?: string;
270
- /** Event types to subscribe to. Omit/empty to receive all events. */
271
- eventTypes?: WebhookEventType[];
272
- }
273
- /** Body for `PATCH /v1/webhooks/:id`. */
274
- interface UpdateWebhookEndpointOptions {
275
- url?: string;
276
- description?: string;
277
- /** Pause/resume deliveries to this endpoint. */
278
- enabled?: boolean;
279
- eventTypes?: WebhookEventType[];
280
- }
281
- /** Raw webhook endpoint payload. */
282
- interface WebhookEndpointData {
283
- id: string;
284
- url: string;
285
- description: string | null;
286
- enabled: boolean;
287
- eventTypes: WebhookEventType[];
288
- createdAt: string;
289
- updatedAt: string;
290
- }
291
- /** Raw webhook endpoint payload including the one-time signing secret. */
292
- interface WebhookEndpointWithSecretData extends WebhookEndpointData {
293
- /** HMAC signing secret — shown once. Store it securely. */
294
- secret: string;
295
- }
296
- /** Raw result of a webhook ping. */
297
- interface WebhookPingData {
298
- ok: boolean;
299
- responseStatus: number | null;
300
- error: string | null;
301
- }
302
- /** Raw webhook delivery (audit) record. */
303
- interface WebhookDeliveryData {
304
- id: string;
305
- endpointId: string;
306
- eventType: WebhookEventType;
307
- eventId: string;
308
- payload: Record<string, unknown>;
309
- status: WebhookDeliveryStatus;
310
- attempts: number;
311
- responseStatus: number | null;
312
- error: string | null;
313
- lastAttemptAt: string | null;
314
- createdAt: string;
315
- updatedAt: string;
316
- }
317
- /** Raw paginated list of webhook deliveries. */
318
- interface WebhookDeliveryListData {
319
- data: WebhookDeliveryData[];
320
- total: number;
321
- take: number;
322
- skip: number;
323
- }
324
- /** Query for `GET /v1/webhooks/:id/deliveries`. */
325
- interface ListWebhookDeliveriesOptions {
326
- status?: WebhookDeliveryStatus;
327
- take?: number;
328
- skip?: number;
329
- }
330
- /** Shape of the JSON body POSTed to an integrator's webhook URL. */
331
- interface WebhookEvent<T = PaymentIntentData> {
332
- /** Stable event id (use for idempotency). */
333
- id: string;
334
- type: WebhookEventType;
335
- createdAt: string;
336
- data: T;
337
- }
338
- /** Body for `POST /v1/products`. */
339
- interface CreateProductOptions {
340
- name: string;
341
- description?: string;
342
- /** Decimal price (≤ 7 decimals). Omit for a customer-set amount. */
343
- amount?: string;
344
- /** Asset code the price is in. Omit for native lumens (XLM). */
345
- assetCode?: string;
346
- kind?: ProductKind;
347
- active?: boolean;
348
- reference?: string;
349
- }
350
- /** Body for `PATCH /v1/products/:id`. */
351
- type UpdateProductOptions = Partial<CreateProductOptions>;
352
- /** Raw product payload. */
353
- interface ProductData {
354
- id: string;
355
- name: string;
356
- description: string | null;
357
- amount: string | null;
358
- asset: string;
359
- kind: ProductKind;
360
- active: boolean;
361
- reference: string | null;
362
- createdAt: string;
363
- updatedAt: string;
364
- }
365
- /** Body for `POST /v1/customers`. */
366
- interface CreateCustomerOptions {
367
- name: string;
368
- alias?: string;
369
- note?: string;
370
- email?: string;
371
- /** Optional Stellar account to associate the customer with. */
372
- account?: string;
373
- reference?: string;
374
- }
375
- /** Body for `PATCH /v1/customers/:id`. */
376
- type UpdateCustomerOptions = Partial<CreateCustomerOptions>;
377
- /** Raw customer payload. */
378
- interface CustomerData {
379
- id: string;
380
- consumerId: string;
381
- name: string;
382
- alias: string | null;
383
- note: string | null;
384
- email: string | null;
385
- account: string | null;
386
- reference: string | null;
387
- createdAt: string;
388
- updatedAt: string;
389
- /** Derived on-chain stats (present in list responses). */
390
- payments?: number;
391
- succeeded?: number;
392
- total?: string;
393
- }
394
- /** Raw `{ data, total }` list of customers. */
395
- interface CustomerListData {
396
- data: CustomerData[];
397
- total: number;
398
- }
399
- interface AnalyticsVolumeEntry {
400
- asset: string;
401
- amount: string;
402
- count: number;
403
- }
404
- interface AnalyticsSeriesPoint {
405
- date: string;
406
- count: number;
407
- volume: string;
408
- }
409
- interface AnalyticsRecentRow {
410
- id: string;
411
- kind: string;
412
- status: PaymentIntentStatus;
413
- amount: string | null;
414
- asset: string;
415
- destination: string;
416
- createdAt: string;
417
- }
418
- /** Raw overview metrics returned by `GET /v1/summary`. */
419
- interface AnalyticsSummaryData {
420
- totals: {
421
- all: number;
422
- succeeded: number;
423
- pending: number;
424
- submitted: number;
425
- failed: number;
426
- cancelled: number;
427
- expired: number;
428
- successRate: number;
429
- };
430
- volume: AnalyticsVolumeEntry[];
431
- webhooks: {
432
- endpoints: number;
433
- deliveries: number;
434
- failedDeliveries: number;
435
- };
436
- customers: number;
437
- series: AnalyticsSeriesPoint[];
438
- recent: AnalyticsRecentRow[];
439
- }
440
- interface AnalyticsBalanceEntry {
441
- asset: string;
442
- amount: string;
443
- pending: string;
444
- count: number;
445
- }
446
- /** Raw balances returned by `GET /v1/balances`. */
447
- interface AnalyticsBalancesData {
448
- data: AnalyticsBalanceEntry[];
449
- total: number;
450
- }
451
- interface ApiLogRow {
452
- id: string;
453
- method: string;
454
- path: string;
455
- statusCode: number;
456
- durationMs: number;
457
- ip: string | null;
458
- userAgent: string | null;
459
- status: 'ok' | 'pending' | 'fail';
460
- at: string;
461
- }
462
- /** Raw API request log returned by `GET /v1/logs`. */
463
- interface ApiLogsData {
464
- data: ApiLogRow[];
465
- total: number;
466
- }
467
- interface WebhookLogRow {
468
- id: string;
469
- endpointId: string;
470
- url: string | null;
471
- eventType: WebhookEventType;
472
- eventId: string;
473
- attempts: number;
474
- responseStatus: number | null;
475
- error: string | null;
476
- status: 'ok' | 'pending' | 'fail';
477
- at: string;
478
- }
479
- /** Raw webhook delivery log returned by `GET /v1/logs/webhooks`. */
480
- interface WebhookLogsData {
481
- data: WebhookLogRow[];
482
- total: number;
483
- }
484
- interface HealthCheckData {
485
- status: string;
486
- info?: Record<string, {
487
- status: string;
488
- } & Record<string, unknown>> | null;
489
- error?: Record<string, {
490
- status: string;
491
- } & Record<string, unknown>> | null;
492
- details?: Record<string, {
493
- status: string;
494
- } & Record<string, unknown>>;
495
- }
496
- /** Body for `POST /v1/swaps/quote` (pricing only; no fee parameter — the fee is enforced server-side per organization). */
497
- interface QuoteSwapOptions {
498
- /** Amount to send, as a decimal string (max 7 decimals). */
499
- amount: string;
500
- /** Source asset code. Omit (or `XLM`/`native`) for native lumens. */
501
- sourceAssetCode?: string;
502
- /** Issuer account for a non-native source asset. */
503
- sourceAssetIssuer?: string;
504
- /** Destination asset code the swap should deliver. */
505
- destAssetCode: string;
506
- /** Issuer account for a non-native destination asset. */
507
- destAssetIssuer?: string;
508
- /** Allowed slippage in basis points. */
509
- slippageBps?: number;
510
- }
511
- /** Body for `POST /v1/swaps`. */
512
- interface CreateSwapOptions extends QuoteSwapOptions {
513
- /** Source account performing the swap. A registered address-book name also works. */
514
- source: string;
515
- /** Destination account that receives the swapped asset. Defaults to the source. */
516
- destination?: string;
517
- /** MEMO_ID (numeric uint64) for idempotency + on-chain identification. */
518
- memo?: string;
519
- }
520
- /** Body for `POST /v1/swaps/:id/submit`. */
521
- interface SubmitSwapOptions {
522
- /** Signed transaction envelope (base64 XDR) to relay to the network. */
523
- signedXdr: string;
524
- }
525
- /** Query for `GET /v1/swaps`. */
526
- interface ListSwapsOptions {
527
- status?: SwapStatus;
528
- /** Page size (max 100, default 20). */
529
- take?: number;
530
- /** Offset (default 0). */
531
- skip?: number;
532
- }
533
- /** Raw swap payload returned by the API. */
534
- interface SwapData {
535
- id: string;
536
- status: SwapStatus;
537
- network: string;
538
- source: string;
539
- destination: string;
540
- sendAsset: string;
541
- sendAssetIssuer: string | null;
542
- sendAmount: string;
543
- feeAmount: string;
544
- feeBps: number;
545
- swapAmount: string;
546
- destAsset: string;
547
- destAssetIssuer: string | null;
548
- destEstimated: string;
549
- destMin: string;
550
- slippageBps: number;
551
- path: {
552
- code: string;
553
- issuer: string | null;
554
- }[];
555
- memo: string | null;
556
- xdr: string;
557
- uri: string;
558
- txHash: string;
559
- qr: string;
560
- createdAt: string;
561
- updatedAt: string;
562
- }
563
- /** Raw paginated list of swaps. */
564
- interface SwapListData {
565
- data: SwapData[];
566
- total: number;
567
- take: number;
568
- skip: number;
569
- }
570
- /** Raw pricing quote returned by `POST /v1/swaps/quote`. */
571
- interface SwapQuoteData {
572
- network: string;
573
- source: {
574
- asset: string;
575
- issuer: string | null;
576
- amount: string;
577
- };
578
- fee: {
579
- asset: string;
580
- issuer: string | null;
581
- amount: string;
582
- bps: number;
583
- wallet: string | null;
584
- };
585
- swap: {
586
- asset: string;
587
- issuer: string | null;
588
- amount: string;
589
- };
590
- destination: {
591
- asset: string;
592
- issuer: string | null;
593
- estimated: string;
594
- minimum: string;
595
- slippageBps: number;
596
- };
597
- path: {
598
- code: string;
599
- issuer: string | null;
600
- }[];
601
- }
602
- /** Raw outcome of relaying a signed swap transaction. */
603
- interface SwapSubmitOutcomeData {
604
- submitted: boolean;
605
- status: SwapStatus;
606
- txHash?: string;
607
- reason?: string;
608
- resultCodes?: string[];
609
- swap: SwapData;
610
- }
611
-
612
- /**
613
- * Error thrown when the Cosmos Pay API responds with a non-2xx status.
614
- *
615
- * Carries the HTTP status, the parsed response body and the request context so
616
- * callers can branch on `error.status` (e.g. 404 → not found, 403 → gateway).
617
- */
618
- declare class CosmosPayAPIError extends Error {
619
- /** HTTP status code returned by the API. */
620
- readonly status: number;
621
- /** HTTP method of the failed request. */
622
- readonly method: string;
623
- /** Absolute URL of the failed request. */
624
- readonly url: string;
625
- /** Parsed response body (object when JSON, string otherwise, or null). */
626
- readonly body: unknown;
627
- /** Machine-readable error code extracted from the body when present. */
628
- readonly code: string | undefined;
629
- constructor(options: {
630
- status: number;
631
- method: string;
632
- url: string;
633
- body: unknown;
634
- });
635
- private static resolveMessage;
636
- private static resolveCode;
637
- }
638
- /**
639
- * Error thrown when a request never reaches the API: network failure, abort or
640
- * timeout. Distinct from {@link CosmosPayAPIError}, which always has a status.
641
- */
642
- declare class CosmosPayRequestError extends Error {
643
- readonly method: string;
644
- readonly url: string;
645
- readonly cause: unknown;
646
- constructor(options: {
647
- method: string;
648
- url: string;
649
- cause: unknown;
650
- });
651
- }
652
-
653
- /**
654
- * Typed identifiers for the wallets the web client knows about, so you can write
655
- * `Wallets.FREIGHTER` instead of remembering the `'freighter'` magic string —
656
- * while any custom adapter id still works.
657
- */
658
- /** Built-in wallet ids (matches each adapter's `id`). */
659
- declare const Wallets: {
660
- readonly FREIGHTER: "freighter";
661
- readonly XBULL: "xbull";
662
- readonly RABET: "rabet";
663
- readonly LOBSTR: "lobstr";
664
- readonly ALBEDO: "albedo";
665
- };
666
- /** A known wallet id, or any custom adapter id (autocomplete for the built-ins). */
667
- type WalletId = (typeof Wallets)[keyof typeof Wallets] | (string & {});
668
-
669
- /**
670
- * Stellar address helpers + a tiny named-address book.
671
- *
672
- * So integrators don't have to sprinkle raw `G...` strings everywhere (and risk
673
- * typos), they can name the accounts they care about once and reference them by
674
- * name. A plain address string always keeps working — `resolveAddress` only
675
- * substitutes registered names and otherwise passes the value straight through.
676
- */
677
- /** Whether a value looks like a Stellar account address (`G…`). */
678
- declare function isStellarAddress(value: unknown): value is string;
679
- /** Whether a value looks like a muxed account address (`M…`). */
680
- declare function isMuxedAddress(value: unknown): value is string;
681
- /** Whether a value looks like a Soroban contract id (`C…`). */
682
- declare function isContractAddress(value: unknown): value is string;
683
- /** Whether a value is any kind of Stellar address (account, muxed or contract). */
684
- declare function isAddress(value: unknown): value is string;
685
- /** Throw unless `value` is a valid Stellar account/muxed/contract address. */
686
- declare function assertAddress(value: unknown, label?: string): string;
687
- /**
688
- * A registry of named Stellar addresses. Register the accounts you use a lot —
689
- * your merchant payout account, a treasury, frequent counterparties — and refer
690
- * to them by name anywhere an address is accepted.
691
- *
692
- * @example
693
- * addresses.define('merchant', 'GC...');
694
- * await client.paymentIntents.createPay({ destination: 'merchant', amount: '10' });
695
- */
696
- declare class AddressBook {
697
- private readonly entries;
698
- constructor(initial?: Record<string, string>);
699
- /** Register (or overwrite) a named address. The address is validated. */
700
- define(name: string, address: string): this;
701
- /** Whether a name is registered. */
702
- has(name: string): boolean;
703
- /** Look up a registered address by name. */
704
- get(name: string): string | undefined;
705
- /** Remove a named address. */
706
- delete(name: string): boolean;
707
- /** All registered names. */
708
- names(): string[];
709
- /**
710
- * Resolve a reference to a concrete address: a registered name is substituted,
711
- * any other string is returned unchanged (so raw `G…`, muxed `M…`, federation
712
- * `name*domain`, etc. all keep working).
713
- */
714
- resolve(ref: string): string;
715
- }
716
- /** Process-wide default address book. Use `addresses.define(...)` to populate it. */
717
- declare const addresses: AddressBook;
718
- /** Anything accepted where an address is expected: a raw address or a name in a book. */
719
- type AddressRef = string;
720
- /**
721
- * Resolve an {@link AddressRef} using the given book (the shared {@link addresses}
722
- * by default). Lenient: unknown strings pass through unchanged.
723
- */
724
- declare function resolveAddress(ref: AddressRef, book?: AddressBook): string;
725
-
726
- /**
727
- * Shared resolution of "create intent" input, used by both the server SDK and
728
- * the web client so the convenience layers behave identically: a typed
729
- * {@link AssetRef} (e.g. `Assets.USDC`) is expanded into `assetCode`/`assetIssuer`,
730
- * and named addresses are substituted via an {@link AddressBook}.
731
- */
732
-
733
- /** Fields the resolver understands (everything else passes through untouched). */
734
- interface ResolvableIntentInput {
735
- destination?: string;
736
- source?: string;
737
- /** Typed asset (`Assets.USDC`, `defineAsset(...)`) — fills code + issuer. */
738
- asset?: AssetRef;
739
- assetCode?: string;
740
- assetIssuer?: string;
741
- }
742
- /**
743
- * Expand `asset` into `assetCode`/`assetIssuer` and resolve named
744
- * `destination`/`source` addresses. Existing `assetCode`/`assetIssuer` win over a
745
- * provided `asset`; native assets leave the code unset (the API treats an omitted
746
- * asset as native XLM). Returns a new object — the input is not mutated.
747
- */
748
- declare function resolveIntentBody<T extends ResolvableIntentInput>(options: T, book?: AddressBook): Omit<T, 'asset'>;
749
-
750
- export { type ResolvableIntentInput as $, type AnalyticsSummaryData as A, type WebhookEvent as B, type CustomerData as C, type DeletedData as D, type CreateWebhookEndpointOptions as E, AddressBook as F, type AddressRef as G, type HealthCheckData as H, type AnalyticsBalanceEntry as I, type AnalyticsRecentRow as J, type AnalyticsSeriesPoint as K, type ListPaymentIntentsOptions as L, type AnalyticsVolumeEntry as M, type ApiLogRow as N, type AssetDefinition as O, type PaymentIntentData as P, type QuoteSwapOptions as Q, type AssetRef as R, type SwapData as S, Assets as T, type UpdateCustomerOptions as U, type ValidationOutcomeData as V, type WebhookLogsData as W, CosmosPayAPIError as X, CosmosPayRequestError as Y, type CustomerListData as Z, type PaymentIntentListData as _, type AnalyticsBalancesData as a, type ResolvedAsset as a0, type SwapListData as a1, type SwapSubmitOutcomeData as a2, TestnetAssets as a3, type WalletId as a4, Wallets as a5, type WebhookDeliveryListData as a6, type WebhookLogRow as a7, addresses as a8, assertAddress as a9, defineAsset as aa, isAddress as ab, isContractAddress as ac, isMuxedAddress as ad, isNativeAsset as ae, isStellarAddress as af, resolveAddress as ag, resolveAsset as ah, resolveIntentBody as ai, type ApiLogsData as b, type CreateCustomerOptions as c, PaymentIntentKind as d, PaymentIntentStatus as e, type UpdatePaymentIntentOptions as f, type CreateTxPaymentIntentOptions as g, type CreatePayPaymentIntentOptions as h, type ValidatePaymentIntentOptions as i, type ProductData as j, ProductKind as k, type UpdateProductOptions as l, type CreateProductOptions as m, SwapStatus as n, type SubmitSwapOptions as o, type SwapQuoteData as p, type CreateSwapOptions as q, type ListSwapsOptions as r, type WebhookDeliveryData as s, WebhookEventType as t, WebhookDeliveryStatus as u, type WebhookEndpointData as v, type WebhookEndpointWithSecretData as w, type UpdateWebhookEndpointOptions as x, type WebhookPingData as y, type ListWebhookDeliveriesOptions as z };