@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
package/src/bridge.ts CHANGED
@@ -1,42 +1,35 @@
1
1
  import { parseUnits } from "viem";
2
2
  import {
3
- base,
4
3
  baseUSDC,
5
- bscUSDT,
6
- ethereum,
7
- ethereumUSDC,
4
+ getChainById,
8
5
  getKnownToken,
9
- polygon,
10
- polygonUSDC,
6
+ isChainSupported,
7
+ isTokenSupported,
11
8
  RozoPayHydratedOrderWithOrg,
12
9
  RozoPayIntentStatus,
13
10
  RozoPayOrderMode,
14
11
  RozoPayOrderStatusDest,
15
12
  RozoPayOrderStatusSource,
16
13
  RozoPayUserMetadata,
17
- rozoSolana,
18
14
  rozoSolanaUSDC,
19
- rozoStellar,
20
15
  rozoStellarUSDC,
21
- worldchainUSDC,
16
+ validateAddressForChain,
22
17
  } from ".";
23
18
  import type { PaymentResponseData } from "./api/payment";
24
19
 
25
20
  export interface PaymentBridgeConfig {
26
- toChain?: number;
27
- toToken?: string;
21
+ toChain: number;
22
+ toToken: string;
28
23
  toAddress: string;
29
- toStellarAddress?: string;
30
- toSolanaAddress?: string;
31
24
  toUnits: string;
32
- payInTokenAddress: string;
33
- log?: (msg: string) => void;
25
+ preferredChain: number;
26
+ preferredTokenAddress: string;
34
27
  }
35
28
 
36
29
  export interface PreferredPaymentConfig {
37
30
  preferredChain: string;
38
- preferredToken: "USDC" | "USDT" | "XLM";
39
- preferredTokenAddress?: string;
31
+ preferredToken: string;
32
+ preferredTokenAddress: string;
40
33
  }
41
34
 
42
35
  export interface DestinationConfig {
@@ -47,11 +40,17 @@ export interface DestinationConfig {
47
40
  tokenAddress: string;
48
41
  }
49
42
 
43
+ interface PaymentBridge {
44
+ preferred: PreferredPaymentConfig;
45
+ destination: DestinationConfig;
46
+ isIntentPayment: boolean;
47
+ }
48
+
50
49
  /**
51
50
  * Creates payment bridge configuration for cross-chain payment routing
52
51
  *
53
52
  * Determines the optimal payment routing based on the destination chain/token
54
- * and the wallet payment option selected by the user. This function handles
53
+ * and the preferred payment method selected by the user. This function handles
55
54
  * the complexity of multi-chain payments by:
56
55
  *
57
56
  * 1. **Preferred Payment Method**: Identifies which chain/token the user will pay from
@@ -60,198 +59,178 @@ export interface DestinationConfig {
60
59
  *
61
60
  * 2. **Destination Configuration**: Determines where funds will be received
62
61
  * - Supports Base, Solana, Stellar, and Worldchain as destination chains
63
- * - Handles special address formats for Solana and Stellar addresses
64
- * - Defaults to Base USDC when no special destination is specified
62
+ * - Automatically handles special address formats for Solana and Stellar addresses
63
+ * - Configures destination token based on chain type (e.g., Stellar/Solana USDC)
65
64
  *
66
- * 3. **Cross-Chain Bridging**: Configures the payment bridge parameters
67
- * - Maps user's selected wallet/token to the appropriate payment method
68
- * - Sets up destination chain and token configuration
69
- * - Handles token address formatting (e.g., Stellar's `USDC:issuerPK` format)
65
+ * 3. **Intent Payment Detection**: Determines if this is a cross-chain intent payment
66
+ * - Returns `isIntentPayment: true` when preferred chain/token differs from destination
67
+ * - Returns `isIntentPayment: false` for same-chain, same-token payments
70
68
  *
71
69
  * @param config - Payment bridge configuration parameters
72
- * @param config.toChain - Destination chain ID (defaults to Base: 8453)
73
- * @param config.toToken - Destination token address (defaults to Base USDC)
74
- * @param config.toAddress - Standard EVM destination address
75
- * @param config.toStellarAddress - Stellar-specific destination address (if paying to Stellar)
76
- * @param config.toSolanaAddress - Solana-specific destination address (if paying to Solana)
77
- * @param config.toUnits - Amount in token units (smallest denomination)
78
- * @param config.payInTokenAddress - Token address user selected to pay with
79
- * @param config.log - Optional logging function for debugging
70
+ * @param config.toChain - Destination chain ID (e.g., 8453 for Base, 900 for Solana, 10001 for Stellar)
71
+ * @param config.toToken - Destination token address (must be a supported token on the destination chain)
72
+ * @param config.toAddress - Destination address (format validated based on chain type: EVM 0x..., Solana Base58, Stellar G...)
73
+ * @param config.toUnits - Amount in human-readable units (e.g., "1" for 1 USDC, "0.5" for half a USDC)
74
+ * @param config.preferredChain - Chain ID where the user will pay from (e.g., 137 for Polygon, 8453 for Base)
75
+ * @param config.preferredTokenAddress - Token address the user selected to pay with (must be a supported token on preferredChain)
80
76
  *
81
- * @returns Payment routing configuration
77
+ * @returns Payment routing configuration object
82
78
  * @returns preferred - Source payment configuration (chain, token user will pay from)
79
+ * @returns preferred.preferredChain - Chain ID as string where payment originates
80
+ * @returns preferred.preferredToken - Token symbol (e.g., "USDC", "USDT")
81
+ * @returns preferred.preferredTokenAddress - Token contract address
83
82
  * @returns destination - Destination payment configuration (chain, token user will receive)
83
+ * @returns destination.destinationAddress - Address where funds will be received
84
+ * @returns destination.chainId - Destination chain ID as string
85
+ * @returns destination.amountUnits - Payment amount in token units
86
+ * @returns destination.tokenSymbol - Destination token symbol
87
+ * @returns destination.tokenAddress - Destination token contract address
88
+ * @returns isIntentPayment - Boolean indicating if this is a cross-chain intent payment
89
+ *
90
+ * @throws {Error} If the destination token is not supported for the destination chain
91
+ * @throws {Error} If the destination address format is invalid for the destination chain
92
+ * @throws {Error} If the preferred token is not supported for the preferred chain
93
+ * @throws {Error} If the destination chain or token is not supported
84
94
  *
85
95
  * @example
86
96
  * ```typescript
87
97
  * // User wants to pay with Polygon USDC to receive on Base
88
- * const { preferred, destination } = createPaymentBridgeConfig({
89
- * toChain: 8453, // Base
98
+ * import { baseUSDC, polygonUSDCe } from '@rozoai/intent-common';
99
+ * import { base, polygon } from '@rozoai/intent-common';
100
+ *
101
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
102
+ * toChain: base.chainId, // 8453
90
103
  * toToken: baseUSDC.token,
91
- * toAddress: '0x123...',
92
- * toUnits: '1000000', // 1 USDC
93
- * payInTokenAddress: polygonUSDC.token,
94
- * log: console.log
104
+ * toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
105
+ * toUnits: '1000000', // 1 USDC (6 decimals)
106
+ * preferredChain: polygon.chainId, // 137
107
+ * preferredToken: polygonUSDCe.token,
95
108
  * });
96
109
  *
97
- * // preferred = { preferredChain: '137', preferredToken: 'USDC', preferredTokenAddress: '0x2791...' }
98
- * // destination = { destinationAddress: '0x123...', chainId: '8453', amountUnits: '1000000', ... }
110
+ * // preferred = { preferredChain: '137', preferredToken: 'USDCe', preferredTokenAddress: '0x2791...' }
111
+ * // destination = { destinationAddress: '0x742d...', chainId: '8453', amountUnits: '1000000', tokenSymbol: 'USDC', tokenAddress: '0x8335...' }
112
+ * // isIntentPayment = true (different chains)
99
113
  * ```
100
114
  *
101
115
  * @example
102
116
  * ```typescript
103
- * // User wants to pay to a Stellar address
104
- * const { preferred, destination } = createPaymentBridgeConfig({
105
- * toStellarAddress: 'GDZS...',
106
- * toUnits: '1000000',
107
- * payInTokenAddress: baseUSDC.token,
117
+ * // User wants to pay to a Stellar address using Base USDC
118
+ * import { baseUSDC, rozoStellarUSDC } from '@rozoai/intent-common';
119
+ * import { base, rozoStellar } from '@rozoai/intent-common';
120
+ *
121
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
122
+ * toChain: rozoStellar.chainId, // 10001
123
+ * toToken: rozoStellarUSDC.token,
124
+ * toAddress: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
125
+ * toUnits: '10000000', // 1 USDC (7 decimals for Stellar)
126
+ * preferredChain: base.chainId, // 8453
127
+ * preferredToken: baseUSDC.token,
108
128
  * });
109
129
  *
110
- * // destination will be configured for Stellar chain with USDC:issuerPK format
130
+ * // preferred = { preferredChain: '8453', preferredToken: 'USDC', preferredTokenAddress: '0x8335...' }
131
+ * // destination = { destinationAddress: 'GA5Z...', chainId: '10001', amountUnits: '10000000', tokenSymbol: 'USDC', tokenAddress: 'USDC:GA5Z...' }
132
+ * // isIntentPayment = true (Base to Stellar)
111
133
  * ```
112
134
  *
113
- * @note Currently only supports Base USDC and Stellar USDC as destination chains.
114
- * Support for additional destination chains is planned.
135
+ * @example
136
+ * ```typescript
137
+ * // Same-chain payment (not an intent payment)
138
+ * const { preferred, destination, isIntentPayment } = createPaymentBridgeConfig({
139
+ * toChain: base.chainId, // 8453
140
+ * toToken: baseUSDC.token,
141
+ * toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
142
+ * toUnits: '1000000',
143
+ * preferredChain: base.chainId, // 8453
144
+ * preferredToken: baseUSDC.token,
145
+ * });
146
+ *
147
+ * // isIntentPayment = false (same chain and token)
148
+ * ```
115
149
  *
116
150
  * @see PreferredPaymentConfig
117
151
  * @see DestinationConfig
152
+ * @see PaymentBridgeConfig
118
153
  */
119
154
  export function createPaymentBridgeConfig({
120
- toChain = baseUSDC.chainId,
121
- toToken = baseUSDC.token,
155
+ toChain,
156
+ toToken,
122
157
  toAddress,
123
- toStellarAddress,
124
- toSolanaAddress,
125
158
  toUnits,
126
- payInTokenAddress,
127
- log,
128
- }: PaymentBridgeConfig): {
129
- preferred: PreferredPaymentConfig;
130
- destination: DestinationConfig;
131
- } {
132
- // Default configuration for Base USDC payments
159
+ preferredChain,
160
+ preferredTokenAddress,
161
+ }: PaymentBridgeConfig): PaymentBridge {
162
+ const chain = getChainById(toChain);
163
+ const token = getKnownToken(toChain, toToken);
164
+
165
+ if (!token) {
166
+ throw new Error(
167
+ `Unsupported token ${toToken} for chain ${chain.name} (${toChain})`
168
+ );
169
+ }
170
+
171
+ const addressValid = validateAddressForChain(toChain, toAddress);
172
+ if (!addressValid) {
173
+ throw new Error(
174
+ `Invalid address ${toAddress} for chain ${chain.name} (${toChain})`
175
+ );
176
+ }
177
+
178
+ const tokenConfig = getKnownToken(preferredChain, preferredTokenAddress);
179
+ if (!tokenConfig) {
180
+ throw new Error(
181
+ `Unknown token ${preferredTokenAddress} for chain ${chain.name} (${preferredChain})`
182
+ );
183
+ }
184
+
133
185
  let preferred: PreferredPaymentConfig = {
134
- preferredChain: String(toChain),
135
- preferredToken: "USDC",
186
+ preferredChain: String(preferredChain),
187
+ preferredToken: tokenConfig.symbol,
188
+ preferredTokenAddress: preferredTokenAddress,
136
189
  };
137
190
 
138
191
  let destination: DestinationConfig = {
139
192
  destinationAddress: toAddress,
140
193
  chainId: String(toChain),
141
194
  amountUnits: toUnits,
142
- tokenSymbol: "USDC",
195
+ tokenSymbol: token.symbol,
143
196
  tokenAddress: toToken,
144
197
  };
145
198
 
146
- /**
147
- * IMPORTANT: Because we only support PAY OUT USDC EVM & NON-EVM
148
- * So, We force toChain and toToken to Base USDC as default PayParams
149
- *
150
- * @TODO: Adjust this when we support another PAY OUT chain
151
- */
152
- const supportedChains = [
153
- base.chainId,
154
- polygon.chainId,
155
- ethereum.chainId,
156
- rozoSolana.chainId,
157
- rozoStellar.chainId,
158
- ];
159
- const supportedTokens = [
160
- baseUSDC.token,
161
- polygonUSDC.token,
162
- ethereumUSDC.token,
163
- rozoSolanaUSDC.token,
164
- rozoStellarUSDC.token,
165
- ];
166
-
167
- if (supportedChains.includes(toChain) && supportedTokens.includes(toToken)) {
168
- // Determine preferred payment method based on wallet selection
169
- if (payInTokenAddress) {
170
- // Pay In USDC Polygon
171
- if (payInTokenAddress === polygonUSDC.token) {
172
- log?.(`[Payment Bridge] Pay In USDC Polygon`);
173
- preferred = {
174
- preferredChain: String(polygonUSDC.chainId),
175
- preferredToken: "USDC",
176
- preferredTokenAddress: polygonUSDC.token,
177
- };
178
- }
179
- // Pay In USDC Ethereum
180
- else if (payInTokenAddress === ethereumUSDC.token) {
181
- log?.(`[Payment Bridge] Pay In USDC Ethereum`);
182
- preferred = {
183
- preferredChain: String(ethereumUSDC.chainId),
184
- preferredToken: "USDC",
185
- preferredTokenAddress: ethereumUSDC.token,
186
- };
187
- }
188
- // Pay In USDC Solana
189
- else if (payInTokenAddress === rozoSolanaUSDC.token) {
190
- log?.(`[Payment Bridge] Pay In USDC Solana`);
191
- preferred = {
192
- preferredChain: String(rozoSolanaUSDC.chainId),
193
- preferredToken: "USDC",
194
- preferredTokenAddress: rozoSolanaUSDC.token,
195
- };
196
- }
197
- // Pay In USDC Stellar
198
- else if (
199
- payInTokenAddress === rozoStellarUSDC.token ||
200
- payInTokenAddress === `USDC:${rozoStellarUSDC.token}`
201
- ) {
202
- log?.(`[Payment Bridge] Pay In USDC Stellar`);
203
- preferred = {
204
- preferredChain: String(rozoStellarUSDC.chainId),
205
- preferredToken: "USDC",
206
- preferredTokenAddress: `USDC:${rozoStellarUSDC.token}`,
207
- };
208
- }
209
- // Pay In USDC Worldchain
210
- else if (payInTokenAddress === worldchainUSDC.token) {
211
- log?.(`[Payment Bridge] Pay In USDC Worldchain`);
212
- preferred = {
213
- preferredChain: String(worldchainUSDC.chainId),
214
- preferredToken: "USDC",
215
- preferredTokenAddress: worldchainUSDC.token,
216
- };
217
- }
218
- // Pay In USDT BSC
219
- else if (payInTokenAddress === bscUSDT.token) {
220
- log?.(`[Payment Bridge] Pay In USDT BSC`);
221
- preferred = {
222
- preferredChain: String(bscUSDT.chainId),
223
- preferredToken: "USDT",
224
- preferredTokenAddress: bscUSDT.token,
225
- };
226
- }
227
- }
199
+ if (isChainSupported(toChain) && isTokenSupported(toChain, toToken)) {
200
+ preferred = {
201
+ preferredChain: String(tokenConfig.chainId),
202
+ preferredToken: tokenConfig.symbol,
203
+ preferredTokenAddress: tokenConfig.token,
204
+ };
228
205
 
229
206
  // Determine destination based on special address types
230
- if (toStellarAddress) {
231
- log?.(`[Payment Bridge] Pay Out USDC Stellar`);
207
+ if (isChainSupported(toChain, "stellar")) {
232
208
  destination = {
233
- destinationAddress: toStellarAddress,
234
- chainId: String(rozoStellar.chainId),
235
- amountUnits: toUnits,
236
- tokenSymbol: "USDC",
237
- tokenAddress: `USDC:${rozoStellarUSDC.token}`,
209
+ ...destination,
210
+ tokenSymbol: rozoStellarUSDC.symbol,
211
+ chainId: String(rozoStellarUSDC.chainId),
212
+ tokenAddress: rozoStellarUSDC.token,
238
213
  };
239
- } else if (toSolanaAddress) {
240
- log?.(`[Payment Bridge] Pay Out USDC Solana`);
214
+ } else if (isChainSupported(toChain, "solana")) {
241
215
  destination = {
242
- destinationAddress: toSolanaAddress,
216
+ ...destination,
217
+ tokenSymbol: rozoSolanaUSDC.symbol,
243
218
  chainId: String(rozoSolanaUSDC.chainId),
244
- amountUnits: toUnits,
245
- tokenSymbol: "USDC",
246
219
  tokenAddress: rozoSolanaUSDC.token,
247
220
  };
248
- } else {
249
- log?.(`[Payment Bridge] Pay Out USDC EVM`);
250
- // Keep default Base configuration
251
221
  }
222
+ } else {
223
+ throw new Error(
224
+ `Unsupported chain ${chain.name} (${toChain}) or token ${token.symbol} (${toToken})`
225
+ );
252
226
  }
253
227
 
254
- return { preferred, destination };
228
+ // If the preferred chain and token are not the same as the toChain and toToken, then it is an intent payment
229
+ const isIntentPayment =
230
+ preferred.preferredChain !== String(toChain) &&
231
+ preferred.preferredTokenAddress !== toToken;
232
+
233
+ return { preferred, destination, isIntentPayment };
255
234
  }
256
235
 
257
236
  /**
@@ -327,9 +306,9 @@ export function formatResponseToHydratedOrder(
327
306
 
328
307
  const requiredChain = order.metadata.preferredChain || baseUSDC.chainId;
329
308
 
330
- const chain = getKnownToken(
309
+ const token = getKnownToken(
331
310
  Number(requiredChain),
332
- Number(requiredChain) === rozoStellar.chainId
311
+ Number(requiredChain) === rozoStellarUSDC.chainId
333
312
  ? rozoStellarUSDC.token
334
313
  : order.metadata.preferredTokenAddress
335
314
  );
@@ -338,51 +317,48 @@ export function formatResponseToHydratedOrder(
338
317
  id: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
339
318
  mode: RozoPayOrderMode.HYDRATED,
340
319
  intentAddr: destAddress,
341
- handoffAddr: destAddress,
342
- escrowContractAddress: destAddress,
343
- bridgerContractAddress: destAddress,
344
320
  // @TODO: use correct destination token
345
- bridgeTokenOutOptions: [
346
- {
347
- token: {
348
- chainId: baseUSDC.chainId,
349
- token: baseUSDC.token,
350
- symbol: baseUSDC.symbol,
351
- usd: 1,
352
- priceFromUsd: 1,
353
- decimals: baseUSDC.decimals,
354
- displayDecimals: 2,
355
- logoSourceURI: baseUSDC.logoSourceURI,
356
- logoURI: baseUSDC.logoURI,
357
- maxAcceptUsd: 100000,
358
- maxSendUsd: 0,
359
- },
360
- amount: parseUnits(
361
- order.destination.amountUnits,
362
- baseUSDC.decimals
363
- ).toString() as `${bigint}`,
364
- usd: Number(order.destination.amountUnits),
365
- },
366
- ],
367
- selectedBridgeTokenOutAddr: null,
368
- selectedBridgeTokenOutAmount: null,
321
+ // bridgeTokenOutOptions: [
322
+ // {
323
+ // token: {
324
+ // chainId: baseUSDC.chainId,
325
+ // token: baseUSDC.token,
326
+ // symbol: baseUSDC.symbol,
327
+ // usd: 1,
328
+ // priceFromUsd: 1,
329
+ // decimals: baseUSDC.decimals,
330
+ // displayDecimals: 2,
331
+ // logoSourceURI: baseUSDC.logoSourceURI,
332
+ // logoURI: baseUSDC.logoURI,
333
+ // maxAcceptUsd: 100000,
334
+ // maxSendUsd: 0,
335
+ // },
336
+ // amount: parseUnits(
337
+ // order.destination.amountUnits,
338
+ // baseUSDC.decimals
339
+ // ).toString() as `${bigint}`,
340
+ // usd: Number(order.destination.amountUnits),
341
+ // },
342
+ // ],
343
+ // selectedBridgeTokenOutAddr: null,
344
+ // selectedBridgeTokenOutAmount: null,
369
345
  destFinalCallTokenAmount: {
370
346
  token: {
371
- chainId: chain ? chain.chainId : baseUSDC.chainId,
372
- token: chain ? chain.token : baseUSDC.token,
373
- symbol: chain ? chain.symbol : baseUSDC.symbol,
347
+ chainId: token ? token.chainId : baseUSDC.chainId,
348
+ token: token ? token.token : baseUSDC.token,
349
+ symbol: token ? token.symbol : baseUSDC.symbol,
374
350
  usd: 1,
375
351
  priceFromUsd: 1,
376
- decimals: chain ? chain.decimals : baseUSDC.decimals,
352
+ decimals: token ? token.decimals : baseUSDC.decimals,
377
353
  displayDecimals: 2,
378
- logoSourceURI: chain ? chain.logoSourceURI : baseUSDC.logoSourceURI,
379
- logoURI: chain ? chain.logoURI : baseUSDC.logoURI,
354
+ logoSourceURI: token ? token.logoSourceURI : baseUSDC.logoSourceURI,
355
+ logoURI: token ? token.logoURI : baseUSDC.logoURI,
380
356
  maxAcceptUsd: 100000,
381
357
  maxSendUsd: 0,
382
358
  },
383
359
  amount: parseUnits(
384
360
  order.destination.amountUnits,
385
- chain ? chain.decimals : baseUSDC.decimals
361
+ token ? token.decimals : baseUSDC.decimals
386
362
  ).toString() as `${bigint}`,
387
363
  usd: Number(order.destination.amountUnits),
388
364
  },
@@ -394,10 +370,10 @@ export function formatResponseToHydratedOrder(
394
370
  },
395
371
  refundAddr: (order.source?.sourceAddress as `0x${string}`) || null,
396
372
  nonce: order.nonce as unknown as bigint,
397
- sourceTokenAmount: null,
398
373
  sourceFulfillerAddr: null,
374
+ sourceTokenAmount: null,
399
375
  sourceInitiateTxHash: null,
400
- sourceStartTxHash: null,
376
+ // sourceStartTxHash: null,
401
377
  sourceStatus: RozoPayOrderStatusSource.WAITING_PAYMENT,
402
378
  destStatus: RozoPayOrderStatusDest.PENDING,
403
379
  intentStatus: RozoPayIntentStatus.UNPAID,
@@ -417,7 +393,7 @@ export function formatResponseToHydratedOrder(
417
393
  expirationTs: BigInt(Math.floor(Date.now() / 1000 + 5 * 60).toString()),
418
394
  org: {
419
395
  orgId: order.orgId as string,
420
- name: "Pay Rozo",
396
+ name: "",
421
397
  },
422
398
  };
423
399
  }
package/src/chain.ts CHANGED
@@ -107,21 +107,44 @@ export const rozoStellar: Chain = {
107
107
  cctpDomain: null,
108
108
  };
109
109
 
110
+ export const gnosis: Chain = {
111
+ type: "evm",
112
+ chainId: 100,
113
+ name: "Gnosis",
114
+ cctpDomain: null,
115
+ };
116
+
117
+ export const avalanche: Chain = {
118
+ type: "evm",
119
+ chainId: 43114,
120
+ name: "Avalanche",
121
+ cctpDomain: null,
122
+ };
123
+
124
+ /**
125
+ * Supported chains for Near Intents cross-chain swaps
126
+ * Based on USDC/USDT support documentation
127
+ */
110
128
  export const supportedChains: Chain[] = [
111
- arbitrum,
112
- base,
113
- bsc,
114
- celo,
115
- ethereum,
116
- linea,
117
- mantle,
118
- optimism,
119
- polygon,
120
- solana,
121
- stellar,
129
+ // Supported for Near Intents (USDC/USDT)
130
+ arbitrum, // USDC & USDT
131
+ avalanche, // USDC & USDT
132
+ base, // USDC only (no USDT)
133
+ bsc, // USDC & USDT
134
+ ethereum, // USDC & USDT
135
+ gnosis, // USDC & USDT
136
+ optimism, // USDC & USDT
137
+ polygon, // USDC & USDT
122
138
  worldchain,
123
- rozoSolana,
124
- rozoStellar,
139
+ rozoSolana, // USDC & USDT (chainId: 900)
140
+ rozoStellar, // USDC only (chainId: 1500, no USDT)
141
+
142
+ // Not supported for Near Intents - kept for other features
143
+ // celo, // Not in Near Intents docs
144
+ // linea, // Not in Near Intents docs
145
+ // mantle, // Not in Near Intents docs
146
+ // solana, // Use rozoSolana (900) instead of solana (501)
147
+ // stellar, // Use rozoStellar (1500) instead of stellar (10001)
125
148
  ];
126
149
 
127
150
  // https://developers.circle.com/stablecoins/supported-domains
@@ -186,6 +209,10 @@ export function getChainExplorerByChainId(chainId: number): string | undefined {
186
209
  return "https://optimistic.etherscan.io";
187
210
  case polygon.chainId:
188
211
  return "https://polygonscan.com";
212
+ case gnosis.chainId:
213
+ return "https://gnosisscan.io";
214
+ case avalanche.chainId:
215
+ return "https://snowtrace.io";
189
216
  case solana.chainId:
190
217
  case rozoSolana.chainId:
191
218
  return "https://solscan.io";
package/src/daimoPay.ts CHANGED
@@ -190,16 +190,16 @@ export type RozoPayDehydratedOrder = {
190
190
  export type RozoPayHydratedOrder = {
191
191
  mode: RozoPayOrderMode.HYDRATED;
192
192
  id: bigint;
193
- intentAddr: Address;
193
+ intentAddr: string;
194
194
  /** Nullable because old intents don't record escrow address. */
195
- escrowContractAddress: Address | null;
195
+ // escrowContractAddress: Address | null;
196
196
  /** Nullable because old intents don't record bridger address. */
197
- bridgerContractAddress: Address | null;
197
+ // bridgerContractAddress: Address | null;
198
198
  /** @deprecated included for backcompat with old versions. Remove soon. */
199
- handoffAddr: Address;
200
- bridgeTokenOutOptions: RozoPayTokenAmount[];
201
- selectedBridgeTokenOutAddr: Address | null;
202
- selectedBridgeTokenOutAmount: bigint | null;
199
+ // handoffAddr: Address;
200
+ // bridgeTokenOutOptions: RozoPayTokenAmount[];
201
+ // selectedBridgeTokenOutAddr: Address | null;
202
+ // selectedBridgeTokenOutAmount: bigint | null;
203
203
  destFinalCallTokenAmount: RozoPayTokenAmount;
204
204
  destFinalCall: OnChainCall;
205
205
  usdValue: number;
@@ -208,7 +208,7 @@ export type RozoPayHydratedOrder = {
208
208
  sourceFulfillerAddr: Address | SolanaPublicKey | StellarPublicKey | null;
209
209
  sourceTokenAmount: RozoPayTokenAmount | null;
210
210
  sourceInitiateTxHash: Hex | null;
211
- sourceStartTxHash: Hex | null;
211
+ // sourceStartTxHash: Hex | null;
212
212
  sourceStatus: RozoPayOrderStatusSource;
213
213
  destStatus: RozoPayOrderStatusDest;
214
214
  destFastFinishTxHash: Hex | null;
@@ -429,6 +429,12 @@ export enum DepositAddressPaymentOptions {
429
429
  STELLAR = "Stellar",
430
430
  WORLD = "Worldchain",
431
431
 
432
+ SOLANA_USDT = "USDT on Solana",
433
+ SOLANA_USDC = "USDC on Solana",
434
+ BASE_USDC = "USDC on Base",
435
+ ETHEREUM_USDT = "USDT on Ethereum",
436
+ ETHEREUM_USDC = "USDC on Ethereum",
437
+
432
438
  /** @deprecated */
433
439
  BITCOIN = "Bitcoin",
434
440
  /** @deprecated */
@@ -449,6 +455,8 @@ export type DepositAddressPaymentOptionMetadata = {
449
455
  id: DepositAddressPaymentOptions;
450
456
  logoURI: string;
451
457
  minimumUsd: number;
458
+ chainId: number;
459
+ token: Token;
452
460
  };
453
461
 
454
462
  export type DepositAddressPaymentOptionData = {
@@ -482,7 +490,7 @@ export interface RozoPayTokenAmount {
482
490
  }
483
491
 
484
492
  export type OnChainCall = {
485
- to: Address;
493
+ to: Address | SolanaPublicKey | StellarPublicKey;
486
494
  data: Hex;
487
495
  value: bigint;
488
496
  };
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./api/fee";
2
+ export * from "./api/new-payment";
2
3
  export * from "./api/payment";
3
4
  export * from "./assert";
4
5
  export * from "./bridge";
@@ -10,3 +11,4 @@ export * from "./primitiveTypes";
10
11
  export * from "./retryBackoff";
11
12
  export * from "./token";
12
13
  export * from "./try";
14
+ export * from "./validation";