0xtrails 0.1.13 → 0.2.1
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.
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +12 -2
- package/dist/analytics.d.ts.map +1 -1
- package/dist/apiClient.d.ts +1 -1
- package/dist/apiClient.d.ts.map +1 -1
- package/dist/{ccip-D3gTQONK.js → ccip-BbfANth7.js} +12 -12
- package/dist/cctp.d.ts.map +1 -1
- package/dist/cctpqueue.d.ts +3 -3
- package/dist/cctpqueue.d.ts.map +1 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +18 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts +2 -0
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/customChains.d.ts +24 -0
- package/dist/customChains.d.ts.map +1 -0
- package/dist/gasless.d.ts +19 -7
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-CnUM7lKf.js → index-WpIVoh3X.js} +36741 -31761
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +405 -394
- package/dist/indexerClient.d.ts +10 -0
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentEntrypoint.d.ts +122 -0
- package/dist/intentEntrypoint.d.ts.map +1 -0
- package/dist/intents.d.ts +5 -3
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/morpho.d.ts.map +1 -1
- package/dist/pools.d.ts +3 -1
- package/dist/pools.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +18 -9
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/toast.d.ts +9 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/tokenBalances.d.ts +6 -2
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +6 -5
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +12 -0
- package/dist/trailsClient.d.ts.map +1 -0
- package/dist/trailsRouter.d.ts +22 -0
- package/dist/trailsRouter.d.ts.map +1 -0
- package/dist/transactions.d.ts +8 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts +7 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -0
- package/dist/widget/components/ChainList.d.ts +0 -1
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +46 -0
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -0
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +9 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -0
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DebugToast.d.ts +3 -0
- package/dist/widget/components/DebugToast.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +22 -0
- package/dist/widget/components/FeeOption.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +13 -17
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +44 -0
- package/dist/widget/components/Fund.d.ts.map +1 -0
- package/dist/widget/components/FundMethods.d.ts +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts +9 -0
- package/dist/widget/components/Identicon.d.ts.map +1 -0
- package/dist/widget/components/MeshConnectExchanges.d.ts +5 -2
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +2 -0
- package/dist/widget/components/MeshConnectFlow.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts +12 -0
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +46 -0
- package/dist/widget/components/Pay.d.ts.map +1 -0
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts +9 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -0
- package/dist/widget/components/RefundWarning.d.ts +9 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -0
- package/dist/widget/components/SimpleSwap.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts +1 -5
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/ThemeSyncer.d.ts +6 -0
- package/dist/widget/components/ThemeSyncer.d.ts.map +1 -0
- package/dist/widget/components/Toast.d.ts +24 -0
- package/dist/widget/components/Toast.d.ts.map +1 -0
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TruncatedAddress.d.ts +2 -0
- package/dist/widget/components/TruncatedAddress.d.ts.map +1 -1
- package/dist/widget/components/UserPreferences.d.ts +7 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -0
- package/dist/widget/hooks/useBack.d.ts +2 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +54 -0
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -0
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts +34 -0
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -0
- package/dist/widget/hooks/useRecipients.d.ts +17 -0
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +32 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +14 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts +12 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +10 -13
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +13 -0
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useSwapSettings.d.ts +16 -0
- package/dist/widget/hooks/useSwapSettings.d.ts.map +1 -0
- package/dist/widget/hooks/useTargetAmount.d.ts +5 -0
- package/dist/widget/hooks/useTargetAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useTheme.d.ts +14 -0
- package/dist/widget/hooks/useTheme.d.ts.map +1 -0
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +38 -36
- package/src/aave.ts +6 -1
- package/src/analytics.ts +109 -53
- package/src/apiClient.ts +1 -1
- package/src/cctp.ts +6 -2
- package/src/cctpqueue.ts +7 -7
- package/src/chains.ts +18 -0
- package/src/config.ts +63 -17
- package/src/constants.ts +20 -16
- package/src/contractUtils.ts +33 -2
- package/src/customChains.ts +24 -0
- package/src/gasless.ts +162 -109
- package/src/index.ts +11 -1
- package/src/indexerClient.ts +73 -1
- package/src/intentEntrypoint.ts +218 -0
- package/src/intents.ts +85 -54
- package/src/metaTxnMonitor.ts +1 -0
- package/src/morpho.ts +13 -2
- package/src/pools.ts +68 -86
- package/src/prepareSend.ts +1719 -967
- package/src/prices.ts +51 -7
- package/src/relaySdk.ts +6 -4
- package/src/relayer.ts +6 -3
- package/src/toast.ts +110 -0
- package/src/tokenBalances.ts +112 -20
- package/src/tokens.ts +70 -7
- package/src/trails.ts +81 -80
- package/src/trailsClient.ts +48 -0
- package/src/{proxyCaller.ts → trailsRouter.ts} +25 -20
- package/src/transactions.ts +30 -88
- package/src/umd.tsx +1 -1
- package/src/wallets.ts +2 -1
- package/src/widget/assets/sequence-logo.svg +15 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +18 -159
- package/src/widget/components/AccountIntentTransactionHistory.tsx +346 -63
- package/src/widget/components/AccountSettings.tsx +102 -0
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +10 -20
- package/src/widget/components/ClassicSwap.tsx +921 -0
- package/src/widget/components/ConfigDisplay.tsx +41 -5
- package/src/widget/components/ConnectWallet.tsx +168 -11
- package/src/widget/components/ConnectedWallets.tsx +342 -0
- package/src/widget/components/DebugMenu.tsx +2 -0
- package/src/widget/components/DebugScreensList.tsx +3 -0
- package/src/widget/components/DebugToast.tsx +63 -0
- package/src/widget/components/Earn.tsx +112 -143
- package/src/widget/components/EarnPools.tsx +2 -4
- package/src/widget/components/EarnPoolsFilters.tsx +6 -6
- package/src/widget/components/FeeOption.tsx +78 -0
- package/src/widget/components/FeeOptions.tsx +192 -127
- package/src/widget/components/Fund.tsx +1236 -0
- package/src/widget/components/FundMethods.tsx +4 -4
- package/src/widget/components/FundSendForm.tsx +1 -34
- package/src/widget/components/Identicon.tsx +158 -0
- package/src/widget/components/MeshConnectExchanges.tsx +32 -3
- package/src/widget/components/MeshConnectFlow.tsx +23 -4
- package/src/widget/components/NativeGasOption.tsx +99 -0
- package/src/widget/components/Pay.tsx +1092 -0
- package/src/widget/components/PaySendForm.tsx +1 -38
- package/src/widget/components/QuoteDetails.tsx +1 -30
- package/src/widget/components/Receipt.tsx +1 -1
- package/src/widget/components/Receive.tsx +4 -2
- package/src/widget/components/RecentTokens.tsx +2 -1
- package/src/widget/components/Recipients.tsx +448 -0
- package/src/widget/components/RefundWarning.tsx +61 -0
- package/src/widget/components/ScreenHeader.tsx +1 -1
- package/src/widget/components/SimpleSwap.tsx +74 -58
- package/src/widget/components/Swap.tsx +35 -853
- package/src/widget/components/SwapSettings.tsx +5 -11
- package/src/widget/components/ThemeProvider.tsx +32 -0
- package/src/widget/components/ThemeSyncer.tsx +47 -0
- package/src/widget/components/Toast.tsx +315 -0
- package/src/widget/components/TokenList.tsx +2 -34
- package/src/widget/components/TokenSelector.tsx +14 -3
- package/src/widget/components/TransactionDetails.tsx +153 -13
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/TruncatedAddress.tsx +5 -1
- package/src/widget/components/UserPreferences.tsx +155 -0
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/hooks/useBack.tsx +4 -0
- package/src/widget/hooks/useBalanceVisible.tsx +40 -2
- package/src/widget/hooks/useCheckout.ts +13 -0
- package/src/widget/hooks/useCurrentScreen.tsx +4 -0
- package/src/widget/hooks/useDebugScreens.ts +12 -2
- package/src/widget/hooks/useDefaultTokenSelection.tsx +471 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +212 -0
- package/src/widget/hooks/usePayMessage.tsx +370 -0
- package/src/widget/hooks/useRecipients.ts +168 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +299 -0
- package/src/widget/hooks/useSelectedMeshExchange.tsx +46 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +48 -0
- package/src/widget/hooks/useSendForm.ts +257 -49
- package/src/widget/hooks/useSwapAmount.tsx +50 -0
- package/src/widget/hooks/useSwapSettings.tsx +100 -0
- package/src/widget/hooks/useTargetAmount.ts +23 -0
- package/src/widget/hooks/useTheme.tsx +80 -0
- package/src/widget/hooks/useTokenList.ts +20 -11
- package/src/widget/index.css +45 -21
- package/src/widget/widget.tsx +294 -136
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- package/dist/proxyCaller.d.ts +0 -21
- package/dist/proxyCaller.d.ts.map +0 -1
- package/src/address.ts +0 -6
package/src/trails.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
IntentCallsPayload,
|
|
6
6
|
IntentPrecondition,
|
|
7
7
|
} from "@0xsequence/trails-api"
|
|
8
|
-
import type {
|
|
8
|
+
import type { TrailsClient } from "./trailsClient.js"
|
|
9
9
|
import type { Relayer } from "@0xsequence/wallet-core"
|
|
10
10
|
import { useMutation, useQuery } from "@tanstack/react-query"
|
|
11
11
|
import { Address } from "ox"
|
|
@@ -27,14 +27,9 @@ import {
|
|
|
27
27
|
useSwitchChain,
|
|
28
28
|
useWaitForTransactionReceipt,
|
|
29
29
|
} from "wagmi"
|
|
30
|
-
import {
|
|
30
|
+
import { useTrailsClient } from "./trailsClient.js"
|
|
31
31
|
import { attemptSwitchChain } from "./chainSwitch.js"
|
|
32
32
|
import { getChainInfo } from "./chains.js"
|
|
33
|
-
import {
|
|
34
|
-
TRAILS_CCTP_SAPIENT_SIGNER_ADDRESS,
|
|
35
|
-
TRAILS_LIFI_SAPIENT_SIGNER_ADDRESS,
|
|
36
|
-
TRAILS_RELAY_SAPIENT_SIGNER_ADDRESS,
|
|
37
|
-
} from "./constants.js"
|
|
38
33
|
import { getERC20TransferData } from "./encoders.js"
|
|
39
34
|
import type {
|
|
40
35
|
GetIntentCallsPayloadsReturn,
|
|
@@ -53,6 +48,7 @@ import { findPreconditionAddresses } from "./preconditions.js"
|
|
|
53
48
|
import { getBackupRelayer, useRelayers } from "./relayer.js"
|
|
54
49
|
import { queueCCTPTransfer } from "./cctpqueue.js"
|
|
55
50
|
import { logger } from "./logger.js"
|
|
51
|
+
import { SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES } from "./constants.js"
|
|
56
52
|
|
|
57
53
|
export type WagmiAccount = {
|
|
58
54
|
address: `0x${string}`
|
|
@@ -69,10 +65,12 @@ export type UseTrailsConfig = {
|
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
export type UseTrailsReturn = {
|
|
72
|
-
|
|
73
|
-
metaTxns: GetIntentCallsPayloadsReturn["metaTxns"] | null
|
|
74
|
-
intentCallsPayloads: GetIntentCallsPayloadsReturn["calls"] | null
|
|
75
|
-
intentPreconditions:
|
|
68
|
+
trailsClient: TrailsClient
|
|
69
|
+
metaTxns: GetIntentCallsPayloadsReturn["payloads"]["metaTxns"] | null
|
|
70
|
+
intentCallsPayloads: GetIntentCallsPayloadsReturn["payloads"]["calls"] | null
|
|
71
|
+
intentPreconditions:
|
|
72
|
+
| GetIntentCallsPayloadsReturn["payloads"]["preconditions"]
|
|
73
|
+
| null
|
|
76
74
|
trailsFee: TrailsFee | null
|
|
77
75
|
txnHash: Hex | undefined
|
|
78
76
|
committedOriginIntentAddress: string | null
|
|
@@ -183,7 +181,9 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
183
181
|
env,
|
|
184
182
|
sequenceProjectAccessKey,
|
|
185
183
|
} = config
|
|
186
|
-
const
|
|
184
|
+
const trailsClient = useTrailsClient({
|
|
185
|
+
projectAccessKey: sequenceProjectAccessKey,
|
|
186
|
+
})
|
|
187
187
|
|
|
188
188
|
const [isAutoExecute, setIsAutoExecute] = useState(!disableAutoExecute)
|
|
189
189
|
const [hasAutoExecuted, setHasAutoExecuted] = useState(false)
|
|
@@ -195,13 +195,13 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
195
195
|
|
|
196
196
|
// State declarations
|
|
197
197
|
const [metaTxns, setMetaTxns] = useState<
|
|
198
|
-
GetIntentCallsPayloadsReturn["metaTxns"] | null
|
|
198
|
+
GetIntentCallsPayloadsReturn["payloads"]["metaTxns"] | null
|
|
199
199
|
>(null)
|
|
200
200
|
const [intentCallsPayloads, setIntentCallsPayloads] = useState<
|
|
201
|
-
GetIntentCallsPayloadsReturn["calls"] | null
|
|
201
|
+
GetIntentCallsPayloadsReturn["payloads"]["calls"] | null
|
|
202
202
|
>(null)
|
|
203
203
|
const [intentPreconditions, setIntentPreconditions] = useState<
|
|
204
|
-
GetIntentCallsPayloadsReturn["preconditions"] | null
|
|
204
|
+
GetIntentCallsPayloadsReturn["payloads"]["preconditions"] | null
|
|
205
205
|
>(null)
|
|
206
206
|
const [trailsFee, setTrailsFee] = useState<TrailsFee | null>(null)
|
|
207
207
|
const [txnHash, setTxnHash] = useState<Hex | undefined>()
|
|
@@ -291,7 +291,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
291
291
|
"[useTrails] commitIntentConfigMutation started with args:",
|
|
292
292
|
args,
|
|
293
293
|
)
|
|
294
|
-
if (!
|
|
294
|
+
if (!trailsClient) {
|
|
295
295
|
logger.console.error("[useTrails] API client not available")
|
|
296
296
|
throw new Error("API client not available")
|
|
297
297
|
}
|
|
@@ -305,9 +305,10 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
305
305
|
logger.console.log("[useTrails] Main signer:", args.mainSignerAddress)
|
|
306
306
|
logger.console.log("[useTrails] Calls:", args.calls)
|
|
307
307
|
|
|
308
|
-
const originChainId =
|
|
308
|
+
const originChainId =
|
|
309
|
+
createIntentMutation.variables?.params.originChainId
|
|
309
310
|
const destinationChainId =
|
|
310
|
-
createIntentMutation.variables?.destinationChainId
|
|
311
|
+
createIntentMutation.variables?.params.destinationChainId
|
|
311
312
|
|
|
312
313
|
if (!originChainId || !destinationChainId) {
|
|
313
314
|
logger.console.error(
|
|
@@ -388,19 +389,17 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
388
389
|
|
|
389
390
|
// Commit the intent config
|
|
390
391
|
logger.console.log("[useTrails] Committing intent config to API...")
|
|
391
|
-
const response = await
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
TRAILS_CCTP_SAPIENT_SIGNER_ADDRESS,
|
|
403
|
-
...args.addressOverrides,
|
|
392
|
+
const response = await trailsClient.commitIntentConfig({
|
|
393
|
+
params: {
|
|
394
|
+
originIntentAddress: originIntentAddress.toString(),
|
|
395
|
+
destinationIntentAddress: destinationIntentAddress.toString(),
|
|
396
|
+
mainSigner: args.mainSignerAddress,
|
|
397
|
+
calls: args.calls,
|
|
398
|
+
preconditions: args.preconditions,
|
|
399
|
+
addressOverrides: {
|
|
400
|
+
...SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES,
|
|
401
|
+
...args.addressOverrides,
|
|
402
|
+
},
|
|
404
403
|
},
|
|
405
404
|
})
|
|
406
405
|
logger.console.log("[useTrails] API Commit Response:", response)
|
|
@@ -441,33 +440,33 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
441
440
|
} = useQuery<GetIntentConfigReturn, Error>({
|
|
442
441
|
queryKey: ["getIntentConfig", committedOriginIntentAddress],
|
|
443
442
|
queryFn: async () => {
|
|
444
|
-
if (!
|
|
443
|
+
if (!trailsClient || !committedOriginIntentAddress) {
|
|
445
444
|
throw new Error("API client or committed intent address not available")
|
|
446
445
|
}
|
|
447
446
|
logger.console.log(
|
|
448
447
|
"Fetching intent config for address:",
|
|
449
448
|
committedOriginIntentAddress,
|
|
450
449
|
)
|
|
451
|
-
return await
|
|
450
|
+
return await trailsClient.getIntentConfig({
|
|
452
451
|
intentAddress: committedOriginIntentAddress,
|
|
453
452
|
})
|
|
454
453
|
},
|
|
455
454
|
enabled:
|
|
456
455
|
!!committedOriginIntentAddress &&
|
|
457
|
-
!!
|
|
456
|
+
!!trailsClient &&
|
|
458
457
|
commitIntentConfigMutation.isSuccess,
|
|
459
458
|
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
460
459
|
retry: 1,
|
|
461
460
|
})
|
|
462
461
|
|
|
463
462
|
async function getIntentCallsPayloads(args: GetIntentCallsPayloadsArgs) {
|
|
464
|
-
return getIntentCallsPayloadsFromIntents(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
463
|
+
return getIntentCallsPayloadsFromIntents(trailsClient, {
|
|
464
|
+
params: {
|
|
465
|
+
...args.params,
|
|
466
|
+
addressOverrides: {
|
|
467
|
+
...SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES,
|
|
468
|
+
...args.params.addressOverrides,
|
|
469
|
+
},
|
|
471
470
|
},
|
|
472
471
|
})
|
|
473
472
|
}
|
|
@@ -480,10 +479,10 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
480
479
|
>({
|
|
481
480
|
mutationFn: async (args: GetIntentCallsPayloadsArgs) => {
|
|
482
481
|
if (
|
|
483
|
-
args.originChainId === args.destinationChainId &&
|
|
482
|
+
args.params.originChainId === args.params.destinationChainId &&
|
|
484
483
|
isAddressEqual(
|
|
485
|
-
Address.from(args.originTokenAddress),
|
|
486
|
-
Address.from(args.destinationTokenAddress),
|
|
484
|
+
Address.from(args.params.originTokenAddress),
|
|
485
|
+
Address.from(args.params.destinationTokenAddress),
|
|
487
486
|
)
|
|
488
487
|
) {
|
|
489
488
|
throw new Error(
|
|
@@ -506,12 +505,12 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
506
505
|
|
|
507
506
|
const data = await getIntentCallsPayloads(args)
|
|
508
507
|
|
|
509
|
-
setMetaTxns(data.metaTxns)
|
|
510
|
-
setIntentCallsPayloads(data.calls)
|
|
511
|
-
setIntentPreconditions(data.preconditions)
|
|
512
|
-
setTrailsFee(data.trailsFee!)
|
|
513
|
-
setOriginIntentAddress(data.originIntentAddress)
|
|
514
|
-
setDestinationIntentAddress(data.destinationIntentAddress)
|
|
508
|
+
setMetaTxns(data.payloads.metaTxns)
|
|
509
|
+
setIntentCallsPayloads(data.payloads.calls)
|
|
510
|
+
setIntentPreconditions(data.payloads.preconditions)
|
|
511
|
+
setTrailsFee(data.payloads.trailsFee!)
|
|
512
|
+
setOriginIntentAddress(data.payloads.originIntentAddress)
|
|
513
|
+
setDestinationIntentAddress(data.payloads.destinationIntentAddress)
|
|
515
514
|
setCommittedOriginIntentAddress(null)
|
|
516
515
|
setCommittedDestinationIntentAddress(null)
|
|
517
516
|
|
|
@@ -521,21 +520,21 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
521
520
|
onSuccess: (data) => {
|
|
522
521
|
logger.console.log("Intent Config Success:", data)
|
|
523
522
|
|
|
524
|
-
setTrailsFee(data.trailsFee || null)
|
|
525
|
-
setOriginIntentAddress(data.originIntentAddress)
|
|
526
|
-
setDestinationIntentAddress(data.destinationIntentAddress)
|
|
523
|
+
setTrailsFee(data.payloads.trailsFee || null)
|
|
524
|
+
setOriginIntentAddress(data.payloads.originIntentAddress)
|
|
525
|
+
setDestinationIntentAddress(data.payloads.destinationIntentAddress)
|
|
527
526
|
|
|
528
527
|
if (
|
|
529
|
-
data?.calls &&
|
|
530
|
-
data.calls.length > 0 &&
|
|
531
|
-
data.preconditions &&
|
|
532
|
-
data.preconditions.length > 0 &&
|
|
533
|
-
data.metaTxns &&
|
|
534
|
-
data.metaTxns.length > 0
|
|
528
|
+
data.payloads?.calls &&
|
|
529
|
+
data.payloads.calls.length > 0 &&
|
|
530
|
+
data.payloads.preconditions &&
|
|
531
|
+
data.payloads.preconditions.length > 0 &&
|
|
532
|
+
data.payloads.metaTxns &&
|
|
533
|
+
data.payloads.metaTxns.length > 0
|
|
535
534
|
) {
|
|
536
|
-
setIntentCallsPayloads(data.calls)
|
|
537
|
-
setIntentPreconditions(data.preconditions)
|
|
538
|
-
setMetaTxns(data.metaTxns)
|
|
535
|
+
setIntentCallsPayloads(data.payloads.calls)
|
|
536
|
+
setIntentPreconditions(data.payloads.preconditions)
|
|
537
|
+
setMetaTxns(data.payloads.metaTxns)
|
|
539
538
|
} else {
|
|
540
539
|
logger.console.warn("API returned success but no operations found.")
|
|
541
540
|
setIntentCallsPayloads(null)
|
|
@@ -1033,7 +1032,8 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1033
1032
|
calls: intentCallsPayloads,
|
|
1034
1033
|
preconditions: intentPreconditions,
|
|
1035
1034
|
quoteProvider: trailsFee.quoteProvider as QuoteProvider,
|
|
1036
|
-
addressOverrides:
|
|
1035
|
+
addressOverrides:
|
|
1036
|
+
createIntentMutation.variables?.params.addressOverrides,
|
|
1037
1037
|
})
|
|
1038
1038
|
}
|
|
1039
1039
|
}, [
|
|
@@ -1341,9 +1341,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1341
1341
|
(p.type === "transfer-native" || p.type === "native-balance") &&
|
|
1342
1342
|
p.chainId === originChainId.toString(),
|
|
1343
1343
|
)
|
|
1344
|
-
const nativeMinAmount =
|
|
1345
|
-
nativePrecondition?.data?.minAmount?.toString() ??
|
|
1346
|
-
nativePrecondition?.data?.min?.toString()
|
|
1344
|
+
const nativeMinAmount = nativePrecondition?.data?.min?.toString()
|
|
1347
1345
|
if (nativeMinAmount === undefined) {
|
|
1348
1346
|
throw new Error(
|
|
1349
1347
|
"Could not find native precondition (transfer-native or native-balance) or min amount",
|
|
@@ -1571,16 +1569,19 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1571
1569
|
const providerFromQuote = trailsFee?.quoteProvider
|
|
1572
1570
|
? String(trailsFee.quoteProvider).toLowerCase()
|
|
1573
1571
|
: undefined
|
|
1574
|
-
const providerFromArgs = createIntentMutation.variables?.
|
|
1575
|
-
|
|
1572
|
+
const providerFromArgs = createIntentMutation.variables?.params
|
|
1573
|
+
.provider
|
|
1574
|
+
? String(
|
|
1575
|
+
createIntentMutation.variables.params.provider,
|
|
1576
|
+
).toLowerCase()
|
|
1576
1577
|
: undefined
|
|
1577
1578
|
const isCctp =
|
|
1578
1579
|
providerFromQuote === "cctp" || providerFromArgs === "cctp"
|
|
1579
1580
|
|
|
1580
1581
|
const originChainIdForCctp =
|
|
1581
|
-
createIntentMutation.variables?.originChainId
|
|
1582
|
+
createIntentMutation.variables?.params.originChainId
|
|
1582
1583
|
const destinationChainIdForCctp =
|
|
1583
|
-
createIntentMutation.variables?.destinationChainId
|
|
1584
|
+
createIntentMutation.variables?.params.destinationChainId
|
|
1584
1585
|
|
|
1585
1586
|
logger.console.log("[Trails] isCctp", isCctp)
|
|
1586
1587
|
logger.console.log("[Trails] providerFromQuote", providerFromQuote)
|
|
@@ -1591,16 +1592,16 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1591
1592
|
createIntentMutation.variables,
|
|
1592
1593
|
)
|
|
1593
1594
|
logger.console.log(
|
|
1594
|
-
"[Trails] createIntentMutation.variables.provider",
|
|
1595
|
-
createIntentMutation.variables?.provider,
|
|
1595
|
+
"[Trails] createIntentMutation.variables.params.provider",
|
|
1596
|
+
createIntentMutation.variables?.params.provider,
|
|
1596
1597
|
)
|
|
1597
1598
|
logger.console.log(
|
|
1598
|
-
"[Trails] createIntentMutation.variables.originChainId",
|
|
1599
|
-
createIntentMutation.variables?.originChainId,
|
|
1599
|
+
"[Trails] createIntentMutation.variables.params.originChainId",
|
|
1600
|
+
createIntentMutation.variables?.params.originChainId,
|
|
1600
1601
|
)
|
|
1601
1602
|
logger.console.log(
|
|
1602
|
-
"[Trails] createIntentMutation.variables.destinationChainId",
|
|
1603
|
-
createIntentMutation.variables?.destinationChainId,
|
|
1603
|
+
"[Trails] createIntentMutation.variables.params.destinationChainId",
|
|
1604
|
+
createIntentMutation.variables?.params.destinationChainId,
|
|
1604
1605
|
)
|
|
1605
1606
|
logger.console.log(
|
|
1606
1607
|
"[Trails] lastQueuedCctpSourceTxHash",
|
|
@@ -1618,7 +1619,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1618
1619
|
|
|
1619
1620
|
if (
|
|
1620
1621
|
isCctp &&
|
|
1621
|
-
|
|
1622
|
+
trailsClient &&
|
|
1622
1623
|
transactionHash &&
|
|
1623
1624
|
typeof originChainIdForCctp === "number" &&
|
|
1624
1625
|
typeof destinationChainIdForCctp === "number" &&
|
|
@@ -1627,7 +1628,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1627
1628
|
) {
|
|
1628
1629
|
lastQueuedCctpSourceTxHash.current = transactionHash
|
|
1629
1630
|
await queueCCTPTransfer({
|
|
1630
|
-
|
|
1631
|
+
trailsClient,
|
|
1631
1632
|
sourceTxHash: transactionHash,
|
|
1632
1633
|
sourceChainId: originChainIdForCctp,
|
|
1633
1634
|
destinationChainId: destinationChainIdForCctp,
|
|
@@ -1671,7 +1672,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1671
1672
|
metaTxnBlockTimestamps,
|
|
1672
1673
|
trailsFee,
|
|
1673
1674
|
createIntentMutation.variables,
|
|
1674
|
-
|
|
1675
|
+
trailsClient,
|
|
1675
1676
|
])
|
|
1676
1677
|
|
|
1677
1678
|
const updateAutoExecute = (enabled: boolean) => {
|
|
@@ -1732,7 +1733,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1732
1733
|
const sendMetaTxnArgs = sendMetaTxnMutation.variables
|
|
1733
1734
|
|
|
1734
1735
|
return {
|
|
1735
|
-
|
|
1736
|
+
trailsClient,
|
|
1736
1737
|
metaTxns,
|
|
1737
1738
|
intentCallsPayloads,
|
|
1738
1739
|
intentPreconditions,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useConfig } from "@0xsequence/hooks"
|
|
2
|
+
import { TrailsAPIClient } from "@0xsequence/trails-api"
|
|
3
|
+
import { useMemo } from "react"
|
|
4
|
+
import { getTrailsApiUrl, getSequenceProjectAccessKey } from "./config.js"
|
|
5
|
+
|
|
6
|
+
export type TrailsClientConfig = {
|
|
7
|
+
hostname?: string
|
|
8
|
+
projectAccessKey?: string
|
|
9
|
+
jwt?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Trails client for interacting with Trails APIs only
|
|
13
|
+
export class TrailsClient extends TrailsAPIClient {
|
|
14
|
+
constructor(hostname?: string, projectAccessKey?: string, jwt?: string) {
|
|
15
|
+
super(hostname || getTrailsApiUrl(), projectAccessKey, jwt)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getTrailsClient({
|
|
20
|
+
hostname,
|
|
21
|
+
projectAccessKey = getSequenceProjectAccessKey(),
|
|
22
|
+
jwt,
|
|
23
|
+
}: TrailsClientConfig = {}): TrailsClient {
|
|
24
|
+
return new TrailsClient(hostname, projectAccessKey, jwt)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const useTrailsClient = (config?: TrailsClientConfig) => {
|
|
28
|
+
const { projectAccessKey, jwt } = useConfig()
|
|
29
|
+
|
|
30
|
+
const trailsClient = useMemo(() => {
|
|
31
|
+
return getTrailsClient({
|
|
32
|
+
hostname: config?.hostname || getTrailsApiUrl(),
|
|
33
|
+
projectAccessKey:
|
|
34
|
+
getSequenceProjectAccessKey() ||
|
|
35
|
+
config?.projectAccessKey ||
|
|
36
|
+
projectAccessKey,
|
|
37
|
+
jwt: config?.jwt || jwt,
|
|
38
|
+
})
|
|
39
|
+
}, [
|
|
40
|
+
config?.hostname,
|
|
41
|
+
config?.projectAccessKey,
|
|
42
|
+
config?.jwt,
|
|
43
|
+
projectAccessKey,
|
|
44
|
+
jwt,
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
return trailsClient
|
|
48
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { encodeFunctionData } from "viem"
|
|
2
|
-
import {
|
|
1
|
+
import { encodeFunctionData, zeroAddress } from "viem"
|
|
2
|
+
import { TRAILS_ROUTER_ADDRESS } from "./constants.js"
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const TRAILS_ROUTER_PLACEHOLDER_AMOUNT =
|
|
5
5
|
0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefn
|
|
6
6
|
|
|
7
7
|
function getAmountOffset(calldata: `0x${string}`, placeholder: bigint): number {
|
|
@@ -14,10 +14,10 @@ function getAmountOffset(calldata: `0x${string}`, placeholder: bigint): number {
|
|
|
14
14
|
return byteOffset
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const trailsRouterAbi = [
|
|
18
18
|
{
|
|
19
19
|
type: "function",
|
|
20
|
-
name: "
|
|
20
|
+
name: "injectAndCall",
|
|
21
21
|
stateMutability: "nonpayable",
|
|
22
22
|
inputs: [
|
|
23
23
|
{ name: "token", type: "address" },
|
|
@@ -30,29 +30,31 @@ const proxyCallerAbi = [
|
|
|
30
30
|
},
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
-
export function
|
|
33
|
+
export function encodeTrailsRouterCalldata({
|
|
34
34
|
token,
|
|
35
35
|
target,
|
|
36
36
|
calldata,
|
|
37
37
|
amountOffset,
|
|
38
|
+
placeholder,
|
|
38
39
|
}: {
|
|
39
40
|
token: string
|
|
40
41
|
target: string
|
|
41
42
|
calldata: `0x${string}`
|
|
42
43
|
amountOffset: number
|
|
44
|
+
placeholder: bigint
|
|
43
45
|
}) {
|
|
44
46
|
// Convert BigInt to bytes32 format
|
|
45
47
|
const placeholderBytes32 =
|
|
46
|
-
`0x${
|
|
48
|
+
`0x${placeholder.toString(16).padStart(64, "0")}` as `0x${string}`
|
|
47
49
|
|
|
48
50
|
return encodeFunctionData({
|
|
49
|
-
abi:
|
|
50
|
-
functionName: "
|
|
51
|
+
abi: trailsRouterAbi,
|
|
52
|
+
functionName: "injectAndCall",
|
|
51
53
|
args: [token, target, calldata, amountOffset, placeholderBytes32],
|
|
52
54
|
})
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
export function
|
|
57
|
+
export function wrapCalldataWithTrailsRouterIfNeeded({
|
|
56
58
|
token,
|
|
57
59
|
target,
|
|
58
60
|
calldata,
|
|
@@ -70,12 +72,13 @@ export function wrapCalldataWithProxyCallerIfNeeded({
|
|
|
70
72
|
amount: string
|
|
71
73
|
originTokenAddress: string
|
|
72
74
|
destinationTokenAddress: string
|
|
73
|
-
}): { encodedCalldata: `0x${string}`;
|
|
75
|
+
}): { encodedCalldata: `0x${string}`; trailsRouterAddress: string } | null {
|
|
74
76
|
const isSameToken =
|
|
75
77
|
originTokenAddress?.toLowerCase() === destinationTokenAddress?.toLowerCase()
|
|
78
|
+
const isDestinationNativeToken = destinationTokenAddress === zeroAddress
|
|
76
79
|
if (originChainId === destinationChainId && isSameToken) {
|
|
77
80
|
const amountHex = BigInt(amount).toString(16).padStart(64, "0") // 32-byte hex (no 0x)
|
|
78
|
-
const placeholderHex =
|
|
81
|
+
const placeholderHex = TRAILS_ROUTER_PLACEHOLDER_AMOUNT.toString(
|
|
79
82
|
16,
|
|
80
83
|
).padStart(64, "0")
|
|
81
84
|
|
|
@@ -86,29 +89,31 @@ export function wrapCalldataWithProxyCallerIfNeeded({
|
|
|
86
89
|
const calldataWithAmount = calldata.replace(placeholderHex, amountHex)
|
|
87
90
|
return {
|
|
88
91
|
encodedCalldata: calldataWithAmount as `0x${string}`,
|
|
89
|
-
|
|
92
|
+
trailsRouterAddress: target,
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
const
|
|
96
|
+
const trailsRouterAddress = TRAILS_ROUTER_ADDRESS
|
|
94
97
|
|
|
95
|
-
const amountOffset =
|
|
96
|
-
|
|
97
|
-
BigInt(
|
|
98
|
-
)
|
|
98
|
+
const amountOffset = isDestinationNativeToken
|
|
99
|
+
? 0
|
|
100
|
+
: getAmountOffset(calldata, BigInt(TRAILS_ROUTER_PLACEHOLDER_AMOUNT))
|
|
99
101
|
if (amountOffset === -1) {
|
|
100
102
|
return null
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
const encodedCalldata =
|
|
105
|
+
const encodedCalldata = encodeTrailsRouterCalldata({
|
|
104
106
|
token,
|
|
105
107
|
target,
|
|
106
108
|
calldata,
|
|
107
109
|
amountOffset,
|
|
110
|
+
placeholder: isDestinationNativeToken
|
|
111
|
+
? BigInt(0)
|
|
112
|
+
: TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
|
|
108
113
|
})
|
|
109
114
|
|
|
110
115
|
return {
|
|
111
116
|
encodedCalldata,
|
|
112
|
-
|
|
117
|
+
trailsRouterAddress,
|
|
113
118
|
}
|
|
114
119
|
}
|
package/src/transactions.ts
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
import { createPublicClient, http } from "viem"
|
|
2
2
|
import { useQuery } from "@tanstack/react-query"
|
|
3
3
|
import { getChainInfo } from "./chains.js"
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
getSequenceEnv,
|
|
7
|
-
getSequenceApiUrl,
|
|
8
|
-
} from "./config.js"
|
|
4
|
+
import { getSequenceProjectAccessKey } from "./config.js"
|
|
5
|
+
import { getTrailsClient } from "./trailsClient.js"
|
|
9
6
|
import type { GuestModuleEvent, TrailsTokenSweeperEvent } from "./decoders.js"
|
|
10
|
-
import {
|
|
11
|
-
arbitrum,
|
|
12
|
-
base,
|
|
13
|
-
baseSepolia,
|
|
14
|
-
optimism,
|
|
15
|
-
polygon,
|
|
16
|
-
mainnet,
|
|
17
|
-
apeChain,
|
|
18
|
-
arbitrumNova,
|
|
19
|
-
avalanche,
|
|
20
|
-
b3,
|
|
21
|
-
blast,
|
|
22
|
-
gnosis,
|
|
23
|
-
soneium,
|
|
24
|
-
xai,
|
|
25
|
-
bsc,
|
|
26
|
-
etherlink,
|
|
27
|
-
katana,
|
|
28
|
-
} from "viem/chains"
|
|
29
7
|
import { logger } from "./logger.js"
|
|
30
8
|
import { bigintReplacer } from "./utils.js"
|
|
31
9
|
import { getExplorerUrl } from "./explorer.js"
|
|
10
|
+
import { SortOrder } from "@0xsequence/trails-api"
|
|
11
|
+
import { getChainIndexerUrl } from "./indexerClient.js"
|
|
32
12
|
|
|
33
13
|
export type TransactionStateStatus =
|
|
34
14
|
| "pending"
|
|
@@ -204,43 +184,12 @@ export async function getTxTimeDiff(
|
|
|
204
184
|
}
|
|
205
185
|
}
|
|
206
186
|
|
|
207
|
-
export function getIndexerUrlFromChainSlug(chainSlug: string) {
|
|
208
|
-
const env = getSequenceEnv()
|
|
209
|
-
let envPrefix = ""
|
|
210
|
-
|
|
211
|
-
if (env === "dev") {
|
|
212
|
-
envPrefix = "dev-"
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return `https://${envPrefix}${chainSlug}-indexer.sequence.app`
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const chainIdToIndexerUrl = {
|
|
219
|
-
[arbitrum.id]: getIndexerUrlFromChainSlug("arbitrum"),
|
|
220
|
-
[base.id]: getIndexerUrlFromChainSlug("base"),
|
|
221
|
-
[baseSepolia.id]: getIndexerUrlFromChainSlug("base-sepolia"),
|
|
222
|
-
[optimism.id]: getIndexerUrlFromChainSlug("optimism"),
|
|
223
|
-
[polygon.id]: getIndexerUrlFromChainSlug("polygon"),
|
|
224
|
-
[mainnet.id]: getIndexerUrlFromChainSlug("mainnet"),
|
|
225
|
-
[apeChain.id]: getIndexerUrlFromChainSlug("apechain"),
|
|
226
|
-
[arbitrumNova.id]: getIndexerUrlFromChainSlug("arbitrum-nova"),
|
|
227
|
-
[avalanche.id]: getIndexerUrlFromChainSlug("avalanche"),
|
|
228
|
-
[b3.id]: getIndexerUrlFromChainSlug("b3"),
|
|
229
|
-
[blast.id]: getIndexerUrlFromChainSlug("blast"),
|
|
230
|
-
[gnosis.id]: getIndexerUrlFromChainSlug("gnosis"),
|
|
231
|
-
[soneium.id]: getIndexerUrlFromChainSlug("soneium"),
|
|
232
|
-
[xai.id]: getIndexerUrlFromChainSlug("xai"),
|
|
233
|
-
[bsc.id]: getIndexerUrlFromChainSlug("bsc"),
|
|
234
|
-
421613: getIndexerUrlFromChainSlug("arbitrum-nova-sepolia"),
|
|
235
|
-
[etherlink.id]: getIndexerUrlFromChainSlug("etherlink"),
|
|
236
|
-
[katana.id]: getIndexerUrlFromChainSlug("katana"),
|
|
237
|
-
}
|
|
238
|
-
|
|
239
187
|
export async function getAccountTransactionHistory({
|
|
240
188
|
chainId,
|
|
241
189
|
accountAddress,
|
|
242
190
|
pageSize = 10,
|
|
243
191
|
page = 1,
|
|
192
|
+
|
|
244
193
|
includeMetadata = true,
|
|
245
194
|
}: GetAccountTransactionHistoryParams): Promise<TransactionHistoryResponse> {
|
|
246
195
|
const accessKey = getSequenceProjectAccessKey()
|
|
@@ -250,8 +199,7 @@ export async function getAccountTransactionHistory({
|
|
|
250
199
|
}
|
|
251
200
|
|
|
252
201
|
// Get the chain-specific indexer URL
|
|
253
|
-
const chainIndexerUrl =
|
|
254
|
-
chainIdToIndexerUrl[chainId as keyof typeof chainIdToIndexerUrl]
|
|
202
|
+
const chainIndexerUrl = getChainIndexerUrl(chainId)
|
|
255
203
|
if (!chainIndexerUrl) {
|
|
256
204
|
throw new Error(`Unsupported chain ID: ${chainId}`)
|
|
257
205
|
}
|
|
@@ -336,6 +284,15 @@ export type IntentTransaction = {
|
|
|
336
284
|
imageUrl: string
|
|
337
285
|
chainId: number
|
|
338
286
|
}
|
|
287
|
+
// Intent wallet transaction hashes
|
|
288
|
+
originIntentTxHash?: string // First action tx FROM origin intent (not deposit into it)
|
|
289
|
+
destinationIntentTxHash?: string // First action tx FROM destination intent (not deposit into it)
|
|
290
|
+
originIntentTxExplorerUrl?: string
|
|
291
|
+
destinationIntentTxExplorerUrl?: string
|
|
292
|
+
originIntentDepositTxHash?: string // First deposit tx INTO origin intent
|
|
293
|
+
destinationIntentDepositTxHash?: string // First deposit tx INTO destination intent
|
|
294
|
+
originIntentDepositTxExplorerUrl?: string
|
|
295
|
+
destinationIntentDepositTxExplorerUrl?: string
|
|
339
296
|
}
|
|
340
297
|
|
|
341
298
|
export type IntentTransactionHistoryResponse = {
|
|
@@ -364,40 +321,25 @@ export async function getIntentTransactionHistory({
|
|
|
364
321
|
throw new Error("Sequence project access key is required")
|
|
365
322
|
}
|
|
366
323
|
|
|
367
|
-
const apiUrl = getSequenceApiUrl()
|
|
368
|
-
|
|
369
|
-
const endpoint = `${apiUrl}/rpc/API/GetIntentTransactionHistory`
|
|
370
|
-
|
|
371
|
-
const requestBody = {
|
|
372
|
-
accountAddress: accountAddress.toLowerCase(),
|
|
373
|
-
page: {
|
|
374
|
-
page,
|
|
375
|
-
pageSize,
|
|
376
|
-
sort: [
|
|
377
|
-
{
|
|
378
|
-
column: "created_at",
|
|
379
|
-
order: "DESC",
|
|
380
|
-
},
|
|
381
|
-
],
|
|
382
|
-
},
|
|
383
|
-
}
|
|
384
|
-
|
|
385
324
|
try {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
325
|
+
const trailsClient = getTrailsClient()
|
|
326
|
+
|
|
327
|
+
// Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
|
|
328
|
+
const result = await trailsClient.getIntentTransactionHistory({
|
|
329
|
+
accountAddress: accountAddress.toLowerCase(),
|
|
330
|
+
page: {
|
|
331
|
+
page,
|
|
332
|
+
pageSize,
|
|
333
|
+
sort: [
|
|
334
|
+
{
|
|
335
|
+
column: "created_at",
|
|
336
|
+
order: SortOrder.DESC,
|
|
337
|
+
},
|
|
338
|
+
],
|
|
391
339
|
},
|
|
392
|
-
body: JSON.stringify(requestBody, bigintReplacer, 2),
|
|
393
340
|
})
|
|
394
341
|
|
|
395
|
-
|
|
396
|
-
throw new Error(`HTTP error! status: ${response.status}`)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const data: IntentTransactionHistoryResponse = await response.json()
|
|
400
|
-
return data
|
|
342
|
+
return result
|
|
401
343
|
} catch (error) {
|
|
402
344
|
logger.console.error(
|
|
403
345
|
"[trails-sdk] Error fetching intent transaction history:",
|
package/src/umd.tsx
CHANGED