@rozoai/intent-common 0.0.32-beta.1 → 0.0.32-beta.2

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 (52) hide show
  1. package/README.md +134 -0
  2. package/dist/api/base.d.ts +1 -1
  3. package/dist/api/base.js +2 -1
  4. package/dist/api/base.js.map +1 -1
  5. package/dist/api/fee.d.ts +2 -1
  6. package/dist/api/fee.js +5 -1
  7. package/dist/api/fee.js.map +1 -1
  8. package/dist/api/new-payment.d.ts +319 -0
  9. package/dist/api/new-payment.js +140 -0
  10. package/dist/api/new-payment.js.map +1 -0
  11. package/dist/api/payment.d.ts +102 -4
  12. package/dist/api/payment.js +117 -10
  13. package/dist/api/payment.js.map +1 -1
  14. package/dist/bridge.d.ts +82 -45
  15. package/dist/bridge.js +142 -168
  16. package/dist/bridge.js.map +1 -1
  17. package/dist/chain.d.ts +6 -0
  18. package/dist/chain.js +38 -14
  19. package/dist/chain.js.map +1 -1
  20. package/dist/daimoPay.d.ts +9 -9
  21. package/dist/daimoPay.js +5 -0
  22. package/dist/daimoPay.js.map +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +2 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/token.d.ts +9 -0
  27. package/dist/token.js +111 -17
  28. package/dist/token.js.map +1 -1
  29. package/dist/validation.d.ts +9 -0
  30. package/dist/validation.js +47 -0
  31. package/dist/validation.js.map +1 -0
  32. package/package.json +4 -2
  33. package/src/api/base.ts +3 -1
  34. package/src/api/fee.ts +8 -2
  35. package/src/api/new-payment.ts +433 -0
  36. package/src/api/payment.ts +162 -8
  37. package/src/bridge.ts +176 -200
  38. package/src/chain.ts +40 -13
  39. package/src/daimoPay.ts +17 -9
  40. package/src/index.ts +2 -0
  41. package/src/token.ts +124 -18
  42. package/src/validation.ts +54 -0
  43. package/test/bridge.test.ts +393 -0
  44. package/dist/chainAddress.d.ts +0 -27
  45. package/dist/chainAddress.js +0 -87
  46. package/dist/chainAddress.js.map +0 -1
  47. package/dist/supportedChain.d.ts +0 -27
  48. package/dist/supportedChain.js +0 -87
  49. package/dist/supportedChain.js.map +0 -1
  50. package/dist/supportedChains.d.ts +0 -27
  51. package/dist/supportedChains.js +0 -87
  52. package/dist/supportedChains.js.map +0 -1
@@ -80,14 +80,112 @@ export interface PaymentResponseData {
80
80
  [key: string]: unknown;
81
81
  }
82
82
  /**
83
- * Creates a new payment
84
- * @param paymentData - Payment data to send
85
- * @returns Promise with payment response
83
+ * Simplified interface for creating a payment bridge
86
84
  */
87
- export declare const createRozoPayment: (paymentData: PaymentRequestData) => Promise<ApiResponse<PaymentResponseData>>;
85
+ export interface CreatePaymentBridgeParams {
86
+ /** App ID for authentication */
87
+ appId: string;
88
+ /** Destination chain ID (e.g., 8453 for Base, 900 for Solana, 10001 for Stellar) */
89
+ toChain: number;
90
+ /** Destination token address */
91
+ toToken: string;
92
+ /** Destination address - Can be EVM, Solana, or Stellar address */
93
+ toAddress: string;
94
+ /** Chain ID where user will pay from (e.g., 137 for Polygon, 8453 for Base) */
95
+ preferredChain: number;
96
+ /** Token address user will pay with */
97
+ preferredTokenAddress: string;
98
+ /** Amount in human-readable units (e.g., "1" for 1 USDC, "0.5" for half a USDC) */
99
+ toUnits?: string;
100
+ /** Additional metadata to include */
101
+ metadata?: Record<string, unknown>;
102
+ }
88
103
  /**
89
104
  * Gets payment details by ID
90
105
  * @param paymentId - Payment ID
91
106
  * @returns Promise with payment response
92
107
  */
93
108
  export declare const getRozoPayment: (paymentId: string) => Promise<ApiResponse<PaymentResponseData>>;
109
+ /**
110
+ * Creates a payment bridge configuration and initiates a Rozo payment
111
+ *
112
+ * This function combines the payment bridge configuration logic with payment creation,
113
+ * handling cross-chain payment routing and metadata merging. It provides a simplified
114
+ * API that doesn't require understanding internal types like WalletPaymentOption.
115
+ *
116
+ * @param params - Payment bridge creation parameters
117
+ * @returns Promise resolving to the payment response data
118
+ * @throws Error if payment creation fails or required parameters are missing
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * // Simple same-chain payment
123
+ * const payment = await createPaymentBridge({
124
+ * toChain: 8453, // Base
125
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
126
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
127
+ * preferredChainId: 8453, // User pays from Base
128
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
129
+ * toUnits: "1", // 1 USDC
130
+ * appId: "my-app-id",
131
+ * intent: "Pay",
132
+ * });
133
+ * ```
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * // Cross-chain payment: Polygon to Base
138
+ * const payment = await createPaymentBridge({
139
+ * toChain: 8453, // Base (destination)
140
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
141
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
142
+ * preferredChainId: 137, // Polygon (user pays from)
143
+ * preferredToken: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", // Polygon USDC
144
+ * toUnits: "1",
145
+ * appId: "my-app-id",
146
+ * });
147
+ * ```
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Payment to Solana address (payout → Solana)
152
+ * const payment = await createPaymentBridge({
153
+ * toChain: 900, // Solana
154
+ * toToken: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // Solana USDC
155
+ * toAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // Solana address
156
+ * preferredChainId: 8453, // User pays from Base
157
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
158
+ * toUnits: "1",
159
+ * appId: "my-app-id",
160
+ * });
161
+ * ```
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // Payment paid in from Stellar account
166
+ * const payment = await createPaymentBridge({
167
+ * toChain: 8453, // Payout on Base
168
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
169
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", // EVM address
170
+ * preferredChainId: 1500, // Pay in from Stellar
171
+ * preferredToken: "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN", // Stellar USDC (token format: code:issuer)
172
+ * toUnits: "10",
173
+ * appId: "my-app-id",
174
+ * });
175
+ * ```
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * // Payment paying out to Stellar address (payout → Stellar)
180
+ * const payment = await createPaymentBridge({
181
+ * toChain: 1500, // Stellar
182
+ * toToken: "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN", // Stellar USDC (token format: code:issuer)
183
+ * toAddress: "GA5ZSEPRY3STUGUUXZGHV5CDEQ2AJGEAAUUMSZK2QIPICFL2JVP4X6T4", // Stellar address
184
+ * preferredChainId: 8453, // User pays from Base
185
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
186
+ * toUnits: "1",
187
+ * appId: "my-app-id",
188
+ * });
189
+ * ```
190
+ */
191
+ export declare function createRozoPayment(params: CreatePaymentBridgeParams): Promise<PaymentResponseData>;
@@ -1,16 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRozoPayment = exports.createRozoPayment = void 0;
4
- const base_1 = require("./base");
5
- /**
6
- * Creates a new payment
7
- * @param paymentData - Payment data to send
8
- * @returns Promise with payment response
9
- */
10
- const createRozoPayment = (paymentData) => {
11
- return base_1.apiClient.post("/payment-api", paymentData);
12
- };
3
+ exports.getRozoPayment = void 0;
13
4
  exports.createRozoPayment = createRozoPayment;
5
+ const bridge_1 = require("../bridge");
6
+ const base_1 = require("./base");
14
7
  /**
15
8
  * Gets payment details by ID
16
9
  * @param paymentId - Payment ID
@@ -24,4 +17,118 @@ const getRozoPayment = (paymentId) => {
24
17
  return base_1.apiClient.get(endpoint);
25
18
  };
26
19
  exports.getRozoPayment = getRozoPayment;
20
+ /**
21
+ * Creates a payment bridge configuration and initiates a Rozo payment
22
+ *
23
+ * This function combines the payment bridge configuration logic with payment creation,
24
+ * handling cross-chain payment routing and metadata merging. It provides a simplified
25
+ * API that doesn't require understanding internal types like WalletPaymentOption.
26
+ *
27
+ * @param params - Payment bridge creation parameters
28
+ * @returns Promise resolving to the payment response data
29
+ * @throws Error if payment creation fails or required parameters are missing
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Simple same-chain payment
34
+ * const payment = await createPaymentBridge({
35
+ * toChain: 8453, // Base
36
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
37
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
38
+ * preferredChainId: 8453, // User pays from Base
39
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
40
+ * toUnits: "1", // 1 USDC
41
+ * appId: "my-app-id",
42
+ * intent: "Pay",
43
+ * });
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Cross-chain payment: Polygon to Base
49
+ * const payment = await createPaymentBridge({
50
+ * toChain: 8453, // Base (destination)
51
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
52
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
53
+ * preferredChainId: 137, // Polygon (user pays from)
54
+ * preferredToken: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", // Polygon USDC
55
+ * toUnits: "1",
56
+ * appId: "my-app-id",
57
+ * });
58
+ * ```
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Payment to Solana address (payout → Solana)
63
+ * const payment = await createPaymentBridge({
64
+ * toChain: 900, // Solana
65
+ * toToken: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // Solana USDC
66
+ * toAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // Solana address
67
+ * preferredChainId: 8453, // User pays from Base
68
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
69
+ * toUnits: "1",
70
+ * appId: "my-app-id",
71
+ * });
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // Payment paid in from Stellar account
77
+ * const payment = await createPaymentBridge({
78
+ * toChain: 8453, // Payout on Base
79
+ * toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
80
+ * toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", // EVM address
81
+ * preferredChainId: 1500, // Pay in from Stellar
82
+ * preferredToken: "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN", // Stellar USDC (token format: code:issuer)
83
+ * toUnits: "10",
84
+ * appId: "my-app-id",
85
+ * });
86
+ * ```
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * // Payment paying out to Stellar address (payout → Stellar)
91
+ * const payment = await createPaymentBridge({
92
+ * toChain: 1500, // Stellar
93
+ * toToken: "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN", // Stellar USDC (token format: code:issuer)
94
+ * toAddress: "GA5ZSEPRY3STUGUUXZGHV5CDEQ2AJGEAAUUMSZK2QIPICFL2JVP4X6T4", // Stellar address
95
+ * preferredChainId: 8453, // User pays from Base
96
+ * preferredToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
97
+ * toUnits: "1",
98
+ * appId: "my-app-id",
99
+ * });
100
+ * ```
101
+ */
102
+ async function createRozoPayment(params) {
103
+ const { toChain, toToken, toAddress, preferredChain, preferredTokenAddress, toUnits, appId, metadata, } = params;
104
+ // Create payment bridge configuration
105
+ const { preferred, destination, isIntentPayment } = (0, bridge_1.createPaymentBridgeConfig)({
106
+ toChain,
107
+ toToken,
108
+ toAddress,
109
+ toUnits: toUnits ?? "0",
110
+ // Preferred payment method (what user will pay with)
111
+ preferredChain,
112
+ preferredTokenAddress,
113
+ });
114
+ // Build payment request data
115
+ const paymentData = {
116
+ appId,
117
+ display: {
118
+ intent: "",
119
+ paymentValue: String(toUnits ?? ""),
120
+ currency: "USD",
121
+ },
122
+ destination,
123
+ ...preferred,
124
+ ...(metadata ?? {}),
125
+ ...(isIntentPayment ? { intents: true } : {}),
126
+ };
127
+ // Create payment via API
128
+ const response = await base_1.apiClient.post("/payment-api", paymentData);
129
+ if (!response?.data?.id) {
130
+ throw new Error(response?.error?.message ?? "Payment creation failed");
131
+ }
132
+ return response.data;
133
+ }
27
134
  //# sourceMappingURL=payment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/api/payment.ts"],"names":[],"mappings":";;;AAAA,iCAAgD;AAuFhD;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAC/B,WAA+B,EACY,EAAE;IAC7C,OAAO,gBAAS,CAAC,IAAI,CAAsB,cAAc,EAAE,WAAW,CAAC,CAAC;AAC1E,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAC5B,SAAiB,EAC0B,EAAE;IAC7C,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,WAAW;QAC1B,CAAC,CAAC,eAAe,SAAS,EAAE;QAC5B,CAAC,CAAC,cAAc,SAAS,EAAE,CAAC;IAC9B,OAAO,gBAAS,CAAC,GAAG,CAAsB,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB"}
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/api/payment.ts"],"names":[],"mappings":";;;AAsNA,8CAmDC;AAzQD,sCAAsD;AACtD,iCAAgD;AAoHhD;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAC5B,SAAiB,EAC0B,EAAE;IAC7C,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,WAAW;QAC1B,CAAC,CAAC,eAAe,SAAS,EAAE;QAC5B,CAAC,CAAC,cAAc,SAAS,EAAE,CAAC;IAC9B,OAAO,gBAAS,CAAC,GAAG,CAAsB,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAAiC;IAEjC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,QAAQ,GACT,GAAG,MAAM,CAAC;IACX,sCAAsC;IACtC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,IAAA,kCAAyB,EAC3E;QACE,OAAO;QACP,OAAO;QACP,SAAS;QACT,OAAO,EAAE,OAAO,IAAI,GAAG;QACvB,qDAAqD;QACrD,cAAc;QACd,qBAAqB;KACtB,CACF,CAAC;IAEF,6BAA6B;IAC7B,MAAM,WAAW,GAAuB;QACtC,KAAK;QACL,OAAO,EAAE;YACP,MAAM,EAAE,EAAE;YACV,YAAY,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;YACnC,QAAQ,EAAE,KAAK;SAChB;QACD,WAAW;QACX,GAAG,SAAS;QACZ,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;QACnB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;IAEF,yBAAyB;IACzB,MAAM,QAAQ,GAAG,MAAM,gBAAS,CAAC,IAAI,CACnC,cAAc,EACd,WAAW,CACZ,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,IAAI,yBAAyB,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
package/dist/bridge.d.ts CHANGED
@@ -1,19 +1,17 @@
1
1
  import { RozoPayHydratedOrderWithOrg } from ".";
2
2
  import type { PaymentResponseData } from "./api/payment";
3
3
  export interface PaymentBridgeConfig {
4
- toChain?: number;
5
- toToken?: string;
4
+ toChain: number;
5
+ toToken: string;
6
6
  toAddress: string;
7
- toStellarAddress?: string;
8
- toSolanaAddress?: string;
9
7
  toUnits: string;
10
- payInTokenAddress: string;
11
- log?: (msg: string) => void;
8
+ preferredChain: number;
9
+ preferredTokenAddress: string;
12
10
  }
13
11
  export interface PreferredPaymentConfig {
14
12
  preferredChain: string;
15
- preferredToken: "USDC" | "USDT" | "XLM";
16
- preferredTokenAddress?: string;
13
+ preferredToken: string;
14
+ preferredTokenAddress: string;
17
15
  }
18
16
  export interface DestinationConfig {
19
17
  destinationAddress?: string;
@@ -22,11 +20,16 @@ export interface DestinationConfig {
22
20
  tokenSymbol: string;
23
21
  tokenAddress: string;
24
22
  }
23
+ interface PaymentBridge {
24
+ preferred: PreferredPaymentConfig;
25
+ destination: DestinationConfig;
26
+ isIntentPayment: boolean;
27
+ }
25
28
  /**
26
29
  * Creates payment bridge configuration for cross-chain payment routing
27
30
  *
28
31
  * Determines the optimal payment routing based on the destination chain/token
29
- * and the wallet payment option selected by the user. This function handles
32
+ * and the preferred payment method selected by the user. This function handles
30
33
  * the complexity of multi-chain payments by:
31
34
  *
32
35
  * 1. **Preferred Payment Method**: Identifies which chain/token the user will pay from
@@ -35,66 +38,99 @@ export interface DestinationConfig {
35
38
  *
36
39
  * 2. **Destination Configuration**: Determines where funds will be received
37
40
  * - Supports Base, Solana, Stellar, and Worldchain as destination chains
38
- * - Handles special address formats for Solana and Stellar addresses
39
- * - Defaults to Base USDC when no special destination is specified
41
+ * - Automatically handles special address formats for Solana and Stellar addresses
42
+ * - Configures destination token based on chain type (e.g., Stellar/Solana USDC)
40
43
  *
41
- * 3. **Cross-Chain Bridging**: Configures the payment bridge parameters
42
- * - Maps user's selected wallet/token to the appropriate payment method
43
- * - Sets up destination chain and token configuration
44
- * - Handles token address formatting (e.g., Stellar's `USDC:issuerPK` format)
44
+ * 3. **Intent Payment Detection**: Determines if this is a cross-chain intent payment
45
+ * - Returns `isIntentPayment: true` when preferred chain/token differs from destination
46
+ * - Returns `isIntentPayment: false` for same-chain, same-token payments
45
47
  *
46
48
  * @param config - Payment bridge configuration parameters
47
- * @param config.toChain - Destination chain ID (defaults to Base: 8453)
48
- * @param config.toToken - Destination token address (defaults to Base USDC)
49
- * @param config.toAddress - Standard EVM destination address
50
- * @param config.toStellarAddress - Stellar-specific destination address (if paying to Stellar)
51
- * @param config.toSolanaAddress - Solana-specific destination address (if paying to Solana)
52
- * @param config.toUnits - Amount in token units (smallest denomination)
53
- * @param config.payInTokenAddress - Token address user selected to pay with
54
- * @param config.log - Optional logging function for debugging
55
- *
56
- * @returns Payment routing configuration
49
+ * @param config.toChain - Destination chain ID (e.g., 8453 for Base, 900 for Solana, 10001 for Stellar)
50
+ * @param config.toToken - Destination token address (must be a supported token on the destination chain)
51
+ * @param config.toAddress - Destination address (format validated based on chain type: EVM 0x..., Solana Base58, Stellar G...)
52
+ * @param config.toUnits - Amount in human-readable units (e.g., "1" for 1 USDC, "0.5" for half a USDC)
53
+ * @param config.preferredChain - Chain ID where the user will pay from (e.g., 137 for Polygon, 8453 for Base)
54
+ * @param config.preferredTokenAddress - Token address the user selected to pay with (must be a supported token on preferredChain)
55
+ *
56
+ * @returns Payment routing configuration object
57
57
  * @returns preferred - Source payment configuration (chain, token user will pay from)
58
+ * @returns preferred.preferredChain - Chain ID as string where payment originates
59
+ * @returns preferred.preferredToken - Token symbol (e.g., "USDC", "USDT")
60
+ * @returns preferred.preferredTokenAddress - Token contract address
58
61
  * @returns destination - Destination payment configuration (chain, token user will receive)
62
+ * @returns destination.destinationAddress - Address where funds will be received
63
+ * @returns destination.chainId - Destination chain ID as string
64
+ * @returns destination.amountUnits - Payment amount in token units
65
+ * @returns destination.tokenSymbol - Destination token symbol
66
+ * @returns destination.tokenAddress - Destination token contract address
67
+ * @returns isIntentPayment - Boolean indicating if this is a cross-chain intent payment
68
+ *
69
+ * @throws {Error} If the destination token is not supported for the destination chain
70
+ * @throws {Error} If the destination address format is invalid for the destination chain
71
+ * @throws {Error} If the preferred token is not supported for the preferred chain
72
+ * @throws {Error} If the destination chain or token is not supported
59
73
  *
60
74
  * @example
61
75
  * ```typescript
62
76
  * // User wants to pay with Polygon USDC to receive on Base
63
- * const { preferred, destination } = createPaymentBridgeConfig({
64
- * toChain: 8453, // Base
77
+ * import { baseUSDC, polygonUSDCe } from '@rozoai/intent-common';
78
+ * import { base, polygon } from '@rozoai/intent-common';
79
+ *
80
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
81
+ * toChain: base.chainId, // 8453
65
82
  * toToken: baseUSDC.token,
66
- * toAddress: '0x123...',
67
- * toUnits: '1000000', // 1 USDC
68
- * payInTokenAddress: polygonUSDC.token,
69
- * log: console.log
83
+ * toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
84
+ * toUnits: '1000000', // 1 USDC (6 decimals)
85
+ * preferredChain: polygon.chainId, // 137
86
+ * preferredToken: polygonUSDCe.token,
70
87
  * });
71
88
  *
72
- * // preferred = { preferredChain: '137', preferredToken: 'USDC', preferredTokenAddress: '0x2791...' }
73
- * // destination = { destinationAddress: '0x123...', chainId: '8453', amountUnits: '1000000', ... }
89
+ * // preferred = { preferredChain: '137', preferredToken: 'USDCe', preferredTokenAddress: '0x2791...' }
90
+ * // destination = { destinationAddress: '0x742d...', chainId: '8453', amountUnits: '1000000', tokenSymbol: 'USDC', tokenAddress: '0x8335...' }
91
+ * // isIntentPayment = true (different chains)
74
92
  * ```
75
93
  *
76
94
  * @example
77
95
  * ```typescript
78
- * // User wants to pay to a Stellar address
79
- * const { preferred, destination } = createPaymentBridgeConfig({
80
- * toStellarAddress: 'GDZS...',
81
- * toUnits: '1000000',
82
- * payInTokenAddress: baseUSDC.token,
96
+ * // User wants to pay to a Stellar address using Base USDC
97
+ * import { baseUSDC, rozoStellarUSDC } from '@rozoai/intent-common';
98
+ * import { base, rozoStellar } from '@rozoai/intent-common';
99
+ *
100
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
101
+ * toChain: rozoStellar.chainId, // 10001
102
+ * toToken: rozoStellarUSDC.token,
103
+ * toAddress: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
104
+ * toUnits: '10000000', // 1 USDC (7 decimals for Stellar)
105
+ * preferredChain: base.chainId, // 8453
106
+ * preferredToken: baseUSDC.token,
83
107
  * });
84
108
  *
85
- * // destination will be configured for Stellar chain with USDC:issuerPK format
109
+ * // preferred = { preferredChain: '8453', preferredToken: 'USDC', preferredTokenAddress: '0x8335...' }
110
+ * // destination = { destinationAddress: 'GA5Z...', chainId: '10001', amountUnits: '10000000', tokenSymbol: 'USDC', tokenAddress: 'USDC:GA5Z...' }
111
+ * // isIntentPayment = true (Base to Stellar)
86
112
  * ```
87
113
  *
88
- * @note Currently only supports Base USDC and Stellar USDC as destination chains.
89
- * Support for additional destination chains is planned.
114
+ * @example
115
+ * ```typescript
116
+ * // Same-chain payment (not an intent payment)
117
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
118
+ * toChain: base.chainId, // 8453
119
+ * toToken: baseUSDC.token,
120
+ * toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
121
+ * toUnits: '1000000',
122
+ * preferredChain: base.chainId, // 8453
123
+ * preferredToken: baseUSDC.token,
124
+ * });
125
+ *
126
+ * // isIntentPayment = false (same chain and token)
127
+ * ```
90
128
  *
91
129
  * @see PreferredPaymentConfig
92
130
  * @see DestinationConfig
131
+ * @see PaymentBridgeConfig
93
132
  */
94
- export declare function createPaymentBridgeConfig({ toChain, toToken, toAddress, toStellarAddress, toSolanaAddress, toUnits, payInTokenAddress, log, }: PaymentBridgeConfig): {
95
- preferred: PreferredPaymentConfig;
96
- destination: DestinationConfig;
97
- };
133
+ export declare function createPaymentBridgeConfig({ toChain, toToken, toAddress, toUnits, preferredChain, preferredTokenAddress, }: PaymentBridgeConfig): PaymentBridge;
98
134
  /**
99
135
  * Transforms a payment API response into a fully hydrated order object
100
136
  *
@@ -162,3 +198,4 @@ export declare function createPaymentBridgeConfig({ toChain, toToken, toAddress,
162
198
  * @see getKnownToken
163
199
  */
164
200
  export declare function formatResponseToHydratedOrder(order: PaymentResponseData): RozoPayHydratedOrderWithOrg;
201
+ export {};