0xtrails 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.d.ts +8 -3
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-DhEkQ6QC.js → ccip-Dw5AN7oU.js} +1 -1
- package/dist/cctp.d.ts +0 -149
- package/dist/cctp.d.ts.map +1 -1
- package/dist/chains.d.ts +28 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +12 -0
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-MhD2DA7_.js → index-BtVUTbEZ.js} +30984 -38945
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -107
- package/dist/indexerClient.d.ts +2 -2
- package/dist/intents.d.ts +0 -17
- package/dist/intents.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/sendUserOp.d.ts +0 -18
- package/dist/sendUserOp.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +10 -8
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +4 -5
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +4 -5
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +2 -2
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +4 -4
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/index.d.ts +0 -1
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +4 -34
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +6 -19
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/index.d.ts +0 -1
- package/dist/transactionIntent/utils/index.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -20
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +21 -0
- package/dist/walletUtils.d.ts.map +1 -0
- package/dist/wallets.d.ts +33 -240
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +8 -13
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +11 -5
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeDeposit.d.ts +5 -0
- package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +13 -0
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -0
- package/dist/widget/components/QrCode.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Toast.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +15 -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/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +7 -0
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +1 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts +6 -0
- package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +1 -0
- package/dist/widget/hooks/useQuote.d.ts +5 -8
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +30 -0
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +6 -15
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +23 -12
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +11 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/analytics.ts +53 -21
- package/src/cctp.ts +0 -1016
- package/src/chains.ts +93 -39
- package/src/config.ts +24 -6
- package/src/constants.ts +1 -4
- package/src/contractUtils.ts +6 -6
- package/src/estimate.ts +3 -6
- package/src/fees.ts +5 -10
- package/src/gasless.ts +45 -0
- package/src/index.ts +7 -6
- package/src/indexerClient.ts +2 -2
- package/src/intents.ts +52 -206
- package/src/mutations.ts +3 -2
- package/src/paymasterSend.ts +2 -5
- package/src/prepareSend.ts +9 -12
- package/src/sendUserOp.ts +3 -64
- package/src/tokenBalances.ts +2 -1
- package/src/tokens.ts +62 -133
- package/src/trailsClient.ts +1 -1
- package/src/transactionIntent/deposits/depositOrchestrator.ts +14 -15
- package/src/transactionIntent/deposits/gaslessDeposit.ts +70 -100
- package/src/transactionIntent/deposits/standardDeposit.ts +22 -28
- package/src/transactionIntent/execution/transactionState.ts +2 -2
- package/src/transactionIntent/handlers/crossChain.ts +165 -385
- package/src/transactionIntent/handlers/index.ts +0 -1
- package/src/transactionIntent/handlers/sameChainSameToken.ts +228 -94
- package/src/transactionIntent/quote/normalizeQuote.ts +4 -6
- package/src/transactionIntent/quote/quoteHelpers.ts +35 -3
- package/src/transactionIntent/types.ts +6 -27
- package/src/transactionIntent/utils/index.ts +0 -1
- package/src/transactions.ts +6 -203
- package/src/umd.tsx +1 -3
- package/src/utils.ts +28 -8
- package/src/walletUtils.ts +42 -0
- package/src/wallets.ts +361 -203
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +73 -4
- package/src/widget/components/AccountSettings.tsx +17 -17
- package/src/widget/components/ChainList.tsx +3 -3
- package/src/widget/components/ClassicSwap.tsx +19 -10
- package/src/widget/components/ConfigDisplay.tsx +1 -1
- package/src/widget/components/FeeOption.tsx +63 -20
- package/src/widget/components/FeeOptions.tsx +54 -123
- package/src/widget/components/NativeGasOption.tsx +3 -1
- package/src/widget/components/Pay.tsx +18 -11
- package/src/widget/components/PoolDeposit.tsx +23 -10
- package/src/widget/components/QRCodeDeposit.tsx +50 -30
- package/src/widget/components/QRCodeWalletSelect.tsx +77 -0
- package/src/widget/components/QrCode.tsx +188 -233
- package/src/widget/components/QuoteDetails.tsx +48 -2
- package/src/widget/components/Receipt.tsx +5 -2
- package/src/widget/components/ScreenHeader.tsx +10 -8
- package/src/widget/components/Toast.tsx +10 -0
- package/src/widget/components/TokenImage.tsx +56 -13
- package/src/widget/hooks/useCheckout.ts +71 -0
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDebugScreens.ts +5 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +788 -418
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +43 -0
- package/src/widget/hooks/useIsSequenceWallet.ts +17 -0
- package/src/widget/hooks/useQuote.ts +16 -17
- package/src/widget/hooks/useRecentTokens.ts +2 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +257 -0
- package/src/widget/hooks/useSendForm.ts +172 -47
- package/src/widget/hooks/useTokenList.ts +15 -2
- package/src/widget/providers/TrailsProvider.tsx +53 -25
- package/src/widget/widget.tsx +119 -48
- package/dist/cctpqueue.d.ts +0 -18
- package/dist/cctpqueue.d.ts.map +0 -1
- package/dist/preconditions.d.ts +0 -12
- package/dist/preconditions.d.ts.map +0 -1
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +0 -62
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +0 -1
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +0 -10
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +0 -33
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +0 -1
- package/src/cctpqueue.ts +0 -69
- package/src/preconditions.ts +0 -47
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +0 -323
- package/src/transactionIntent/utils/lifiHelpers.ts +0 -68
- package/src/widget/hooks/useSelectedFeeToken.tsx +0 -288
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, useState, useEffect, useRef } from "react"
|
|
2
|
+
import type React from "react"
|
|
2
3
|
import { ChainImage } from "./ChainImage.js"
|
|
3
4
|
import { getCommonTokenImageUrl } from "../../tokens.js"
|
|
4
5
|
import { logger } from "../../logger.js"
|
|
6
|
+
import { commonTokenImages } from "../../tokens.js"
|
|
5
7
|
|
|
6
8
|
function normalizeImageUrl(
|
|
7
9
|
imageUrl?: string | null,
|
|
8
10
|
symbol?: string | null,
|
|
9
11
|
chainId?: number | null,
|
|
10
12
|
contractAddress?: string | null,
|
|
11
|
-
) {
|
|
13
|
+
): string | null {
|
|
12
14
|
if (symbol === "ETH") {
|
|
13
|
-
return
|
|
15
|
+
return commonTokenImages.ETH!
|
|
14
16
|
}
|
|
15
17
|
const commonImageUrl = getCommonTokenImageUrl({
|
|
16
18
|
symbol,
|
|
@@ -43,24 +45,64 @@ export const TokenImage: React.FC<TokenImageProps> = ({
|
|
|
43
45
|
contractAddress,
|
|
44
46
|
size = 24,
|
|
45
47
|
}) => {
|
|
46
|
-
const [imageError, setImageError] =
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const [imageError, setImageError] = useState(false)
|
|
49
|
+
const [imageSize, setImageSize] = useState<{
|
|
50
|
+
width: number
|
|
51
|
+
height: number
|
|
52
|
+
} | null>(null)
|
|
53
|
+
const previousUrlRef = useRef<string | null>(null)
|
|
54
|
+
|
|
55
|
+
const effectiveImageUrl = useMemo<string | null>(() => {
|
|
54
56
|
return normalizeImageUrl(imageUrl, symbol, chainId, contractAddress)
|
|
55
57
|
}, [imageUrl, symbol, chainId, contractAddress])
|
|
56
58
|
|
|
59
|
+
// Reset image size and error when URL changes
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (previousUrlRef.current !== effectiveImageUrl) {
|
|
62
|
+
setImageSize(null)
|
|
63
|
+
setImageError(false)
|
|
64
|
+
previousUrlRef.current = effectiveImageUrl
|
|
65
|
+
}
|
|
66
|
+
}, [effectiveImageUrl])
|
|
67
|
+
|
|
57
68
|
const displaySymbol = symbol?.[0]?.toUpperCase() || "?"
|
|
58
69
|
|
|
70
|
+
const handleImageLoad = (e: React.SyntheticEvent<HTMLImageElement>) => {
|
|
71
|
+
const img = e.currentTarget
|
|
72
|
+
const size = {
|
|
73
|
+
width: img.naturalWidth,
|
|
74
|
+
height: img.naturalHeight,
|
|
75
|
+
}
|
|
76
|
+
setImageSize(size)
|
|
77
|
+
logger.console.log("[TokenImage] Image loaded", {
|
|
78
|
+
effectiveImageUrl,
|
|
79
|
+
naturalWidth: img.naturalWidth,
|
|
80
|
+
naturalHeight: img.naturalHeight,
|
|
81
|
+
symbol,
|
|
82
|
+
chainId,
|
|
83
|
+
contractAddress,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
59
87
|
const handleImageError = () => {
|
|
60
|
-
|
|
88
|
+
// Only set error if we haven't already determined it's invalid
|
|
89
|
+
// This prevents unnecessary state updates
|
|
90
|
+
if (!imageError) {
|
|
91
|
+
logger.console.error("[TokenImage] Image load error", {
|
|
92
|
+
effectiveImageUrl,
|
|
93
|
+
imageUrl,
|
|
94
|
+
symbol,
|
|
95
|
+
chainId,
|
|
96
|
+
contractAddress,
|
|
97
|
+
})
|
|
98
|
+
setImageError(true)
|
|
99
|
+
}
|
|
61
100
|
}
|
|
62
101
|
|
|
63
|
-
|
|
102
|
+
// Show text if no URL, error, or image is 1x1 or less (transparent pixel)
|
|
103
|
+
const isTransparentPixel =
|
|
104
|
+
imageSize !== null && imageSize.width <= 1 && imageSize.height <= 1
|
|
105
|
+
const shouldShowText = !effectiveImageUrl || imageError || isTransparentPixel
|
|
64
106
|
|
|
65
107
|
return (
|
|
66
108
|
<div
|
|
@@ -92,6 +134,7 @@ export const TokenImage: React.FC<TokenImageProps> = ({
|
|
|
92
134
|
src={effectiveImageUrl}
|
|
93
135
|
alt={symbol || "Token"}
|
|
94
136
|
className="absolute w-full h-full rounded-full object-contain"
|
|
137
|
+
onLoad={handleImageLoad}
|
|
95
138
|
onError={handleImageError}
|
|
96
139
|
title={`Token: ${symbol}`}
|
|
97
140
|
style={{
|
|
@@ -19,6 +19,15 @@ export type CheckoutCallbacks = {
|
|
|
19
19
|
sessionId: string
|
|
20
20
|
error: unknown
|
|
21
21
|
}) => void
|
|
22
|
+
onCheckoutApprovalRequest?: (data: { sessionId: string }) => void
|
|
23
|
+
onCheckoutApprovalConfirmed?: (data: {
|
|
24
|
+
sessionId: string
|
|
25
|
+
transactionHash: `0x${string}`
|
|
26
|
+
}) => void
|
|
27
|
+
onCheckoutApprovalRejected?: (data: {
|
|
28
|
+
sessionId: string
|
|
29
|
+
error: unknown
|
|
30
|
+
}) => void
|
|
22
31
|
onCheckoutComplete?: (data: { sessionId: string }) => void
|
|
23
32
|
onCheckoutError?: (data: { sessionId: string; error: unknown }) => void
|
|
24
33
|
onCheckoutStatusUpdate?: (data: {
|
|
@@ -33,6 +42,9 @@ export type CheckoutOnHandlers = {
|
|
|
33
42
|
triggerCheckoutSignatureRequest: () => void
|
|
34
43
|
triggerCheckoutSignatureConfirmed: () => void
|
|
35
44
|
triggerCheckoutSignatureRejected: (error: unknown) => void
|
|
45
|
+
triggerCheckoutApprovalRequest: () => void
|
|
46
|
+
triggerCheckoutApprovalConfirmed: (transactionHash: `0x${string}`) => void
|
|
47
|
+
triggerCheckoutApprovalRejected: (error: unknown) => void
|
|
36
48
|
triggerCheckoutComplete: (
|
|
37
49
|
txStatus: "success" | "fail",
|
|
38
50
|
accountAddress?: string,
|
|
@@ -59,6 +71,9 @@ export function useCheckout({
|
|
|
59
71
|
onCheckoutSignatureRequest,
|
|
60
72
|
onCheckoutSignatureConfirmed,
|
|
61
73
|
onCheckoutSignatureRejected,
|
|
74
|
+
onCheckoutApprovalRequest,
|
|
75
|
+
onCheckoutApprovalConfirmed,
|
|
76
|
+
onCheckoutApprovalRejected,
|
|
62
77
|
onCheckoutComplete,
|
|
63
78
|
onCheckoutError,
|
|
64
79
|
onCheckoutStatusUpdate,
|
|
@@ -152,6 +167,59 @@ export function useCheckout({
|
|
|
152
167
|
[onCheckoutSignatureRejected],
|
|
153
168
|
)
|
|
154
169
|
|
|
170
|
+
const triggerCheckoutApprovalRequest = useCallback(() => {
|
|
171
|
+
if (onCheckoutApprovalRequest && sessionIdRef.current) {
|
|
172
|
+
try {
|
|
173
|
+
onCheckoutApprovalRequest({
|
|
174
|
+
sessionId: sessionIdRef.current,
|
|
175
|
+
})
|
|
176
|
+
} catch (error) {
|
|
177
|
+
logger.console.error(
|
|
178
|
+
"[trails-sdk] Error calling onCheckoutApprovalRequest:",
|
|
179
|
+
error,
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}, [onCheckoutApprovalRequest])
|
|
184
|
+
|
|
185
|
+
const triggerCheckoutApprovalConfirmed = useCallback(
|
|
186
|
+
(transactionHash: `0x${string}`) => {
|
|
187
|
+
if (onCheckoutApprovalConfirmed && sessionIdRef.current) {
|
|
188
|
+
try {
|
|
189
|
+
onCheckoutApprovalConfirmed({
|
|
190
|
+
sessionId: sessionIdRef.current,
|
|
191
|
+
transactionHash,
|
|
192
|
+
})
|
|
193
|
+
} catch (error) {
|
|
194
|
+
logger.console.error(
|
|
195
|
+
"[trails-sdk] Error calling onCheckoutApprovalConfirmed:",
|
|
196
|
+
error,
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
[onCheckoutApprovalConfirmed],
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const triggerCheckoutApprovalRejected = useCallback(
|
|
205
|
+
(error: unknown) => {
|
|
206
|
+
if (onCheckoutApprovalRejected && sessionIdRef.current) {
|
|
207
|
+
try {
|
|
208
|
+
onCheckoutApprovalRejected({
|
|
209
|
+
sessionId: sessionIdRef.current,
|
|
210
|
+
error,
|
|
211
|
+
})
|
|
212
|
+
} catch (callbackError) {
|
|
213
|
+
logger.console.error(
|
|
214
|
+
"[trails-sdk] Error calling onCheckoutApprovalRejected:",
|
|
215
|
+
callbackError,
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
[onCheckoutApprovalRejected],
|
|
221
|
+
)
|
|
222
|
+
|
|
155
223
|
const triggerCheckoutComplete = useCallback(
|
|
156
224
|
(txStatus: "success" | "fail", accountAddress?: string) => {
|
|
157
225
|
if (onCheckoutComplete && sessionIdRef.current) {
|
|
@@ -256,6 +324,9 @@ export function useCheckout({
|
|
|
256
324
|
triggerCheckoutSignatureRequest,
|
|
257
325
|
triggerCheckoutSignatureConfirmed,
|
|
258
326
|
triggerCheckoutSignatureRejected,
|
|
327
|
+
triggerCheckoutApprovalRequest,
|
|
328
|
+
triggerCheckoutApprovalConfirmed,
|
|
329
|
+
triggerCheckoutApprovalRejected,
|
|
259
330
|
triggerCheckoutComplete,
|
|
260
331
|
triggerCheckoutError,
|
|
261
332
|
triggerCheckoutStatusUpdate,
|
|
@@ -16,6 +16,7 @@ type Screen =
|
|
|
16
16
|
| "swap"
|
|
17
17
|
| "receive"
|
|
18
18
|
| "wallet-confirmation"
|
|
19
|
+
| "qr-code-wallet-select"
|
|
19
20
|
| "qr-code-deposit"
|
|
20
21
|
| "pending"
|
|
21
22
|
| "receipt"
|
|
@@ -132,6 +133,10 @@ export const useDebugScreens = ({
|
|
|
132
133
|
setShowWalletConfirmRetry(false)
|
|
133
134
|
setCurrentScreen("wallet-confirmation")
|
|
134
135
|
break
|
|
136
|
+
case "qr-code-wallet-select":
|
|
137
|
+
setPrepareSendQuote(dummyQuote)
|
|
138
|
+
setCurrentScreen("qr-code-wallet-select")
|
|
139
|
+
break
|
|
135
140
|
case "wallet-confirmation-retry":
|
|
136
141
|
// Set dummy USDC token for debug mode
|
|
137
142
|
setSelectedToken(dummySelectedToken)
|