0xtrails 0.4.2 → 0.5.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 (81) hide show
  1. package/dist/{ccip-Dl3umoGg.js → ccip-DhEkQ6QC.js} +27 -27
  2. package/dist/cctpqueue.d.ts.map +1 -1
  3. package/dist/chains.d.ts +3 -1
  4. package/dist/chains.d.ts.map +1 -1
  5. package/dist/config.d.ts +17 -52
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/constants.d.ts +0 -6
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/{index-sMS_ge1R.js → index-MhD2DA7_.js} +23613 -23893
  10. package/dist/index.d.ts +7 -7
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +319 -944
  13. package/dist/indexerClient.d.ts +9 -6
  14. package/dist/indexerClient.d.ts.map +1 -1
  15. package/dist/intents.d.ts +0 -1
  16. package/dist/intents.d.ts.map +1 -1
  17. package/dist/prepareSend.d.ts.map +1 -1
  18. package/dist/sequenceWallet.d.ts +1 -1
  19. package/dist/sequenceWallet.d.ts.map +1 -1
  20. package/dist/trailsClient.d.ts +3 -3
  21. package/dist/trailsClient.d.ts.map +1 -1
  22. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  23. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  24. package/dist/transactionIntent/handlers/crossChain.d.ts +3 -1
  25. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  26. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  27. package/dist/transactionIntent/types.d.ts +1 -0
  28. package/dist/transactionIntent/types.d.ts.map +1 -1
  29. package/dist/transactions.d.ts +8 -2
  30. package/dist/transactions.d.ts.map +1 -1
  31. package/dist/wallets.d.ts.map +1 -1
  32. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  33. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  34. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  35. package/dist/widget/components/SlippageToleranceSettings.d.ts +1 -0
  36. package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
  37. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  38. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  39. package/dist/widget/hooks/useQuote.d.ts +2 -4
  40. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  41. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  42. package/dist/widget/index.d.ts +1 -0
  43. package/dist/widget/index.d.ts.map +1 -1
  44. package/dist/widget/index.js +4 -2
  45. package/dist/widget/providers/TrailsProvider.d.ts +18 -0
  46. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -0
  47. package/dist/widget/widget.d.ts +3 -3
  48. package/dist/widget/widget.d.ts.map +1 -1
  49. package/package.json +3 -2
  50. package/src/analytics.ts +2 -2
  51. package/src/cctpqueue.ts +6 -3
  52. package/src/chains.ts +62 -29
  53. package/src/config.ts +36 -210
  54. package/src/constants.ts +0 -9
  55. package/src/index.ts +12 -35
  56. package/src/indexerClient.ts +39 -48
  57. package/src/intents.ts +0 -21
  58. package/src/prepareSend.ts +16 -2
  59. package/src/sequenceWallet.ts +1 -2
  60. package/src/trailsClient.ts +17 -12
  61. package/src/transactionIntent/deposits/gaslessDeposit.ts +88 -43
  62. package/src/transactionIntent/deposits/standardDeposit.ts +91 -53
  63. package/src/transactionIntent/handlers/crossChain.ts +88 -0
  64. package/src/transactionIntent/handlers/sameChainSameToken.ts +22 -0
  65. package/src/transactionIntent/types.ts +1 -0
  66. package/src/transactions.ts +122 -24
  67. package/src/wallets.ts +5 -6
  68. package/src/widget/components/AccountIntentTransactionHistory.tsx +5 -0
  69. package/src/widget/components/ConfigDisplay.tsx +19 -59
  70. package/src/widget/components/FeeOptions.tsx +1 -1
  71. package/src/widget/components/SlippageToleranceSettings.tsx +63 -14
  72. package/src/widget/components/WalletConnect.tsx +37 -99
  73. package/src/widget/hooks/useIntentTransactionHistory.ts +9 -1
  74. package/src/widget/hooks/useQuote.ts +11 -17
  75. package/src/widget/hooks/useSendForm.ts +4 -0
  76. package/src/widget/index.tsx +8 -0
  77. package/src/widget/providers/TrailsProvider.tsx +95 -0
  78. package/src/widget/widget.tsx +49 -98
  79. package/dist/trails.d.ts +0 -110
  80. package/dist/trails.d.ts.map +0 -1
  81. package/src/trails.ts +0 -1303
@@ -145,6 +145,8 @@ export async function handleCrossChain({
145
145
  abortSignal,
146
146
  commitIntentFn,
147
147
  executeIntentFn,
148
+ sequenceProjectAccessKey,
149
+ sequenceIndexerUrl,
148
150
  }: {
149
151
  mainSignerAddress: string
150
152
  originChainId: number
@@ -187,6 +189,8 @@ export async function handleCrossChain({
187
189
  depositTransactionHash?: string
188
190
  depositSignature?: DepositSignature
189
191
  }) => Promise<ExecuteIntentResponse>
192
+ sequenceProjectAccessKey?: string
193
+ sequenceIndexerUrl?: string
190
194
  }): Promise<PrepareSendReturn> {
191
195
  const testnet = isTestnetDebugMode()
192
196
  const useCctp = shouldUseCctp(
@@ -324,6 +328,10 @@ export async function handleCrossChain({
324
328
  )
325
329
 
326
330
  onTransactionStateChange(transactionStates)
331
+ // Also trigger checkout status update if handler is provided
332
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
333
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(transactionStates)
334
+ }
327
335
 
328
336
  const attestation = await waitForAttestation()
329
337
 
@@ -380,12 +388,16 @@ export async function handleCrossChain({
380
388
  "[trails-sdk] sequenceWalletAddress",
381
389
  sequenceWalletAddress,
382
390
  )
391
+ if (!sequenceProjectAccessKey) {
392
+ throw new Error("Trails api key is required")
393
+ }
383
394
  const sequenceTxHash = await sequenceSendTransaction(
384
395
  sequenceWalletAddress,
385
396
  delegatorClient,
386
397
  destinationPublicClient,
387
398
  calls,
388
399
  destinationChain,
400
+ sequenceProjectAccessKey,
389
401
  )
390
402
 
391
403
  const destinationReceipt =
@@ -407,6 +419,10 @@ export async function handleCrossChain({
407
419
  }
408
420
 
409
421
  onTransactionStateChange(transactionStates)
422
+ // Also trigger checkout status update if handler is provided
423
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
424
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(transactionStates)
425
+ }
410
426
 
411
427
  return {
412
428
  depositUserTxnReceipt: receipt,
@@ -751,6 +767,7 @@ export async function handleCrossChain({
751
767
  selectedFeeToken: effectiveSelectedFeeToken,
752
768
  selectedFeeTokenType: typeof effectiveSelectedFeeToken,
753
769
  selectedFeeTokenValue: JSON.stringify(effectiveSelectedFeeToken),
770
+ checkoutOnHandlers,
754
771
  },
755
772
  )
756
773
 
@@ -778,6 +795,7 @@ export async function handleCrossChain({
778
795
  destinationTokenSymbol,
779
796
  depositAmountUsd,
780
797
  feeOptions: gasFeeOptions,
798
+ checkoutOnHandlers,
781
799
  trailsClient,
782
800
  selectedFeeToken: effectiveSelectedFeeToken,
783
801
  walletId,
@@ -886,6 +904,10 @@ export async function handleCrossChain({
886
904
  }
887
905
 
888
906
  onTransactionStateChange(transactionStates)
907
+ // Also trigger checkout status update if handler is provided
908
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
909
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(transactionStates)
910
+ }
889
911
 
890
912
  setTimeout(() => {
891
913
  const destinationChain = getChainInfo(destinationChainId)
@@ -916,10 +938,15 @@ export async function handleCrossChain({
916
938
  }
917
939
 
918
940
  try {
941
+ if (!sequenceIndexerUrl) {
942
+ throw new Error("sequenceIndexerUrl is required")
943
+ }
919
944
  const response = await getAccountTransactionHistory({
920
945
  chainId: originChainId,
921
946
  accountAddress: originIntentAddress,
922
947
  abortSignal,
948
+ apiKey: sequenceProjectAccessKey!,
949
+ indexerUrl: sequenceIndexerUrl,
923
950
  })
924
951
  logger.console.log(
925
952
  "[trails-sdk] getAccountTransactionHistory response",
@@ -953,6 +980,12 @@ export async function handleCrossChain({
953
980
  transactionStates[0]?.label,
954
981
  )
955
982
  onTransactionStateChange(transactionStates)
983
+ // Also trigger checkout status update if handler is provided
984
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
985
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
986
+ transactionStates,
987
+ )
988
+ }
956
989
 
957
990
  if (onOriginSend) {
958
991
  onOriginSend()
@@ -980,11 +1013,16 @@ export async function handleCrossChain({
980
1013
  }
981
1014
 
982
1015
  try {
1016
+ if (!sequenceIndexerUrl) {
1017
+ throw new Error("sequenceIndexerUrl is required")
1018
+ }
983
1019
  const response = await getAccountTransactionHistory({
984
1020
  chainId: destinationChainId,
985
1021
  accountAddress:
986
1022
  intent.destinationIntentAddress as `0x${string}`,
987
1023
  abortSignal,
1024
+ apiKey: sequenceProjectAccessKey!,
1025
+ indexerUrl: sequenceIndexerUrl,
988
1026
  })
989
1027
  logger.console.log(
990
1028
  "[trails-sdk] getAccountTransactionHistory response",
@@ -1019,6 +1057,12 @@ export async function handleCrossChain({
1019
1057
  transactionStates[2]?.label,
1020
1058
  )
1021
1059
  onTransactionStateChange(transactionStates)
1060
+ // Also trigger checkout status update if handler is provided
1061
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1062
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1063
+ transactionStates,
1064
+ )
1065
+ }
1022
1066
 
1023
1067
  return destinationDepositTxReceipt
1024
1068
  }
@@ -1092,6 +1136,12 @@ export async function handleCrossChain({
1092
1136
  transactionStates[0]?.label,
1093
1137
  )
1094
1138
  onTransactionStateChange(transactionStates)
1139
+ // Also trigger checkout status update if handler is provided
1140
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1141
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1142
+ transactionStates,
1143
+ )
1144
+ }
1095
1145
 
1096
1146
  // Decode events for the deposit transaction
1097
1147
  try {
@@ -1147,6 +1197,12 @@ export async function handleCrossChain({
1147
1197
  }
1148
1198
 
1149
1199
  onTransactionStateChange(transactionStates)
1200
+ // Also trigger checkout status update if handler is provided
1201
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1202
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1203
+ transactionStates,
1204
+ )
1205
+ }
1150
1206
  } catch (error) {
1151
1207
  logger.console.error(
1152
1208
  "Error decoding deposit tx events",
@@ -1192,6 +1248,12 @@ export async function handleCrossChain({
1192
1248
  transactionStates[1]?.label,
1193
1249
  )
1194
1250
  onTransactionStateChange(transactionStates)
1251
+ // Also trigger checkout status update if handler is provided
1252
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1253
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1254
+ transactionStates,
1255
+ )
1256
+ }
1195
1257
  }
1196
1258
 
1197
1259
  // Decode events for the origin transaction
@@ -1241,6 +1303,12 @@ export async function handleCrossChain({
1241
1303
  }
1242
1304
 
1243
1305
  onTransactionStateChange(transactionStates)
1306
+ // Also trigger checkout status update if handler is provided
1307
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1308
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1309
+ transactionStates,
1310
+ )
1311
+ }
1244
1312
  } catch (error) {
1245
1313
  logger.console.error(
1246
1314
  "Error decoding origin tx events",
@@ -1281,6 +1349,12 @@ export async function handleCrossChain({
1281
1349
  transactionStates[2]?.label,
1282
1350
  )
1283
1351
  onTransactionStateChange(transactionStates)
1352
+ // Also trigger checkout status update if handler is provided
1353
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1354
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1355
+ transactionStates,
1356
+ )
1357
+ }
1284
1358
  }
1285
1359
 
1286
1360
  // Decode events for the destination transaction
@@ -1339,6 +1413,12 @@ export async function handleCrossChain({
1339
1413
  }
1340
1414
 
1341
1415
  onTransactionStateChange(transactionStates)
1416
+ // Also trigger checkout status update if handler is provided
1417
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1418
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
1419
+ transactionStates,
1420
+ )
1421
+ }
1342
1422
  } catch (error) {
1343
1423
  logger.console.error(
1344
1424
  "Error decoding destination tx events",
@@ -1631,6 +1711,10 @@ export async function handleCrossChain({
1631
1711
  ) {
1632
1712
  transactionStates[1].state = "aborted"
1633
1713
  onTransactionStateChange(transactionStates)
1714
+ // Also trigger checkout status update if handler is provided
1715
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1716
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(transactionStates)
1717
+ }
1634
1718
  }
1635
1719
  if (
1636
1720
  transactionStates[2] &&
@@ -1639,6 +1723,10 @@ export async function handleCrossChain({
1639
1723
  ) {
1640
1724
  transactionStates[2].state = "aborted"
1641
1725
  onTransactionStateChange(transactionStates)
1726
+ // Also trigger checkout status update if handler is provided
1727
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
1728
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(transactionStates)
1729
+ }
1642
1730
  }
1643
1731
 
1644
1732
  // Track payment error if transactions didn't complete successfully
@@ -418,6 +418,12 @@ export async function handleSameChainSameToken({
418
418
 
419
419
  try {
420
420
  onTransactionStateChange(localTransactionStates)
421
+ // Also trigger checkout status update if handler is provided
422
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
423
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
424
+ localTransactionStates,
425
+ )
426
+ }
421
427
  } catch (error) {
422
428
  logger.console.error(
423
429
  "[trails-sdk] Error calling onTransactionStateChange:",
@@ -514,6 +520,12 @@ export async function handleSameChainSameToken({
514
520
  localTransactionStates[0]?.label,
515
521
  )
516
522
  onTransactionStateChange(localTransactionStates)
523
+ // Also trigger checkout status update if handler is provided
524
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
525
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
526
+ localTransactionStates,
527
+ )
528
+ }
517
529
  } catch (error) {
518
530
  logger.console.error(
519
531
  "[trails-sdk] Error fetching deposit transaction receipt:",
@@ -551,6 +563,12 @@ export async function handleSameChainSameToken({
551
563
  localTransactionStates[1]?.label,
552
564
  )
553
565
  onTransactionStateChange(localTransactionStates)
566
+ // Also trigger checkout status update if handler is provided
567
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
568
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(
569
+ localTransactionStates,
570
+ )
571
+ }
554
572
  } catch (error) {
555
573
  logger.console.error(
556
574
  "[trails-sdk] Error fetching origin transaction receipt:",
@@ -580,6 +598,10 @@ export async function handleSameChainSameToken({
580
598
  ),
581
599
  ]
582
600
  onTransactionStateChange(updatedStates)
601
+ // Also trigger checkout status update if handler is provided
602
+ if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
603
+ checkoutOnHandlers.triggerCheckoutStatusUpdate(updatedStates)
604
+ }
583
605
  } catch (error) {
584
606
  logger.console.error(
585
607
  "[trails-sdk] Error calling onTransactionStateChange:",
@@ -55,6 +55,7 @@ export type PrepareSendOptions = {
55
55
  originTokenSymbol: string
56
56
  destinationTokenSymbol: string
57
57
  sequenceProjectAccessKey?: string
58
+ sequenceIndexerUrl?: string
58
59
  fee: string
59
60
  client?: WalletClient
60
61
  dryMode: boolean
@@ -1,14 +1,14 @@
1
1
  import { useQuery } from "@tanstack/react-query"
2
2
  import { getChainInfo } from "./chains.js"
3
- import { getSequenceProjectAccessKey } from "./config.js"
4
3
  import { getTrailsClient } from "./trailsClient.js"
5
4
  import type { GuestModuleEvent, TrailsTokenSweeperEvent } from "./decoders.js"
6
5
  import { logger } from "./logger.js"
7
6
  import { bigintReplacer } from "./utils.js"
8
7
  import { getExplorerUrl } from "./explorer.js"
9
- import { SortOrder } from "@0xsequence/trails-api"
8
+ import { SortOrder, type IntentSummary } from "@0xsequence/trails-api"
10
9
  import { getChainIndexerUrl } from "./indexerClient.js"
11
10
  import { abortControllerRegistry } from "./abortController.js"
11
+ import { useTrails } from "./widget/providers/TrailsProvider.js"
12
12
 
13
13
  export type TransactionStateStatus =
14
14
  | "pending"
@@ -161,11 +161,14 @@ export async function getAccountTransactionHistory({
161
161
  page = 1,
162
162
  includeMetadata = true,
163
163
  abortSignal,
164
- }: GetAccountTransactionHistoryParams): Promise<TransactionHistoryResponse> {
165
- const accessKey = getSequenceProjectAccessKey()
166
-
167
- if (!accessKey) {
168
- throw new Error("Sequence project access key is required")
164
+ apiKey,
165
+ indexerUrl,
166
+ }: GetAccountTransactionHistoryParams & {
167
+ apiKey: string
168
+ indexerUrl: string
169
+ }): Promise<TransactionHistoryResponse> {
170
+ if (!apiKey) {
171
+ throw new Error("Trails api key is required")
169
172
  }
170
173
 
171
174
  // Create a unique ID for this operation
@@ -187,7 +190,7 @@ export async function getAccountTransactionHistory({
187
190
  }
188
191
 
189
192
  // Get the chain-specific indexer URL
190
- const chainIndexerUrl = getChainIndexerUrl(chainId)
193
+ const chainIndexerUrl = getChainIndexerUrl(chainId, indexerUrl)
191
194
  if (!chainIndexerUrl) {
192
195
  throw new Error(`Unsupported chain ID: ${chainId}`)
193
196
  }
@@ -217,7 +220,7 @@ export async function getAccountTransactionHistory({
217
220
  method: "POST",
218
221
  headers: {
219
222
  "Content-Type": "application/json",
220
- "X-Access-Key": accessKey,
223
+ "X-Access-Key": apiKey,
221
224
  },
222
225
  body: JSON.stringify(requestBody, bigintReplacer, 2),
223
226
  signal: abortSignal || operationAbortController.signal,
@@ -317,21 +320,24 @@ export type GetIntentTransactionHistoryParams = {
317
320
  }
318
321
 
319
322
  export async function getIntentTransactionHistory({
320
- accountAddress: _accountAddress,
323
+ accountAddress,
321
324
  pageSize = 10,
322
325
  page = 1,
323
- }: GetIntentTransactionHistoryParams): Promise<IntentTransactionHistoryResponse> {
324
- const accessKey = getSequenceProjectAccessKey()
325
-
326
- if (!accessKey) {
327
- throw new Error("Sequence project access key is required")
326
+ apiKey,
327
+ apiUrl,
328
+ }: GetIntentTransactionHistoryParams & {
329
+ apiKey: string
330
+ apiUrl: string
331
+ }): Promise<IntentTransactionHistoryResponse> {
332
+ if (!apiKey) {
333
+ throw new Error("Trails api key is required")
328
334
  }
329
335
 
330
336
  try {
331
- const trailsClient = getTrailsClient()
337
+ const trailsClient = getTrailsClient({ apiKey, hostname: apiUrl })
332
338
 
333
- // Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
334
- const result = await trailsClient.getIntentTransactionHistory({
339
+ const requestParams = {
340
+ byOwnerAddress: accountAddress,
335
341
  page: {
336
342
  pageSize,
337
343
  sort: [
@@ -341,25 +347,111 @@ export async function getIntentTransactionHistory({
341
347
  },
342
348
  ],
343
349
  },
350
+ }
351
+
352
+ logger.console.log(
353
+ "[trails-sdk] getIntentTransactionHistory request:",
354
+ requestParams,
355
+ )
356
+
357
+ // Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
358
+ const result = await trailsClient.getIntentTransactionHistory(requestParams)
359
+
360
+ logger.console.log("[trails-sdk] getIntentTransactionHistory response:", {
361
+ intentCount: result.intents?.length || 0,
362
+ hasNextPage: !!result.nextPage,
363
+ firstIntent: result.intents?.[0],
344
364
  })
345
365
 
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
366
+ // Map the API response to our local type structure
367
+ const mappedTransactions: IntentTransaction[] = (result.intents || []).map(
368
+ (intent: IntentSummary) => {
369
+ // Map API status to UI status format
370
+ const mapStatus = (apiStatus: string): string => {
371
+ const status = apiStatus?.toUpperCase() || "UNKNOWN"
372
+ switch (status) {
373
+ case "SUCCEEDED":
374
+ return "completed"
375
+ case "EXECUTING":
376
+ return "processing"
377
+ case "PENDING":
378
+ return "pending"
379
+ case "FAILED":
380
+ return "failed"
381
+ case "CREATED":
382
+ return "created"
383
+ default:
384
+ return apiStatus?.toLowerCase() || "unknown"
385
+ }
386
+ }
387
+
388
+ return {
389
+ originIntentAddress: intent.originIntentAddress,
390
+ destinationIntentAddress: intent.destinationIntentAddress,
391
+ mainSigner: intent.ownerAddress,
392
+ metaTxnId: intent.intentId,
393
+ txnHash:
394
+ intent.originTransactionHash ||
395
+ intent.destinationTransactionHash ||
396
+ undefined,
397
+ executionStatus: mapStatus(intent.status),
398
+ originChainId: intent.originChainId,
399
+ destinationChainId: intent.destinationChainId,
400
+ originTokenAddress: intent.originTokenAddress,
401
+ originTokenAmount: intent.originTokenAmount.toString(),
402
+ destinationTokenAddress: intent.destinationTokenAddress,
403
+ destinationTokenAmount: intent.destinationTokenAmount.toString(),
404
+ destinationToAddress: intent.ownerAddress,
405
+ createdAt: intent.createdAt,
406
+ // Map origin token metadata if available
407
+ originToken: intent.originTokenMetadata
408
+ ? ({
409
+ symbol: intent.originTokenMetadata.symbol || "",
410
+ name: intent.originTokenMetadata.name || "",
411
+ decimals: intent.originTokenMetadata.decimals ?? 18,
412
+ imageUrl: intent.originTokenMetadata.logoUri ?? "",
413
+ chainId: intent.originTokenMetadata.chainId,
414
+ } as {
415
+ symbol: string
416
+ name: string
417
+ decimals: number
418
+ imageUrl: string
419
+ chainId: number
420
+ })
421
+ : undefined,
422
+ // Map destination token metadata if available
423
+ destinationToken: intent.destinationTokenMetadata
424
+ ? ({
425
+ symbol: intent.destinationTokenMetadata.symbol || "",
426
+ name: intent.destinationTokenMetadata.name || "",
427
+ decimals: intent.destinationTokenMetadata.decimals ?? 18,
428
+ imageUrl: intent.destinationTokenMetadata.logoUri ?? "",
429
+ chainId: intent.destinationTokenMetadata.chainId,
430
+ } as {
431
+ symbol: string
432
+ name: string
433
+ decimals: number
434
+ imageUrl: string
435
+ chainId: number
436
+ })
437
+ : undefined,
438
+ }
439
+ },
440
+ )
441
+
350
442
  return {
351
443
  page: result.nextPage
352
444
  ? {
353
445
  page,
354
446
  pageSize,
355
- more: true,
447
+ more: result.nextPage.more || false,
356
448
  }
357
449
  : {
358
450
  page,
359
451
  pageSize,
360
452
  more: false,
361
453
  },
362
- transactions: [], // TODO: Map result.transactions to SDK IntentTransaction format
454
+ transactions: mappedTransactions,
363
455
  }
364
456
  } catch (error) {
365
457
  logger.console.error(
@@ -393,6 +485,7 @@ export function useAccountTransactionHistory({
393
485
  includeMetadata = true,
394
486
  abortSignal,
395
487
  }: UseAccountTransactionHistoryParams): UseAccountTransactionHistoryReturn {
488
+ const { trailsApiKey, sequenceIndexerUrl } = useTrails()
396
489
  const { data, isLoading, error } = useQuery({
397
490
  queryKey: [
398
491
  "accountTransactionHistory",
@@ -417,6 +510,8 @@ export function useAccountTransactionHistory({
417
510
  page,
418
511
  includeMetadata,
419
512
  abortSignal: effectiveSignal,
513
+ apiKey: trailsApiKey,
514
+ indexerUrl: sequenceIndexerUrl!,
420
515
  })
421
516
  },
422
517
  enabled: Boolean(chainId && accountAddress),
@@ -452,6 +547,7 @@ export function useIntentTransactionHistory({
452
547
  pageSize = 10,
453
548
  page = 1,
454
549
  }: UseIntentTransactionHistoryParams): UseIntentTransactionHistoryReturn {
550
+ const { trailsApiKey, trailsApiUrl } = useTrails()
455
551
  const { data, isLoading, error } = useQuery({
456
552
  queryKey: ["intentTransactionHistory", accountAddress, pageSize, page],
457
553
  queryFn: async () => {
@@ -463,6 +559,8 @@ export function useIntentTransactionHistory({
463
559
  accountAddress,
464
560
  pageSize,
465
561
  page,
562
+ apiKey: trailsApiKey,
563
+ apiUrl: trailsApiUrl!,
466
564
  })
467
565
  },
468
566
  enabled: Boolean(accountAddress),
package/src/wallets.ts CHANGED
@@ -1,7 +1,5 @@
1
- import {
2
- getSequenceProjectAccessKey,
3
- getWalletConnectProjectId,
4
- } from "./config.js"
1
+ import { getConfig } from "./config.js"
2
+ import { DEFAULT_WALLETCONNECT_PROJECT_ID } from "./constants.js"
5
3
  import WalletConnectLogo from "./widget/assets/WalletConnect-logo-blue-bg.svg"
6
4
  import SequenceLogo from "./widget/assets/sequence-logo.svg"
7
5
  import { Wallet as WalletIcon } from "lucide-react"
@@ -30,7 +28,8 @@ let wcConnectorSingleton: ReturnType<typeof walletConnect> | null = null
30
28
  function getWalletConnectConnectorSingleton() {
31
29
  if (!wcConnectorSingleton) {
32
30
  wcConnectorSingleton = walletConnect({
33
- projectId: getWalletConnectProjectId(),
31
+ projectId:
32
+ getConfig("walletConnectProjectId") || DEFAULT_WALLETCONNECT_PROJECT_ID,
34
33
  showQrModal: false,
35
34
  })
36
35
  }
@@ -149,7 +148,7 @@ export const coinbaseWalletConnector = windowProviderOrWalletConnect(
149
148
  export const sequenceConnector: any = sequenceWallet({
150
149
  connect: {
151
150
  app: "Trails",
152
- projectAccessKey: getSequenceProjectAccessKey(),
151
+ projectAccessKey: getConfig("trailsApiKey"),
153
152
  },
154
153
  defaultNetwork: 1,
155
154
  walletAppURL: "https://sequence.app",
@@ -259,6 +259,11 @@ export const AccountIntentTransactionHistory: React.FC<
259
259
  // Use selected wallet or fall back to accountAddress
260
260
  const effectiveAccountAddress = selectedWalletAddress || accountAddress
261
261
 
262
+ console.log(
263
+ "[AccountIntentTransactionHistory] Using account address:",
264
+ effectiveAccountAddress,
265
+ )
266
+
262
267
  const {
263
268
  transactions,
264
269
  loading,