0xtrails 0.5.0 → 0.6.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 (189) hide show
  1. package/dist/analytics.d.ts +8 -3
  2. package/dist/analytics.d.ts.map +1 -1
  3. package/dist/{ccip-DhEkQ6QC.js → ccip-Dw5AN7oU.js} +1 -1
  4. package/dist/cctp.d.ts +0 -149
  5. package/dist/cctp.d.ts.map +1 -1
  6. package/dist/chains.d.ts +28 -3
  7. package/dist/chains.d.ts.map +1 -1
  8. package/dist/config.d.ts +11 -0
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/constants.d.ts +1 -1
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/contractUtils.d.ts.map +1 -1
  13. package/dist/estimate.d.ts.map +1 -1
  14. package/dist/fees.d.ts.map +1 -1
  15. package/dist/gasless.d.ts +12 -0
  16. package/dist/gasless.d.ts.map +1 -1
  17. package/dist/{index-MhD2DA7_.js → index-BtVUTbEZ.js} +30984 -38945
  18. package/dist/index.d.ts +7 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +108 -107
  21. package/dist/indexerClient.d.ts +2 -2
  22. package/dist/intents.d.ts +0 -17
  23. package/dist/intents.d.ts.map +1 -1
  24. package/dist/mutations.d.ts.map +1 -1
  25. package/dist/paymasterSend.d.ts.map +1 -1
  26. package/dist/prepareSend.d.ts +1 -1
  27. package/dist/prepareSend.d.ts.map +1 -1
  28. package/dist/sendUserOp.d.ts +0 -18
  29. package/dist/sendUserOp.d.ts.map +1 -1
  30. package/dist/tokenBalances.d.ts.map +1 -1
  31. package/dist/tokens.d.ts +10 -8
  32. package/dist/tokens.d.ts.map +1 -1
  33. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +4 -5
  34. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  35. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +4 -5
  36. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  37. package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -2
  38. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  39. package/dist/transactionIntent/execution/transactionState.d.ts +2 -2
  40. package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
  41. package/dist/transactionIntent/handlers/crossChain.d.ts +4 -4
  42. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  43. package/dist/transactionIntent/handlers/index.d.ts +0 -1
  44. package/dist/transactionIntent/handlers/index.d.ts.map +1 -1
  45. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +4 -34
  46. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  47. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  48. package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -1
  49. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
  50. package/dist/transactionIntent/types.d.ts +6 -19
  51. package/dist/transactionIntent/types.d.ts.map +1 -1
  52. package/dist/transactionIntent/utils/index.d.ts +0 -1
  53. package/dist/transactionIntent/utils/index.d.ts.map +1 -1
  54. package/dist/transactions.d.ts +2 -20
  55. package/dist/transactions.d.ts.map +1 -1
  56. package/dist/utils.d.ts +8 -2
  57. package/dist/utils.d.ts.map +1 -1
  58. package/dist/walletUtils.d.ts +21 -0
  59. package/dist/walletUtils.d.ts.map +1 -0
  60. package/dist/wallets.d.ts +33 -240
  61. package/dist/wallets.d.ts.map +1 -1
  62. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  63. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  64. package/dist/widget/components/FeeOption.d.ts +8 -13
  65. package/dist/widget/components/FeeOption.d.ts.map +1 -1
  66. package/dist/widget/components/FeeOptions.d.ts +11 -5
  67. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  68. package/dist/widget/components/NativeGasOption.d.ts.map +1 -1
  69. package/dist/widget/components/Pay.d.ts.map +1 -1
  70. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  71. package/dist/widget/components/QRCodeDeposit.d.ts +5 -0
  72. package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
  73. package/dist/widget/components/QRCodeWalletSelect.d.ts +13 -0
  74. package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -0
  75. package/dist/widget/components/QrCode.d.ts.map +1 -1
  76. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  77. package/dist/widget/components/Receipt.d.ts.map +1 -1
  78. package/dist/widget/components/ScreenHeader.d.ts +1 -1
  79. package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
  80. package/dist/widget/components/Toast.d.ts.map +1 -1
  81. package/dist/widget/components/TokenImage.d.ts.map +1 -1
  82. package/dist/widget/css/compiled.css +1 -1
  83. package/dist/widget/hooks/useCheckout.d.ts +15 -1
  84. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  85. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  86. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  87. package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
  88. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  89. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  90. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +7 -0
  91. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +1 -0
  92. package/dist/widget/hooks/useIsSequenceWallet.d.ts +6 -0
  93. package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +1 -0
  94. package/dist/widget/hooks/useQuote.d.ts +5 -8
  95. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  96. package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
  97. package/dist/widget/hooks/useSelectedFeeOption.d.ts +30 -0
  98. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -0
  99. package/dist/widget/hooks/useSendForm.d.ts +6 -15
  100. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  101. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  102. package/dist/widget/index.js +1 -1
  103. package/dist/widget/providers/TrailsProvider.d.ts +23 -12
  104. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  105. package/dist/widget/widget.d.ts +11 -0
  106. package/dist/widget/widget.d.ts.map +1 -1
  107. package/package.json +8 -8
  108. package/src/analytics.ts +53 -21
  109. package/src/cctp.ts +0 -1016
  110. package/src/chains.ts +93 -39
  111. package/src/config.ts +24 -6
  112. package/src/constants.ts +1 -4
  113. package/src/contractUtils.ts +6 -6
  114. package/src/estimate.ts +3 -6
  115. package/src/fees.ts +5 -10
  116. package/src/gasless.ts +45 -0
  117. package/src/index.ts +7 -6
  118. package/src/indexerClient.ts +2 -2
  119. package/src/intents.ts +52 -206
  120. package/src/mutations.ts +3 -2
  121. package/src/paymasterSend.ts +2 -5
  122. package/src/prepareSend.ts +9 -12
  123. package/src/sendUserOp.ts +3 -64
  124. package/src/tokenBalances.ts +2 -1
  125. package/src/tokens.ts +62 -133
  126. package/src/trailsClient.ts +1 -1
  127. package/src/transactionIntent/deposits/depositOrchestrator.ts +14 -15
  128. package/src/transactionIntent/deposits/gaslessDeposit.ts +70 -100
  129. package/src/transactionIntent/deposits/standardDeposit.ts +22 -28
  130. package/src/transactionIntent/execution/transactionState.ts +2 -2
  131. package/src/transactionIntent/handlers/crossChain.ts +165 -385
  132. package/src/transactionIntent/handlers/index.ts +0 -1
  133. package/src/transactionIntent/handlers/sameChainSameToken.ts +228 -94
  134. package/src/transactionIntent/quote/normalizeQuote.ts +4 -6
  135. package/src/transactionIntent/quote/quoteHelpers.ts +35 -3
  136. package/src/transactionIntent/types.ts +6 -27
  137. package/src/transactionIntent/utils/index.ts +0 -1
  138. package/src/transactions.ts +6 -203
  139. package/src/umd.tsx +1 -3
  140. package/src/utils.ts +28 -8
  141. package/src/walletUtils.ts +42 -0
  142. package/src/wallets.ts +361 -203
  143. package/src/widget/compiled.css +1 -1
  144. package/src/widget/components/AccountIntentTransactionHistory.tsx +73 -4
  145. package/src/widget/components/AccountSettings.tsx +17 -17
  146. package/src/widget/components/ChainList.tsx +3 -3
  147. package/src/widget/components/ClassicSwap.tsx +19 -10
  148. package/src/widget/components/ConfigDisplay.tsx +1 -1
  149. package/src/widget/components/FeeOption.tsx +63 -20
  150. package/src/widget/components/FeeOptions.tsx +54 -123
  151. package/src/widget/components/NativeGasOption.tsx +3 -1
  152. package/src/widget/components/Pay.tsx +18 -11
  153. package/src/widget/components/PoolDeposit.tsx +23 -10
  154. package/src/widget/components/QRCodeDeposit.tsx +50 -30
  155. package/src/widget/components/QRCodeWalletSelect.tsx +77 -0
  156. package/src/widget/components/QrCode.tsx +188 -233
  157. package/src/widget/components/QuoteDetails.tsx +48 -2
  158. package/src/widget/components/Receipt.tsx +5 -2
  159. package/src/widget/components/ScreenHeader.tsx +10 -8
  160. package/src/widget/components/Toast.tsx +10 -0
  161. package/src/widget/components/TokenImage.tsx +56 -13
  162. package/src/widget/hooks/useCheckout.ts +71 -0
  163. package/src/widget/hooks/useCurrentScreen.tsx +1 -0
  164. package/src/widget/hooks/useDebugScreens.ts +5 -0
  165. package/src/widget/hooks/useIntentTransactionHistory.ts +788 -418
  166. package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
  167. package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
  168. package/src/widget/hooks/useQuote.ts +16 -17
  169. package/src/widget/hooks/useRecentTokens.ts +2 -1
  170. package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
  171. package/src/widget/hooks/useSendForm.ts +172 -47
  172. package/src/widget/hooks/useTokenList.ts +15 -2
  173. package/src/widget/providers/TrailsProvider.tsx +53 -25
  174. package/src/widget/widget.tsx +119 -48
  175. package/dist/cctpqueue.d.ts +0 -18
  176. package/dist/cctpqueue.d.ts.map +0 -1
  177. package/dist/preconditions.d.ts +0 -12
  178. package/dist/preconditions.d.ts.map +0 -1
  179. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +0 -62
  180. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +0 -1
  181. package/dist/transactionIntent/utils/lifiHelpers.d.ts +0 -10
  182. package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +0 -1
  183. package/dist/widget/hooks/useSelectedFeeToken.d.ts +0 -33
  184. package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +0 -1
  185. package/src/cctpqueue.ts +0 -69
  186. package/src/preconditions.ts +0 -47
  187. package/src/transactionIntent/handlers/sameChainDifferentToken.ts +0 -323
  188. package/src/transactionIntent/utils/lifiHelpers.ts +0 -68
  189. package/src/widget/hooks/useSelectedFeeToken.tsx +0 -288
package/src/chains.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { useQuery } from "@tanstack/react-query"
2
- import type { Chain as ViemChain } from "viem"
2
+ import type { Chain as ViemChain, PublicClient } from "viem"
3
+ import { createPublicClient, http } from "viem"
4
+ import { getConfig } from "./config.js"
3
5
 
4
6
  import {
5
7
  arbitrum,
@@ -147,6 +149,41 @@ export const getRpcUrl = (
147
149
  return `${sequenceRpcUrls[chainId]}/${sequenceProjectAccessKey}`
148
150
  }
149
151
 
152
+ /**
153
+ * Get HTTP transport for a chain using Sequence RPC URLs
154
+ * This is a temporary solution to use global config for RPC URLs
155
+ * @param chainId - The chain ID to get the transport for
156
+ * @returns Viem HTTP transport configured with Sequence RPC URL if available
157
+ */
158
+ export function getHttpTransport(chainId: number) {
159
+ const config = getConfig()
160
+ const trailsApiKey = config.trailsApiKey
161
+ const sequenceNodeGatewayUrl = config.sequenceNodeGatewayUrl
162
+
163
+ if (trailsApiKey && sequenceNodeGatewayUrl) {
164
+ const rpcUrl = getRpcUrl(chainId, trailsApiKey, sequenceNodeGatewayUrl)
165
+ if (rpcUrl) {
166
+ return http(rpcUrl)
167
+ }
168
+ }
169
+
170
+ // Fallback to default http() if Sequence RPC URL is not available
171
+ return http()
172
+ }
173
+
174
+ /**
175
+ * Create a public RPC client for a chain using Sequence RPC URLs
176
+ * This is a temporary solution to use global config for RPC URLs
177
+ * @param chain - The chain to create the public client for
178
+ * @returns Viem PublicClient configured with Sequence RPC URL if available
179
+ */
180
+ export function getPublicRpcClient(chain: Chain): PublicClient {
181
+ return createPublicClient({
182
+ chain,
183
+ transport: getHttpTransport(chain.id),
184
+ })
185
+ }
186
+
150
187
  export const supportedSequenceChains: Record<number, Chain> = {
151
188
  [apeChain.id]: getChainInfo(apeChain.id)!,
152
189
  [arbitrum.id]: getChainInfo(arbitrum.id)!,
@@ -280,30 +317,67 @@ export async function getSupportedSequenceChains(): Promise<Chain[]> {
280
317
  return Object.values(supportedSequenceChains)
281
318
  }
282
319
 
283
- export async function getSupportedSequenceTestnetChains(): Promise<Chain[]> {
284
- return Object.values(supportedSequenceTestnetChains)
320
+ // Chain order for sorting (in the desired display order)
321
+ const CHAIN_ORDER = [
322
+ 1, // Ethereum
323
+ 8453, // Base
324
+ 42161, // Arbitrum
325
+ 137, // Polygon
326
+ 747474, // Katana
327
+ 56, // BNB Smart Chain
328
+ 10, // Optimism
329
+ 43114, // Avalanche
330
+ 42170, // Arbitrum Nova
331
+ 42793, // Etherlink
332
+ 100, // Gnosis
333
+ 8333, // B3
334
+ 33139, // Ape Chain
335
+ 1868, // Soneium
336
+ 5031, // Somnia
337
+ 660279, // Xai
338
+ ]
339
+
340
+ // Mapping of chain ID to normalized display name
341
+ const CHAIN_NAME_MAP: Record<number, string> = {
342
+ [arbitrum.id]: "Arbitrum", // Rename from "Arbitrum One"
343
+ [optimism.id]: "Optimism", // Rename from "OP Mainnet"
344
+ [soneium.id]: "Soneium", // Rename from "Soneium Mainnet"
345
+ [xai.id]: "Xai", // Rename from "Xai Mainnet"
285
346
  }
286
347
 
287
- // Priority chains that should appear first in the list
288
- const PRIORITY_CHAIN_IDS = [1, 8453, 42161, 10, 137]
348
+ /**
349
+ * Gets the normalized display name for a chain.
350
+ * @param chainId - The chain ID
351
+ * @param originalName - The original chain name from viem
352
+ * @returns The normalized chain name
353
+ */
354
+ export function getNormalizedChainName(
355
+ chainId: number,
356
+ originalName: string,
357
+ ): string {
358
+ return CHAIN_NAME_MAP[chainId] || originalName
359
+ }
289
360
 
290
- // Sort function for chains with priority order and then by name
291
- function sortChains(chainList: Chain[]): Chain[] {
361
+ /**
362
+ * Sorts chains by the predefined order, then alphabetically for chains not in the order.
363
+ * @param chainList - The list of chains to sort
364
+ * @returns The sorted list of chains
365
+ */
366
+ export function sortChainsByOrder(chainList: Chain[]): Chain[] {
292
367
  return chainList.sort((a, b) => {
293
- // 1. Priority chains first (1, 8453, 42161, 10, 137)
294
- const aPriority = PRIORITY_CHAIN_IDS.indexOf(a.id)
295
- const bPriority = PRIORITY_CHAIN_IDS.indexOf(b.id)
368
+ const aIndex = CHAIN_ORDER.indexOf(a.id)
369
+ const bIndex = CHAIN_ORDER.indexOf(b.id)
296
370
 
297
- // If both are priority chains, sort by priority order
298
- if (aPriority !== -1 && bPriority !== -1) {
299
- return aPriority - bPriority
371
+ // If both chains are in the order, sort by their position
372
+ if (aIndex !== -1 && bIndex !== -1) {
373
+ return aIndex - bIndex
300
374
  }
301
375
 
302
- // If only one is a priority chain, prioritize it
303
- if (aPriority !== -1) return -1
304
- if (bPriority !== -1) return 1
376
+ // If only one chain is in the order, prioritize it
377
+ if (aIndex !== -1) return -1
378
+ if (bIndex !== -1) return 1
305
379
 
306
- // 2. Sort by chain name alphabetically
380
+ // If neither chain is in the order, sort alphabetically
307
381
  return a.name.localeCompare(b.name)
308
382
  })
309
383
  }
@@ -345,10 +419,8 @@ export async function getSupportedChains({
345
419
  (chain, index, self) => index === self.findIndex((c) => c.id === chain.id),
346
420
  )
347
421
 
348
- const sortedChains = sortChains(uniqueChains)
349
-
350
- // Sort chains by priority and then by name
351
- return sortedChains
422
+ // Sort chains by predefined order
423
+ return sortChainsByOrder(uniqueChains)
352
424
  }
353
425
 
354
426
  export function useSupportedChains({
@@ -378,21 +450,3 @@ export function getIsTestnetChainId(chainId: number): boolean {
378
450
  const testnetChainIds = Object.keys(supportedSequenceTestnetChains)
379
451
  return testnetChainIds.includes(chainId.toString())
380
452
  }
381
-
382
- // Get chain color for UI styling
383
- export function getChainColor(chainId: number): string {
384
- switch (chainId) {
385
- case 1:
386
- return "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200" // More gray-blue for Ethereum
387
- case 8453:
388
- return "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200" // Blue for Base
389
- case 42161:
390
- return "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"
391
- case 137:
392
- return "bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200"
393
- case 10:
394
- return "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"
395
- default:
396
- return "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200"
397
- }
398
- }
package/src/config.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  PROD_SEQUENCE_INDEXER_URL,
3
+ PROD_SEQUENCE_METADATA_URL,
3
4
  DEFAULT_WALLETCONNECT_PROJECT_ID,
4
5
  DEFAULT_SLIPPAGE_TOLERANCE,
5
- PROD_SEQUENCE_PROJECT_ACCESS_KEY,
6
6
  PROD_SEQUENCE_NODE_GATEWAY_URL,
7
7
  PROD_TRAILS_API_URL,
8
8
  } from "./constants.js"
@@ -14,6 +14,7 @@ export interface TrailsConfig {
14
14
  trailsApiUrl?: string
15
15
  sequenceIndexerUrl?: string
16
16
  sequenceNodeGatewayUrl?: string
17
+ sequenceMetadataUrl?: string
17
18
  walletConnectProjectId?: string
18
19
  slippageTolerance?: string
19
20
  debug?: boolean
@@ -21,9 +22,10 @@ export interface TrailsConfig {
21
22
  }
22
23
 
23
24
  const globalConfig: TrailsConfig = {
24
- trailsApiKey: PROD_SEQUENCE_PROJECT_ACCESS_KEY,
25
+ trailsApiKey: "",
25
26
  sequenceIndexerUrl: PROD_SEQUENCE_INDEXER_URL,
26
27
  sequenceNodeGatewayUrl: PROD_SEQUENCE_NODE_GATEWAY_URL,
28
+ sequenceMetadataUrl: PROD_SEQUENCE_METADATA_URL,
27
29
  trailsApiUrl: PROD_TRAILS_API_URL,
28
30
  walletConnectProjectId: DEFAULT_WALLETCONNECT_PROJECT_ID,
29
31
  slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
@@ -31,15 +33,23 @@ const globalConfig: TrailsConfig = {
31
33
  commitHash: declareCommitHash(),
32
34
  }
33
35
 
36
+ /**
37
+ * Updates the global config with new values
38
+ * This is a temporary solution to sync config from TrailsProvider
39
+ */
40
+ export function updateGlobalConfig(updates: Partial<TrailsConfig>) {
41
+ Object.assign(globalConfig, updates)
42
+ }
43
+
34
44
  // DEPRECATED: Use TrailsProvider context instead
35
45
  // This is kept only for backward compatibility during migration
36
46
  export function getConfig<T extends keyof TrailsConfig | undefined = undefined>(
37
47
  propName?: T,
38
48
  ): T extends undefined ? Readonly<TrailsConfig> : TrailsConfig[NonNullable<T>] {
39
- console.warn(
40
- "[trails-sdk] getConfig is deprecated. Use TrailsProvider context with useTrails() hook instead.",
41
- propName,
42
- )
49
+ // console.warn(
50
+ // "[trails-sdk] getConfig is deprecated. Use TrailsProvider context with useTrails() hook instead.",
51
+ // propName,
52
+ // )
43
53
  return (propName ? globalConfig[propName] : globalConfig) as any
44
54
  }
45
55
  export function declareCommitHash() {
@@ -75,6 +85,14 @@ export function getDebug() {
75
85
  return globalConfig.debug || getQueryParam("debug") === "true"
76
86
  }
77
87
 
88
+ /**
89
+ * Sets the global debug mode for backward compatibility with getDebug()
90
+ * This is called by TrailsProvider to sync the debug state
91
+ */
92
+ export function setGlobalDebug(debug: boolean) {
93
+ globalConfig.debug = debug
94
+ }
95
+
78
96
  /**
79
97
  * @deprecated Use TrailsProvider context instead
80
98
  */
package/src/constants.ts CHANGED
@@ -29,12 +29,9 @@ export const ATTESATION_SIGNER_ADDRESS: Address.Address =
29
29
 
30
30
  export const PROD_SEQUENCE_NODE_GATEWAY_URL = "https://nodes.sequence.app"
31
31
  export const PROD_SEQUENCE_INDEXER_URL = "https://indexer.sequence.app"
32
+ export const PROD_SEQUENCE_METADATA_URL = "https://metadata.sequence.app"
32
33
  export const PROD_TRAILS_API_URL = "https://trails-api.sequence.app"
33
34
 
34
- // This is used for Sequence Indexer and API
35
- export const PROD_SEQUENCE_PROJECT_ACCESS_KEY =
36
- "AQAAAAAAAKhGHJc3N5V2AWqfJ1v9xZ2u0nA"
37
-
38
35
  export const DATABEAT_SERVER = "https://databeat.sequence.app"
39
36
  export const DATABEAT_KEY =
40
37
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOiJzZXEtdHJhaWxzIiwiZXhwIjoyMDI4MTIwOTg4fQ.KZIjEziul_nZ4kjEXudvfqeWmVekc5ftXKx_EqDrmZU"
@@ -1,12 +1,12 @@
1
- import { createPublicClient, http } from "viem"
2
- import { getChainInfo } from "./chains.js"
1
+ import { getChainInfo, getPublicRpcClient } from "./chains.js"
3
2
  import { logger } from "./logger.js"
4
3
 
5
4
  export async function getIsContract(address: `0x${string}`, chainId: number) {
6
- const client = createPublicClient({
7
- chain: getChainInfo(chainId)!,
8
- transport: http(),
9
- })
5
+ const chainInfo = getChainInfo(chainId)
6
+ if (!chainInfo) {
7
+ throw new Error(`Chain ${chainId} not found`)
8
+ }
9
+ const client = getPublicRpcClient(chainInfo)
10
10
 
11
11
  const code = await client.getCode({ address })
12
12
  const isNonZero = isNonZeroHexString(code)
package/src/estimate.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type PublicClient, formatUnits, createPublicClient, http } from "viem"
2
- import { getChainInfo } from "./chains.js"
1
+ import { type PublicClient, formatUnits } from "viem"
2
+ import { getChainInfo, getPublicRpcClient } from "./chains.js"
3
3
  import { logger } from "./logger.js"
4
4
 
5
5
  // Default minimum gas limit for deposit transactions
@@ -360,10 +360,7 @@ export async function getDefaultGasCostEstimate(
360
360
  try {
361
361
  const chain = getChainInfo(chainId)
362
362
  if (chain) {
363
- const publicClient = createPublicClient({
364
- chain,
365
- transport: http(),
366
- })
363
+ const publicClient = getPublicRpcClient(chain)
367
364
 
368
365
  // Try to estimate gas if we have transaction details
369
366
  let gasLimit = DEFAULT_MIN_GASLIMIT
package/src/fees.ts CHANGED
@@ -58,10 +58,9 @@ export async function extractTrailsFeeBreakdown(
58
58
  return null
59
59
  }
60
60
 
61
- // Get chain IDs from the calls array to determine origin and destination chains
62
- const calls = intent?.calls || []
63
- const originChainId: number | undefined = calls[0]?.chainId // First call is origin chain
64
- const destinationChainId: number | undefined = calls[1]?.chainId // Second call is destination chain
61
+ // Get chain IDs from origin and destination calls
62
+ const originChainId = intent.quoteRequest.originChainId
63
+ const destinationChainId = intent.quoteRequest.destinationChainId
65
64
 
66
65
  // Use the origin and destination gas fees
67
66
  const originChainQuote = fees.originGas
@@ -84,8 +83,7 @@ export async function extractTrailsFeeBreakdown(
84
83
  // Extract origin relay fee if available
85
84
  if (originChainQuote && originChainId !== undefined) {
86
85
  const originTokenSymbol = originChainQuote.nativeTokenSymbol || "ETH"
87
- const originChainIdNum =
88
- typeof originChainId === "bigint" ? Number(originChainId) : originChainId
86
+ const originChainIdNum = originChainId
89
87
  const nativeTokenAddress = zeroAddress
90
88
 
91
89
  breakdown.originRelayFee = {
@@ -106,10 +104,7 @@ export async function extractTrailsFeeBreakdown(
106
104
  if (destinationChainQuote && destinationChainId !== undefined) {
107
105
  const destinationTokenSymbol =
108
106
  destinationChainQuote.nativeTokenSymbol || "ETH"
109
- const destinationChainIdNum =
110
- typeof destinationChainId === "bigint"
111
- ? Number(destinationChainId)
112
- : destinationChainId
107
+ const destinationChainIdNum = destinationChainId
113
108
  const nativeTokenAddress = zeroAddress
114
109
 
115
110
  breakdown.destinationRelayFee = {
package/src/gasless.ts CHANGED
@@ -597,3 +597,48 @@ export async function signIntent({
597
597
 
598
598
  return { signature, v, r, s }
599
599
  }
600
+
601
+ /**
602
+ * Calculates the byte length of a hex signature string.
603
+ * @param signature - The signature (hex string with or without 0x prefix)
604
+ * @returns The number of bytes in the signature
605
+ */
606
+ function getSignatureBytes(signature: string): number {
607
+ return signature.startsWith("0x")
608
+ ? (signature.length - 2) / 2
609
+ : signature.length / 2
610
+ }
611
+
612
+ /**
613
+ * Validates that a signature is exactly 65 bytes (standard ECDSA signature length).
614
+ * @param signature - The signature to validate (hex string with or without 0x prefix)
615
+ * @returns true if signature is 65 bytes, false otherwise
616
+ */
617
+ export function isValidGaslessSignature(signature: string): boolean {
618
+ // Standard ECDSA signatures are 65 bytes (32 bytes r + 32 bytes s + 1 byte v)
619
+ // Smart contract wallets return longer signatures which are not supported
620
+ return getSignatureBytes(signature) === 65
621
+ }
622
+
623
+ /**
624
+ * Validates that a signature is exactly 65 bytes and throws an appropriate error if invalid.
625
+ * @param signature - The signature to validate (hex string with or without 0x prefix)
626
+ * @throws Error if signature is not 65 bytes
627
+ */
628
+ export function validateGaslessSignature(signature: string): void {
629
+ const signatureBytes = getSignatureBytes(signature)
630
+
631
+ if (signatureBytes !== 65) {
632
+ if (signatureBytes > 65) {
633
+ throw new Error(
634
+ "Smart contract wallets are not supported for gasless transfers at the moment. " +
635
+ "Please use an EOA (Externally Owned Account) wallet for gasless transactions.",
636
+ )
637
+ } else {
638
+ throw new Error(
639
+ `Invalid signature length: expected 65 bytes, got ${signatureBytes} bytes. ` +
640
+ "The signature may be malformed.",
641
+ )
642
+ }
643
+ }
644
+ }
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  useSupportedChains,
11
11
  getChainInfo,
12
12
  getAllChains,
13
+ getRpcUrl,
13
14
  type Chain,
14
15
  } from "./chains.js"
15
16
  export { useIndexerGatewayClient } from "./indexerClient.js"
@@ -42,20 +43,20 @@ export type {
42
43
  TransactionState,
43
44
  IntentTransaction,
44
45
  IntentTransactionHistoryResponse,
45
- GetIntentTransactionHistoryParams,
46
46
  TransactionHistoryResponse,
47
47
  GetAccountTransactionHistoryParams,
48
48
  UseAccountTransactionHistoryParams,
49
49
  UseAccountTransactionHistoryReturn,
50
- UseIntentTransactionHistoryParams,
51
- UseIntentTransactionHistoryReturn,
52
50
  } from "./transactions.js"
53
51
  export {
54
- getIntentTransactionHistory,
55
52
  getAccountTransactionHistory,
56
53
  useAccountTransactionHistory,
57
- useIntentTransactionHistory,
58
54
  } from "./transactions.js"
55
+ export { useIntentTransactionHistory } from "./widget/hooks/useIntentTransactionHistory.js"
56
+ export type {
57
+ UseIntentTransactionHistoryParams,
58
+ UseIntentTransactionHistoryReturn,
59
+ } from "./widget/hooks/useIntentTransactionHistory.js"
59
60
  export {
60
61
  getAccountTotalBalanceUsd,
61
62
  getHasSufficientBalanceToken,
@@ -74,6 +75,7 @@ export {
74
75
  getSupportedTokens,
75
76
  useSupportedTokens,
76
77
  useTokenList,
78
+ useGetTokenImageUrl,
77
79
  } from "./tokens.js"
78
80
  export type { SupportedToken } from "./tokens.js"
79
81
  export { getTxTimeDiff } from "./transactions.js"
@@ -83,7 +85,6 @@ export { TRAILS_ROUTER_PLACEHOLDER_AMOUNT } from "./trailsRouter.js"
83
85
  export { getERC20TransferData } from "./encoders.js"
84
86
  // Config functions - getters are deprecated, use TrailsProvider context instead
85
87
  export {
86
- getConfig,
87
88
  getSlippageTolerance,
88
89
  getDebug,
89
90
  getCommitHash,
@@ -28,7 +28,7 @@ export type IndexerGatewayConfig = {
28
28
  * Get the indexer URL for a specific chain slug
29
29
  * Dynamically determines the environment prefix by parsing the base indexer URL
30
30
  * @param chainSlug - The chain slug (e.g., "arbitrum", "base")
31
- * @param baseIndexerUrl - Optional base indexer URL. If not provided, uses getConfig("sequenceIndexerUrl")
31
+ * @param baseIndexerUrl -Indexer URL
32
32
  * @returns The chain-specific indexer URL with appropriate environment prefix
33
33
  */
34
34
  export function getIndexerUrlFromChainSlug(
@@ -67,7 +67,7 @@ export function getIndexerUrlFromChainSlug(
67
67
  * Get the chain-specific indexer URL by chain ID
68
68
  * Returns the appropriate indexer URL based on the current environment
69
69
  * @param chainId - The chain ID
70
- * @param baseIndexerUrl - Optional base indexer URL. If not provided, uses getConfig("sequenceIndexerUrl")
70
+ * @param baseIndexerUrl - Indexer URL
71
71
  */
72
72
  export function getChainIndexerUrl(
73
73
  chainId: number,