0xtrails 0.4.3 → 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 (207) hide show
  1. package/dist/analytics.d.ts +8 -3
  2. package/dist/analytics.d.ts.map +1 -1
  3. package/dist/{ccip-C9CA3tIi.js → ccip-Dw5AN7oU.js} +27 -27
  4. package/dist/cctp.d.ts +0 -149
  5. package/dist/cctp.d.ts.map +1 -1
  6. package/dist/chains.d.ts +31 -4
  7. package/dist/chains.d.ts.map +1 -1
  8. package/dist/config.d.ts +28 -52
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/constants.d.ts +1 -7
  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-CNB57v0n.js → index-BtVUTbEZ.js} +32255 -40547
  18. package/dist/index.d.ts +13 -11
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +320 -944
  21. package/dist/indexerClient.d.ts +9 -6
  22. package/dist/indexerClient.d.ts.map +1 -1
  23. package/dist/intents.d.ts +0 -18
  24. package/dist/intents.d.ts.map +1 -1
  25. package/dist/mutations.d.ts.map +1 -1
  26. package/dist/paymasterSend.d.ts.map +1 -1
  27. package/dist/prepareSend.d.ts +1 -1
  28. package/dist/prepareSend.d.ts.map +1 -1
  29. package/dist/sendUserOp.d.ts +0 -18
  30. package/dist/sendUserOp.d.ts.map +1 -1
  31. package/dist/sequenceWallet.d.ts +1 -1
  32. package/dist/sequenceWallet.d.ts.map +1 -1
  33. package/dist/tokenBalances.d.ts.map +1 -1
  34. package/dist/tokens.d.ts +10 -8
  35. package/dist/tokens.d.ts.map +1 -1
  36. package/dist/trailsClient.d.ts +3 -3
  37. package/dist/trailsClient.d.ts.map +1 -1
  38. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +4 -5
  39. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  40. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +4 -5
  41. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  42. package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -2
  43. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  44. package/dist/transactionIntent/execution/transactionState.d.ts +2 -2
  45. package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
  46. package/dist/transactionIntent/handlers/crossChain.d.ts +6 -4
  47. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  48. package/dist/transactionIntent/handlers/index.d.ts +0 -1
  49. package/dist/transactionIntent/handlers/index.d.ts.map +1 -1
  50. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +4 -34
  51. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  52. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  53. package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -1
  54. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
  55. package/dist/transactionIntent/types.d.ts +7 -19
  56. package/dist/transactionIntent/types.d.ts.map +1 -1
  57. package/dist/transactionIntent/utils/index.d.ts +0 -1
  58. package/dist/transactionIntent/utils/index.d.ts.map +1 -1
  59. package/dist/transactions.d.ts +6 -18
  60. package/dist/transactions.d.ts.map +1 -1
  61. package/dist/utils.d.ts +8 -2
  62. package/dist/utils.d.ts.map +1 -1
  63. package/dist/walletUtils.d.ts +21 -0
  64. package/dist/walletUtils.d.ts.map +1 -0
  65. package/dist/wallets.d.ts +33 -240
  66. package/dist/wallets.d.ts.map +1 -1
  67. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  68. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  69. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  70. package/dist/widget/components/FeeOption.d.ts +8 -13
  71. package/dist/widget/components/FeeOption.d.ts.map +1 -1
  72. package/dist/widget/components/FeeOptions.d.ts +11 -5
  73. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  74. package/dist/widget/components/NativeGasOption.d.ts.map +1 -1
  75. package/dist/widget/components/Pay.d.ts.map +1 -1
  76. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  77. package/dist/widget/components/QRCodeDeposit.d.ts +5 -0
  78. package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
  79. package/dist/widget/components/QRCodeWalletSelect.d.ts +13 -0
  80. package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -0
  81. package/dist/widget/components/QrCode.d.ts.map +1 -1
  82. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  83. package/dist/widget/components/Receipt.d.ts.map +1 -1
  84. package/dist/widget/components/ScreenHeader.d.ts +1 -1
  85. package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
  86. package/dist/widget/components/SlippageToleranceSettings.d.ts +1 -0
  87. package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
  88. package/dist/widget/components/Toast.d.ts.map +1 -1
  89. package/dist/widget/components/TokenImage.d.ts.map +1 -1
  90. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  91. package/dist/widget/css/compiled.css +1 -1
  92. package/dist/widget/hooks/useCheckout.d.ts +15 -1
  93. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  94. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  95. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  96. package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
  97. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  98. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  99. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +7 -0
  100. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +1 -0
  101. package/dist/widget/hooks/useIsSequenceWallet.d.ts +6 -0
  102. package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +1 -0
  103. package/dist/widget/hooks/useQuote.d.ts +6 -11
  104. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  105. package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
  106. package/dist/widget/hooks/useSelectedFeeOption.d.ts +30 -0
  107. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -0
  108. package/dist/widget/hooks/useSendForm.d.ts +6 -15
  109. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  110. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  111. package/dist/widget/index.d.ts +1 -0
  112. package/dist/widget/index.d.ts.map +1 -1
  113. package/dist/widget/index.js +4 -2
  114. package/dist/widget/providers/TrailsProvider.d.ts +29 -0
  115. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -0
  116. package/dist/widget/widget.d.ts +14 -3
  117. package/dist/widget/widget.d.ts.map +1 -1
  118. package/package.json +9 -8
  119. package/src/analytics.ts +53 -21
  120. package/src/cctp.ts +0 -1016
  121. package/src/chains.ts +155 -68
  122. package/src/config.ts +51 -207
  123. package/src/constants.ts +1 -13
  124. package/src/contractUtils.ts +6 -6
  125. package/src/estimate.ts +3 -6
  126. package/src/fees.ts +5 -10
  127. package/src/gasless.ts +45 -0
  128. package/src/index.ts +18 -40
  129. package/src/indexerClient.ts +39 -48
  130. package/src/intents.ts +51 -226
  131. package/src/mutations.ts +3 -2
  132. package/src/paymasterSend.ts +2 -5
  133. package/src/prepareSend.ts +21 -14
  134. package/src/sendUserOp.ts +3 -64
  135. package/src/sequenceWallet.ts +1 -2
  136. package/src/tokenBalances.ts +2 -1
  137. package/src/tokens.ts +62 -133
  138. package/src/trailsClient.ts +17 -12
  139. package/src/transactionIntent/deposits/depositOrchestrator.ts +14 -15
  140. package/src/transactionIntent/deposits/gaslessDeposit.ts +70 -100
  141. package/src/transactionIntent/deposits/standardDeposit.ts +22 -28
  142. package/src/transactionIntent/execution/transactionState.ts +2 -2
  143. package/src/transactionIntent/handlers/crossChain.ts +179 -381
  144. package/src/transactionIntent/handlers/index.ts +0 -1
  145. package/src/transactionIntent/handlers/sameChainSameToken.ts +228 -94
  146. package/src/transactionIntent/quote/normalizeQuote.ts +4 -6
  147. package/src/transactionIntent/quote/quoteHelpers.ts +35 -3
  148. package/src/transactionIntent/types.ts +7 -27
  149. package/src/transactionIntent/utils/index.ts +0 -1
  150. package/src/transactions.ts +19 -118
  151. package/src/umd.tsx +1 -3
  152. package/src/utils.ts +28 -8
  153. package/src/walletUtils.ts +42 -0
  154. package/src/wallets.ts +365 -208
  155. package/src/widget/compiled.css +1 -1
  156. package/src/widget/components/AccountIntentTransactionHistory.tsx +78 -4
  157. package/src/widget/components/AccountSettings.tsx +17 -17
  158. package/src/widget/components/ChainList.tsx +3 -3
  159. package/src/widget/components/ClassicSwap.tsx +19 -10
  160. package/src/widget/components/ConfigDisplay.tsx +19 -59
  161. package/src/widget/components/FeeOption.tsx +63 -20
  162. package/src/widget/components/FeeOptions.tsx +54 -123
  163. package/src/widget/components/NativeGasOption.tsx +3 -1
  164. package/src/widget/components/Pay.tsx +18 -11
  165. package/src/widget/components/PoolDeposit.tsx +23 -10
  166. package/src/widget/components/QRCodeDeposit.tsx +50 -30
  167. package/src/widget/components/QRCodeWalletSelect.tsx +77 -0
  168. package/src/widget/components/QrCode.tsx +188 -233
  169. package/src/widget/components/QuoteDetails.tsx +48 -2
  170. package/src/widget/components/Receipt.tsx +5 -2
  171. package/src/widget/components/ScreenHeader.tsx +10 -8
  172. package/src/widget/components/SlippageToleranceSettings.tsx +63 -14
  173. package/src/widget/components/Toast.tsx +10 -0
  174. package/src/widget/components/TokenImage.tsx +56 -13
  175. package/src/widget/components/WalletConnect.tsx +37 -99
  176. package/src/widget/hooks/useCheckout.ts +71 -0
  177. package/src/widget/hooks/useCurrentScreen.tsx +1 -0
  178. package/src/widget/hooks/useDebugScreens.ts +5 -0
  179. package/src/widget/hooks/useIntentTransactionHistory.ts +790 -412
  180. package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
  181. package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
  182. package/src/widget/hooks/useQuote.ts +27 -34
  183. package/src/widget/hooks/useRecentTokens.ts +2 -1
  184. package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
  185. package/src/widget/hooks/useSendForm.ts +175 -46
  186. package/src/widget/hooks/useTokenList.ts +15 -2
  187. package/src/widget/index.tsx +8 -0
  188. package/src/widget/providers/TrailsProvider.tsx +123 -0
  189. package/src/widget/widget.tsx +165 -143
  190. package/dist/cctpqueue.d.ts +0 -18
  191. package/dist/cctpqueue.d.ts.map +0 -1
  192. package/dist/preconditions.d.ts +0 -12
  193. package/dist/preconditions.d.ts.map +0 -1
  194. package/dist/trails.d.ts +0 -110
  195. package/dist/trails.d.ts.map +0 -1
  196. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +0 -62
  197. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +0 -1
  198. package/dist/transactionIntent/utils/lifiHelpers.d.ts +0 -10
  199. package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +0 -1
  200. package/dist/widget/hooks/useSelectedFeeToken.d.ts +0 -33
  201. package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +0 -1
  202. package/src/cctpqueue.ts +0 -66
  203. package/src/preconditions.ts +0 -47
  204. package/src/trails.ts +0 -1303
  205. package/src/transactionIntent/handlers/sameChainDifferentToken.ts +0 -323
  206. package/src/transactionIntent/utils/lifiHelpers.ts +0 -68
  207. package/src/widget/hooks/useSelectedFeeToken.tsx +0 -288
@@ -1,14 +1,12 @@
1
1
  import { useQuery } from "@tanstack/react-query"
2
2
  import { getChainInfo } from "./chains.js"
3
- import { getSequenceProjectAccessKey } from "./config.js"
4
- import { getTrailsClient } from "./trailsClient.js"
5
3
  import type { GuestModuleEvent, TrailsTokenSweeperEvent } from "./decoders.js"
6
4
  import { logger } from "./logger.js"
7
- import { bigintReplacer } from "./utils.js"
8
5
  import { getExplorerUrl } from "./explorer.js"
9
- import { SortOrder } from "@0xsequence/trails-api"
6
+ import { JsonEncode } from "@0xsequence/trails-api"
10
7
  import { getChainIndexerUrl } from "./indexerClient.js"
11
8
  import { abortControllerRegistry } from "./abortController.js"
9
+ import { useTrails } from "./widget/providers/TrailsProvider.js"
12
10
 
13
11
  export type TransactionStateStatus =
14
12
  | "pending"
@@ -161,11 +159,14 @@ export async function getAccountTransactionHistory({
161
159
  page = 1,
162
160
  includeMetadata = true,
163
161
  abortSignal,
164
- }: GetAccountTransactionHistoryParams): Promise<TransactionHistoryResponse> {
165
- const accessKey = getSequenceProjectAccessKey()
166
-
167
- if (!accessKey) {
168
- throw new Error("Sequence project access key is required")
162
+ apiKey,
163
+ indexerUrl,
164
+ }: GetAccountTransactionHistoryParams & {
165
+ apiKey: string
166
+ indexerUrl: string
167
+ }): Promise<TransactionHistoryResponse> {
168
+ if (!apiKey) {
169
+ throw new Error("Trails api key is required")
169
170
  }
170
171
 
171
172
  // Create a unique ID for this operation
@@ -187,7 +188,7 @@ export async function getAccountTransactionHistory({
187
188
  }
188
189
 
189
190
  // Get the chain-specific indexer URL
190
- const chainIndexerUrl = getChainIndexerUrl(chainId)
191
+ const chainIndexerUrl = getChainIndexerUrl(chainId, indexerUrl)
191
192
  if (!chainIndexerUrl) {
192
193
  throw new Error(`Unsupported chain ID: ${chainId}`)
193
194
  }
@@ -217,9 +218,9 @@ export async function getAccountTransactionHistory({
217
218
  method: "POST",
218
219
  headers: {
219
220
  "Content-Type": "application/json",
220
- "X-Access-Key": accessKey,
221
+ "X-Access-Key": apiKey,
221
222
  },
222
- body: JSON.stringify(requestBody, bigintReplacer, 2),
223
+ body: JsonEncode(requestBody),
223
224
  signal: abortSignal || operationAbortController.signal,
224
225
  })
225
226
 
@@ -275,6 +276,9 @@ export type IntentTransaction = {
275
276
  destinationTokenAmount?: string
276
277
  destinationToAddress?: string
277
278
  createdAt?: string
279
+ // Transaction hashes from API response
280
+ originTransactionHash?: string // Transaction hash from API
281
+ destinationTransactionHash?: string // Transaction hash from API
278
282
  // Enriched token information
279
283
  originToken?: {
280
284
  symbol: string
@@ -310,66 +314,6 @@ export type IntentTransactionHistoryResponse = {
310
314
  transactions: IntentTransaction[]
311
315
  }
312
316
 
313
- export type GetIntentTransactionHistoryParams = {
314
- accountAddress: string
315
- pageSize?: number
316
- page?: number
317
- }
318
-
319
- export async function getIntentTransactionHistory({
320
- accountAddress: _accountAddress,
321
- pageSize = 10,
322
- page = 1,
323
- }: GetIntentTransactionHistoryParams): Promise<IntentTransactionHistoryResponse> {
324
- const accessKey = getSequenceProjectAccessKey()
325
-
326
- if (!accessKey) {
327
- throw new Error("Sequence project access key is required")
328
- }
329
-
330
- try {
331
- const trailsClient = getTrailsClient()
332
-
333
- // Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
334
- const result = await trailsClient.getIntentTransactionHistory({
335
- page: {
336
- pageSize,
337
- sort: [
338
- {
339
- column: "created_at",
340
- order: SortOrder.DESC,
341
- },
342
- ],
343
- },
344
- })
345
-
346
- // Note: The new API has a different IntentTransaction structure.
347
- // We need to map the API response to our local type structure.
348
- // For now, return an empty result as the API structure has changed significantly.
349
- // TODO: Implement proper mapping from new API IntentTransaction to SDK IntentTransaction
350
- return {
351
- page: result.nextPage
352
- ? {
353
- page,
354
- pageSize,
355
- more: true,
356
- }
357
- : {
358
- page,
359
- pageSize,
360
- more: false,
361
- },
362
- transactions: [], // TODO: Map result.transactions to SDK IntentTransaction format
363
- }
364
- } catch (error) {
365
- logger.console.error(
366
- "[trails-sdk] Error fetching intent transaction history:",
367
- error,
368
- )
369
- throw error
370
- }
371
- }
372
-
373
317
  export type UseAccountTransactionHistoryParams = {
374
318
  chainId?: number | null
375
319
  accountAddress?: string | null
@@ -393,6 +337,7 @@ export function useAccountTransactionHistory({
393
337
  includeMetadata = true,
394
338
  abortSignal,
395
339
  }: UseAccountTransactionHistoryParams): UseAccountTransactionHistoryReturn {
340
+ const { trailsApiKey, sequenceIndexerUrl } = useTrails()
396
341
  const { data, isLoading, error } = useQuery({
397
342
  queryKey: [
398
343
  "accountTransactionHistory",
@@ -417,6 +362,8 @@ export function useAccountTransactionHistory({
417
362
  page,
418
363
  includeMetadata,
419
364
  abortSignal: effectiveSignal,
365
+ apiKey: trailsApiKey || "",
366
+ indexerUrl: sequenceIndexerUrl!,
420
367
  })
421
368
  },
422
369
  enabled: Boolean(chainId && accountAddress),
@@ -434,49 +381,3 @@ export function useAccountTransactionHistory({
434
381
  error: error as Error | null,
435
382
  }
436
383
  }
437
-
438
- export type UseIntentTransactionHistoryParams = {
439
- accountAddress?: string | null
440
- pageSize?: number
441
- page?: number
442
- }
443
-
444
- export type UseIntentTransactionHistoryReturn = {
445
- data: IntentTransactionHistoryResponse | undefined
446
- isLoading: boolean
447
- error: Error | null
448
- }
449
-
450
- export function useIntentTransactionHistory({
451
- accountAddress,
452
- pageSize = 10,
453
- page = 1,
454
- }: UseIntentTransactionHistoryParams): UseIntentTransactionHistoryReturn {
455
- const { data, isLoading, error } = useQuery({
456
- queryKey: ["intentTransactionHistory", accountAddress, pageSize, page],
457
- queryFn: async () => {
458
- if (!accountAddress) {
459
- return undefined
460
- }
461
-
462
- return await getIntentTransactionHistory({
463
- accountAddress,
464
- pageSize,
465
- page,
466
- })
467
- },
468
- enabled: Boolean(accountAddress),
469
- staleTime: 30 * 1000, // Consider data fresh for 30 seconds
470
- refetchOnWindowFocus: false,
471
- refetchOnMount: false,
472
- refetchInterval: false,
473
- retry: 2,
474
- refetchOnReconnect: true,
475
- })
476
-
477
- return {
478
- data,
479
- isLoading,
480
- error: error as Error | null,
481
- }
482
- }
package/src/umd.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from "react"
2
2
  import { createRoot } from "react-dom/client"
3
- import type { RelayerEnv } from "./relayer.js"
4
3
  import type { Theme } from "./theme.js"
5
4
  import { TrailsWidget } from "./widget/widget.js"
6
5
 
@@ -8,10 +7,9 @@ interface TrailsGlobal {
8
7
  render: (
9
8
  element: HTMLElement,
10
9
  options: {
11
- projectAccessKey: string
10
+ apiKey: string
12
11
  sequenceIndexerUrl?: string
13
12
  trailsApiUrl?: string
14
- sequenceEnv?: RelayerEnv
15
13
  toAddress?: string | null
16
14
  toAmount?: string | null
17
15
  toChainId?: number | string | null
package/src/utils.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ethAddress, zeroAddress } from "viem"
2
+
1
3
  export async function requestWithTimeout<T>(
2
4
  client: { request: (...args: any[]) => Promise<T> },
3
5
  args: Parameters<typeof client.request>,
@@ -11,10 +13,6 @@ export async function requestWithTimeout<T>(
11
13
  ])
12
14
  }
13
15
 
14
- export function bigintToString(n: bigint): string {
15
- return n.toString()
16
- }
17
-
18
16
  /**
19
17
  * Formats completion time in seconds to human-readable format
20
18
  * @param seconds - Time in seconds
@@ -69,10 +67,6 @@ export function getTimeAgo(timestamp?: number): string {
69
67
  return `Sent ${diffInDays} days ago`
70
68
  }
71
69
 
72
- export function bigintReplacer(_key: string, value: any) {
73
- return typeof value === "bigint" ? value.toString() : value
74
- }
75
-
76
70
  /**
77
71
  * Truncates an Ethereum address to show first 6 and last 4 characters
78
72
  * @param address - The full Ethereum address
@@ -86,3 +80,29 @@ export function truncateAddress(
86
80
  if (!address) return ""
87
81
  return `${address.slice(0, start)}…${address.slice(-end)}`
88
82
  }
83
+
84
+ /**
85
+ * Checks if an address represents a native token (ETH or zero address)
86
+ * @param address - The token address to check
87
+ * @param caseInsensitive - Whether to perform case-insensitive comparison (default: true)
88
+ * @returns True if the address is a native token address
89
+ */
90
+ export function isNativeToken(
91
+ address?: string | null,
92
+ caseInsensitive = true,
93
+ ): boolean {
94
+ if (!address) {
95
+ return false
96
+ }
97
+
98
+ const addresses = caseInsensitive
99
+ ? [zeroAddress.toLowerCase(), ethAddress.toLowerCase()]
100
+ : [zeroAddress, ethAddress]
101
+
102
+ const normalizedAddress = caseInsensitive ? address.toLowerCase() : address
103
+
104
+ return addresses.includes(normalizedAddress)
105
+ }
106
+
107
+ export const normalizeAddress = (address?: string | null): string =>
108
+ (address ?? "").toLowerCase()
@@ -0,0 +1,42 @@
1
+ import type { Connector } from "wagmi"
2
+ import { getIsContract } from "./contractUtils.js"
3
+
4
+ /**
5
+ * Checks if a wallet connector is a Sequence wallet.
6
+ * @param connector - The wagmi connector to check
7
+ * @returns true if the connector is a Sequence wallet, false otherwise
8
+ */
9
+ export function isSequenceWallet(connector: Connector | undefined): boolean {
10
+ if (!connector) return false
11
+ const connectorName = connector.name?.toLowerCase() || ""
12
+ const connectorId = connector.id?.toLowerCase() || ""
13
+ return connectorName.includes("sequence") || connectorId.includes("sequence")
14
+ }
15
+
16
+ /**
17
+ * Checks if a wallet ID indicates a Sequence wallet.
18
+ * @param walletId - The wallet ID to check
19
+ * @returns true if the wallet ID indicates a Sequence wallet, false otherwise
20
+ */
21
+ export function isSequenceWalletById(walletId: string | undefined): boolean {
22
+ if (!walletId) return false
23
+ return walletId.toLowerCase().includes("sequence")
24
+ }
25
+
26
+ /**
27
+ * Checks if an address is a smart contract wallet.
28
+ * @param address - The wallet address to check
29
+ * @param chainId - The chain ID to check the wallet on
30
+ * @returns Promise that resolves to true if the address is a smart contract, false otherwise
31
+ */
32
+ export async function isSmartContractWallet(
33
+ address: string,
34
+ chainId: number,
35
+ ): Promise<boolean> {
36
+ try {
37
+ return await getIsContract(address as `0x${string}`, chainId)
38
+ } catch {
39
+ // Return false on error to be safe
40
+ return false
41
+ }
42
+ }