@cosmosapp/pay_sdk 1.1.0 → 1.2.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.
@@ -145,6 +145,15 @@ declare const ProductKind: {
145
145
  readonly Link: "link";
146
146
  };
147
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];
148
157
  /** Body for `POST /v1/payment-intents/tx`. */
149
158
  interface CreateTxPaymentIntentOptions {
150
159
  /** Payer's Stellar account — the transaction source. A registered address-book name also works. */
@@ -484,6 +493,121 @@ interface HealthCheckData {
484
493
  status: string;
485
494
  } & Record<string, unknown>>;
486
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
+ }
487
611
 
488
612
  /**
489
613
  * Error thrown when the Cosmos Pay API responds with a non-2xx status.
@@ -623,4 +747,4 @@ interface ResolvableIntentInput {
623
747
  */
624
748
  declare function resolveIntentBody<T extends ResolvableIntentInput>(options: T, book?: AddressBook): Omit<T, 'asset'>;
625
749
 
626
- export { addresses as $, type AnalyticsSummaryData as A, type AnalyticsRecentRow as B, type CustomerData as C, type DeletedData as D, type AnalyticsSeriesPoint as E, type AnalyticsVolumeEntry as F, type ApiLogRow as G, type HealthCheckData as H, type AssetDefinition as I, type AssetRef as J, Assets as K, type ListPaymentIntentsOptions as L, CosmosPayAPIError as M, CosmosPayRequestError as N, type CustomerListData as O, type PaymentIntentData as P, type PaymentIntentListData as Q, type ResolvableIntentInput as R, type ResolvedAsset as S, TestnetAssets as T, type UpdateCustomerOptions as U, type ValidationOutcomeData as V, type WebhookLogsData as W, type WalletId as X, Wallets as Y, type WebhookDeliveryListData as Z, type WebhookLogRow as _, type AnalyticsBalancesData as a, assertAddress as a0, defineAsset as a1, isAddress as a2, isContractAddress as a3, isMuxedAddress as a4, isNativeAsset as a5, isStellarAddress as a6, resolveAddress as a7, resolveAsset as a8, resolveIntentBody as a9, 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, type WebhookDeliveryData as n, WebhookEventType as o, WebhookDeliveryStatus as p, type WebhookEndpointData as q, type WebhookEndpointWithSecretData as r, type UpdateWebhookEndpointOptions as s, type WebhookPingData as t, type ListWebhookDeliveriesOptions as u, type WebhookEvent as v, type CreateWebhookEndpointOptions as w, AddressBook as x, type AddressRef as y, type AnalyticsBalanceEntry as z };
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 };
@@ -145,6 +145,15 @@ declare const ProductKind: {
145
145
  readonly Link: "link";
146
146
  };
147
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];
148
157
  /** Body for `POST /v1/payment-intents/tx`. */
149
158
  interface CreateTxPaymentIntentOptions {
150
159
  /** Payer's Stellar account — the transaction source. A registered address-book name also works. */
@@ -484,6 +493,121 @@ interface HealthCheckData {
484
493
  status: string;
485
494
  } & Record<string, unknown>>;
486
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
+ }
487
611
 
488
612
  /**
489
613
  * Error thrown when the Cosmos Pay API responds with a non-2xx status.
@@ -623,4 +747,4 @@ interface ResolvableIntentInput {
623
747
  */
624
748
  declare function resolveIntentBody<T extends ResolvableIntentInput>(options: T, book?: AddressBook): Omit<T, 'asset'>;
625
749
 
626
- export { addresses as $, type AnalyticsSummaryData as A, type AnalyticsRecentRow as B, type CustomerData as C, type DeletedData as D, type AnalyticsSeriesPoint as E, type AnalyticsVolumeEntry as F, type ApiLogRow as G, type HealthCheckData as H, type AssetDefinition as I, type AssetRef as J, Assets as K, type ListPaymentIntentsOptions as L, CosmosPayAPIError as M, CosmosPayRequestError as N, type CustomerListData as O, type PaymentIntentData as P, type PaymentIntentListData as Q, type ResolvableIntentInput as R, type ResolvedAsset as S, TestnetAssets as T, type UpdateCustomerOptions as U, type ValidationOutcomeData as V, type WebhookLogsData as W, type WalletId as X, Wallets as Y, type WebhookDeliveryListData as Z, type WebhookLogRow as _, type AnalyticsBalancesData as a, assertAddress as a0, defineAsset as a1, isAddress as a2, isContractAddress as a3, isMuxedAddress as a4, isNativeAsset as a5, isStellarAddress as a6, resolveAddress as a7, resolveAsset as a8, resolveIntentBody as a9, 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, type WebhookDeliveryData as n, WebhookEventType as o, WebhookDeliveryStatus as p, type WebhookEndpointData as q, type WebhookEndpointWithSecretData as r, type UpdateWebhookEndpointOptions as s, type WebhookPingData as t, type ListWebhookDeliveriesOptions as u, type WebhookEvent as v, type CreateWebhookEndpointOptions as w, AddressBook as x, type AddressRef as y, type AnalyticsBalanceEntry as z };
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 };
@@ -829,7 +829,7 @@ var CosmosPayRequestError = class _CosmosPayRequestError extends Error {
829
829
  };
830
830
 
831
831
  // src/util/Constants.ts
832
- var version = "1.1.0";
832
+ var version = "1.2.1";
833
833
  var DEFAULT_BASE_URL = "https://api.cosmospay.lat/cosmos-api";
834
834
 
835
835
  // src/web/rest.ts