0xtrails 0.1.13 → 0.2.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.
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +11 -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/{proxyCaller.d.ts → balanceInjector.d.ts} +5 -4
- package/dist/balanceInjector.d.ts.map +1 -0
- package/dist/{ccip-D3gTQONK.js → ccip-D6ToCrWc.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 +17 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -4
- 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/{index-CnUM7lKf.js → index-BqgeTLL8.js} +34072 -30146
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +411 -400
- package/dist/intentEntrypoint.d.ts +96 -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 +8 -2
- 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/transactions.d.ts +8 -0
- 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/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/Fund.d.ts +44 -0
- package/dist/widget/components/Fund.d.ts.map +1 -0
- package/dist/widget/components/Identicon.d.ts +9 -0
- package/dist/widget/components/Identicon.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/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/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/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/useSelectedRecipient.d.ts +12 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +2 -0
- 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 +29 -28
- package/src/aave.ts +6 -1
- package/src/analytics.ts +103 -53
- package/src/apiClient.ts +1 -1
- package/src/{proxyCaller.ts → balanceInjector.ts} +22 -17
- package/src/cctp.ts +6 -2
- package/src/cctpqueue.ts +7 -7
- package/src/chains.ts +8 -0
- package/src/config.ts +40 -9
- package/src/constants.ts +11 -8
- package/src/contractUtils.ts +33 -2
- package/src/customChains.ts +24 -0
- package/src/index.ts +11 -1
- package/src/intentEntrypoint.ts +253 -0
- package/src/intents.ts +87 -54
- package/src/metaTxnMonitor.ts +1 -0
- package/src/morpho.ts +13 -2
- package/src/pools.ts +68 -86
- package/src/prepareSend.ts +437 -207
- package/src/prices.ts +51 -7
- package/src/relaySdk.ts +6 -4
- package/src/relayer.ts +2 -0
- package/src/toast.ts +110 -0
- package/src/tokenBalances.ts +112 -20
- package/src/tokens.ts +70 -7
- package/src/trails.ts +80 -77
- package/src/trailsClient.ts +45 -0
- package/src/transactions.ts +27 -35
- 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 +96 -0
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +10 -20
- package/src/widget/components/ClassicSwap.tsx +923 -0
- package/src/widget/components/ConfigDisplay.tsx +8 -5
- package/src/widget/components/ConnectedWallets.tsx +260 -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 +108 -116
- package/src/widget/components/EarnPools.tsx +2 -4
- package/src/widget/components/EarnPoolsFilters.tsx +6 -6
- package/src/widget/components/Fund.tsx +1245 -0
- package/src/widget/components/FundMethods.tsx +1 -1
- package/src/widget/components/FundSendForm.tsx +1 -1
- package/src/widget/components/Identicon.tsx +158 -0
- package/src/widget/components/Pay.tsx +1088 -0
- package/src/widget/components/PaySendForm.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +1 -1
- 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 +3 -3
- package/src/widget/components/TransactionDetails.tsx +153 -13
- package/src/widget/components/TruncatedAddress.tsx +5 -1
- package/src/widget/components/UserPreferences.tsx +156 -0
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/hooks/useBalanceVisible.tsx +40 -2
- package/src/widget/hooks/useCheckout.ts +13 -0
- package/src/widget/hooks/useCurrentScreen.tsx +3 -0
- package/src/widget/hooks/useDebugScreens.ts +12 -2
- package/src/widget/hooks/useDefaultTokenSelection.tsx +475 -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/useSelectedRecipient.tsx +48 -0
- package/src/widget/hooks/useSendForm.ts +179 -26
- 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 +164 -68
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- 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
|
}, [
|
|
@@ -1571,16 +1571,19 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1571
1571
|
const providerFromQuote = trailsFee?.quoteProvider
|
|
1572
1572
|
? String(trailsFee.quoteProvider).toLowerCase()
|
|
1573
1573
|
: undefined
|
|
1574
|
-
const providerFromArgs = createIntentMutation.variables?.
|
|
1575
|
-
|
|
1574
|
+
const providerFromArgs = createIntentMutation.variables?.params
|
|
1575
|
+
.provider
|
|
1576
|
+
? String(
|
|
1577
|
+
createIntentMutation.variables.params.provider,
|
|
1578
|
+
).toLowerCase()
|
|
1576
1579
|
: undefined
|
|
1577
1580
|
const isCctp =
|
|
1578
1581
|
providerFromQuote === "cctp" || providerFromArgs === "cctp"
|
|
1579
1582
|
|
|
1580
1583
|
const originChainIdForCctp =
|
|
1581
|
-
createIntentMutation.variables?.originChainId
|
|
1584
|
+
createIntentMutation.variables?.params.originChainId
|
|
1582
1585
|
const destinationChainIdForCctp =
|
|
1583
|
-
createIntentMutation.variables?.destinationChainId
|
|
1586
|
+
createIntentMutation.variables?.params.destinationChainId
|
|
1584
1587
|
|
|
1585
1588
|
logger.console.log("[Trails] isCctp", isCctp)
|
|
1586
1589
|
logger.console.log("[Trails] providerFromQuote", providerFromQuote)
|
|
@@ -1591,16 +1594,16 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1591
1594
|
createIntentMutation.variables,
|
|
1592
1595
|
)
|
|
1593
1596
|
logger.console.log(
|
|
1594
|
-
"[Trails] createIntentMutation.variables.provider",
|
|
1595
|
-
createIntentMutation.variables?.provider,
|
|
1597
|
+
"[Trails] createIntentMutation.variables.params.provider",
|
|
1598
|
+
createIntentMutation.variables?.params.provider,
|
|
1596
1599
|
)
|
|
1597
1600
|
logger.console.log(
|
|
1598
|
-
"[Trails] createIntentMutation.variables.originChainId",
|
|
1599
|
-
createIntentMutation.variables?.originChainId,
|
|
1601
|
+
"[Trails] createIntentMutation.variables.params.originChainId",
|
|
1602
|
+
createIntentMutation.variables?.params.originChainId,
|
|
1600
1603
|
)
|
|
1601
1604
|
logger.console.log(
|
|
1602
|
-
"[Trails] createIntentMutation.variables.destinationChainId",
|
|
1603
|
-
createIntentMutation.variables?.destinationChainId,
|
|
1605
|
+
"[Trails] createIntentMutation.variables.params.destinationChainId",
|
|
1606
|
+
createIntentMutation.variables?.params.destinationChainId,
|
|
1604
1607
|
)
|
|
1605
1608
|
logger.console.log(
|
|
1606
1609
|
"[Trails] lastQueuedCctpSourceTxHash",
|
|
@@ -1618,7 +1621,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1618
1621
|
|
|
1619
1622
|
if (
|
|
1620
1623
|
isCctp &&
|
|
1621
|
-
|
|
1624
|
+
trailsClient &&
|
|
1622
1625
|
transactionHash &&
|
|
1623
1626
|
typeof originChainIdForCctp === "number" &&
|
|
1624
1627
|
typeof destinationChainIdForCctp === "number" &&
|
|
@@ -1627,7 +1630,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1627
1630
|
) {
|
|
1628
1631
|
lastQueuedCctpSourceTxHash.current = transactionHash
|
|
1629
1632
|
await queueCCTPTransfer({
|
|
1630
|
-
|
|
1633
|
+
trailsClient,
|
|
1631
1634
|
sourceTxHash: transactionHash,
|
|
1632
1635
|
sourceChainId: originChainIdForCctp,
|
|
1633
1636
|
destinationChainId: destinationChainIdForCctp,
|
|
@@ -1671,7 +1674,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1671
1674
|
metaTxnBlockTimestamps,
|
|
1672
1675
|
trailsFee,
|
|
1673
1676
|
createIntentMutation.variables,
|
|
1674
|
-
|
|
1677
|
+
trailsClient,
|
|
1675
1678
|
])
|
|
1676
1679
|
|
|
1677
1680
|
const updateAutoExecute = (enabled: boolean) => {
|
|
@@ -1732,7 +1735,7 @@ export function useTrails(config: UseTrailsConfig): UseTrailsReturn {
|
|
|
1732
1735
|
const sendMetaTxnArgs = sendMetaTxnMutation.variables
|
|
1733
1736
|
|
|
1734
1737
|
return {
|
|
1735
|
-
|
|
1738
|
+
trailsClient,
|
|
1736
1739
|
metaTxns,
|
|
1737
1740
|
intentCallsPayloads,
|
|
1738
1741
|
intentPreconditions,
|
|
@@ -0,0 +1,45 @@
|
|
|
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: config?.projectAccessKey || projectAccessKey,
|
|
34
|
+
jwt: config?.jwt || jwt,
|
|
35
|
+
})
|
|
36
|
+
}, [
|
|
37
|
+
config?.hostname,
|
|
38
|
+
config?.projectAccessKey,
|
|
39
|
+
config?.jwt,
|
|
40
|
+
projectAccessKey,
|
|
41
|
+
jwt,
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
return trailsClient
|
|
45
|
+
}
|
package/src/transactions.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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, getSequenceEnv } from "./config.js"
|
|
5
|
+
import { getTrailsClient } from "./trailsClient.js"
|
|
9
6
|
import type { GuestModuleEvent, TrailsTokenSweeperEvent } from "./decoders.js"
|
|
10
7
|
import {
|
|
11
8
|
arbitrum,
|
|
@@ -29,6 +26,7 @@ import {
|
|
|
29
26
|
import { logger } from "./logger.js"
|
|
30
27
|
import { bigintReplacer } from "./utils.js"
|
|
31
28
|
import { getExplorerUrl } from "./explorer.js"
|
|
29
|
+
import { SortOrder } from "@0xsequence/trails-api"
|
|
32
30
|
|
|
33
31
|
export type TransactionStateStatus =
|
|
34
32
|
| "pending"
|
|
@@ -336,6 +334,15 @@ export type IntentTransaction = {
|
|
|
336
334
|
imageUrl: string
|
|
337
335
|
chainId: number
|
|
338
336
|
}
|
|
337
|
+
// Intent wallet transaction hashes
|
|
338
|
+
originIntentTxHash?: string // First action tx FROM origin intent (not deposit into it)
|
|
339
|
+
destinationIntentTxHash?: string // First action tx FROM destination intent (not deposit into it)
|
|
340
|
+
originIntentTxExplorerUrl?: string
|
|
341
|
+
destinationIntentTxExplorerUrl?: string
|
|
342
|
+
originIntentDepositTxHash?: string // First deposit tx INTO origin intent
|
|
343
|
+
destinationIntentDepositTxHash?: string // First deposit tx INTO destination intent
|
|
344
|
+
originIntentDepositTxExplorerUrl?: string
|
|
345
|
+
destinationIntentDepositTxExplorerUrl?: string
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
export type IntentTransactionHistoryResponse = {
|
|
@@ -364,40 +371,25 @@ export async function getIntentTransactionHistory({
|
|
|
364
371
|
throw new Error("Sequence project access key is required")
|
|
365
372
|
}
|
|
366
373
|
|
|
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
374
|
try {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
375
|
+
const trailsClient = getTrailsClient()
|
|
376
|
+
|
|
377
|
+
// Use the hybrid client's getIntentTransactionHistory method which tries Trails API first, then Sequence API
|
|
378
|
+
const result = await trailsClient.getIntentTransactionHistory({
|
|
379
|
+
accountAddress: accountAddress.toLowerCase(),
|
|
380
|
+
page: {
|
|
381
|
+
page,
|
|
382
|
+
pageSize,
|
|
383
|
+
sort: [
|
|
384
|
+
{
|
|
385
|
+
column: "created_at",
|
|
386
|
+
order: SortOrder.DESC,
|
|
387
|
+
},
|
|
388
|
+
],
|
|
391
389
|
},
|
|
392
|
-
body: JSON.stringify(requestBody, bigintReplacer, 2),
|
|
393
390
|
})
|
|
394
391
|
|
|
395
|
-
|
|
396
|
-
throw new Error(`HTTP error! status: ${response.status}`)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const data: IntentTransactionHistoryResponse = await response.json()
|
|
400
|
-
return data
|
|
392
|
+
return result
|
|
401
393
|
} catch (error) {
|
|
402
394
|
logger.console.error(
|
|
403
395
|
"[trails-sdk] Error fetching intent transaction history:",
|
package/src/umd.tsx
CHANGED
package/src/wallets.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
getWalletConnectProjectId,
|
|
4
4
|
} from "./config.js"
|
|
5
5
|
import WalletConnectLogo from "./widget/assets/WalletConnect-logo-blue-bg.svg"
|
|
6
|
+
import SequenceLogo from "./widget/assets/sequence-logo.svg"
|
|
6
7
|
import { Wallet as WalletIcon } from "lucide-react"
|
|
7
8
|
import {
|
|
8
9
|
injected,
|
|
@@ -279,7 +280,7 @@ export const WALLET_CONFIGS: Record<string, WalletConfig> = {
|
|
|
279
280
|
id: "sequence",
|
|
280
281
|
name: "Sequence",
|
|
281
282
|
connector: sequenceConnector,
|
|
282
|
-
icon:
|
|
283
|
+
icon: SequenceLogo as string,
|
|
283
284
|
},
|
|
284
285
|
}
|
|
285
286
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg width="500" height="365" viewBox="0 0 500 365" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_29_10159)">
|
|
3
|
+
<path d="M496.448 181.441C496.448 158.416 478.089 139.75 455.442 139.75C432.796 139.75 414.437 158.416 414.437 181.441C414.437 204.467 432.796 223.132 455.442 223.132C478.089 223.132 496.448 204.467 496.448 181.441Z" fill="#7C3AED"/>
|
|
4
|
+
<path d="M82.0114 42.2523C82.0114 19.227 63.6525 0.561279 41.0057 0.561279C18.3589 0.561279 0 19.227 0 42.2523C0 65.2776 18.3589 83.9433 41.0057 83.9433C63.6525 83.9433 82.0114 65.2776 82.0114 42.2523Z" fill="#7C3AED"/>
|
|
5
|
+
<path d="M82.0114 322.846C82.0114 299.821 63.6525 281.155 41.0057 281.155C18.3589 281.155 0 299.821 0 322.846C0 345.871 18.3589 364.537 41.0057 364.537C63.6525 364.537 82.0114 345.871 82.0114 322.846Z" fill="#7C3AED"/>
|
|
6
|
+
<path d="M500 320.63C500 301.412 484.677 285.833 465.775 285.833H161.879C142.977 285.833 127.654 301.412 127.654 320.63C127.654 339.848 142.977 355.427 161.879 355.427H465.775C484.677 355.427 500 339.848 500 320.63Z" fill="#7C3AED"/>
|
|
7
|
+
<path d="M368.794 181.441C368.794 162.223 353.471 146.644 334.569 146.644H34.2255C15.3234 146.644 0.000265708 162.223 0.000265708 181.441C0.000265708 200.659 15.3234 216.238 34.2255 216.238H334.569C353.471 216.238 368.794 200.659 368.794 181.441Z" fill="#7C3AED"/>
|
|
8
|
+
<path d="M500 42.2523C500 23.0343 484.677 7.45507 465.775 7.45507H161.879C142.977 7.45507 127.654 23.0343 127.654 42.2523C127.654 61.4703 142.977 77.0495 161.879 77.0495H465.775C484.677 77.0495 500 61.4703 500 42.2523Z" fill="#7C3AED"/>
|
|
9
|
+
</g>
|
|
10
|
+
<defs>
|
|
11
|
+
<clipPath id="clip0_29_10159">
|
|
12
|
+
<rect width="500" height="363.98" fill="white" transform="translate(0 0.561279)"/>
|
|
13
|
+
</clipPath>
|
|
14
|
+
</defs>
|
|
15
|
+
</svg>
|