0xtrails 0.1.2 → 0.1.4
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/address.d.ts.map +1 -1
- package/dist/analytics.d.ts +86 -1
- 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-BmFTEOaB.js → ccip-dLSEJjCf.js} +55 -55
- package/dist/cctpqueue.d.ts +1 -1
- package/dist/cctpqueue.d.ts.map +1 -1
- package/dist/chains.d.ts +9 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/decoders.d.ts +58 -0
- package/dist/decoders.d.ts.map +1 -0
- package/dist/ens.d.ts +13 -0
- package/dist/ens.d.ts.map +1 -0
- package/dist/error.d.ts +9 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/{index-BPsVj7zK.js → index-BXbaLmtt.js} +28779 -25738
- package/dist/index.js +2 -2
- package/dist/intents.d.ts +4 -4
- package/dist/intents.d.ts.map +1 -1
- package/dist/lifi.d.ts +4 -0
- package/dist/lifi.d.ts.map +1 -0
- package/dist/metaTxns.d.ts +1 -1
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/preconditions.d.ts +1 -1
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +32 -24
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +3 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/proxyCaller.d.ts +0 -1
- package/dist/proxyCaller.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +1 -1
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +4 -4
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +6 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/wallets.d.ts +247 -5
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts +1 -0
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensDropdown.d.ts.map +1 -1
- package/dist/widget/components/ErrorDisplay.d.ts +9 -0
- package/dist/widget/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/widget/components/FundSendForm.d.ts +2 -2
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/OriginTransferInformation.d.ts +10 -0
- package/dist/widget/components/OriginTransferInformation.d.ts.map +1 -0
- package/dist/widget/components/PaySendForm.d.ts +2 -2
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QrCode.d.ts +1 -1
- 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/Receive.d.ts +12 -0
- package/dist/widget/components/Receive.d.ts.map +1 -0
- package/dist/widget/components/RefundAddressInput.d.ts +13 -0
- package/dist/widget/components/RefundAddressInput.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +47 -0
- package/dist/widget/components/Swap.d.ts.map +1 -0
- package/dist/widget/components/SwapDisplay.d.ts +9 -0
- package/dist/widget/components/SwapDisplay.d.ts.map +1 -0
- package/dist/widget/components/TokenList.d.ts +0 -2
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +26 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts +2 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletConnectionPending.d.ts +12 -0
- package/dist/widget/components/WalletConnectionPending.d.ts.map +1 -0
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/YellowWarningAnimation.d.ts +2 -0
- package/dist/widget/components/YellowWarningAnimation.d.ts.map +1 -0
- package/dist/widget/hooks/useAmountUsd.d.ts +1 -3
- package/dist/widget/hooks/useAmountUsd.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +22 -0
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +12 -6
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +2 -3
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -15
- package/src/aave.ts +13 -13
- package/src/address.ts +3 -0
- package/src/analytics.ts +192 -8
- package/src/apiClient.ts +1 -1
- package/src/cctpqueue.ts +1 -1
- package/src/chains.ts +45 -7
- package/src/constants.ts +7 -4
- package/src/decoders.ts +310 -0
- package/src/ens.ts +32 -0
- package/src/error.ts +101 -1
- package/src/intents.ts +10 -2
- package/src/lifi.ts +58 -0
- package/src/metaTxns.ts +1 -1
- package/src/mode.ts +1 -1
- package/src/morpho.ts +3 -3
- package/src/pools.ts +18 -18
- package/src/preconditions.ts +1 -1
- package/src/prepareSend.ts +463 -113
- package/src/prices.ts +26 -1
- package/src/proxyCaller.ts +2 -14
- package/src/relaySdk.ts +1 -0
- package/src/relayer.ts +8 -0
- package/src/tokenBalances.ts +24 -17
- package/src/tokens.ts +147 -22
- package/src/trails.ts +4 -4
- package/src/transactions.ts +35 -17
- package/src/utils.ts +28 -0
- package/src/wallets.ts +275 -35
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/ChainFilterDropdown.tsx +42 -33
- package/src/widget/components/ChainImage.tsx +1 -1
- package/src/widget/components/ConnectWallet.tsx +92 -128
- package/src/widget/components/DebugScreensDropdown.tsx +6 -0
- package/src/widget/components/ErrorDisplay.tsx +150 -0
- package/src/widget/components/FundSendForm.tsx +78 -11
- package/src/widget/components/OriginTransferInformation.tsx +59 -0
- package/src/widget/components/PaySendForm.tsx +80 -13
- package/src/widget/components/QRCodeDeposit.tsx +6 -6
- package/src/widget/components/QrCode.tsx +278 -17
- package/src/widget/components/QuoteDetails.tsx +93 -25
- package/src/widget/components/Receipt.tsx +296 -103
- package/src/widget/components/Receive.tsx +146 -0
- package/src/widget/components/RecentTokens.tsx +1 -1
- package/src/widget/components/RefundAddressInput.tsx +149 -0
- package/src/widget/components/Swap.tsx +769 -0
- package/src/widget/components/SwapDisplay.tsx +68 -0
- package/src/widget/components/TokenList.tsx +27 -363
- package/src/widget/components/TokenSelector.tsx +405 -0
- package/src/widget/components/TransferPendingVertical.tsx +162 -112
- package/src/widget/components/WalletConnect.tsx +9 -7
- package/src/widget/components/WalletConnectionPending.tsx +157 -0
- package/src/widget/components/WalletList.tsx +6 -5
- package/src/widget/components/YellowWarningAnimation.tsx +146 -0
- package/src/widget/hooks/useAmountUsd.ts +3 -8
- package/src/widget/hooks/useCheckout.ts +3 -2
- package/src/widget/hooks/useDebugScreens.ts +583 -0
- package/src/widget/hooks/useSendForm.ts +111 -35
- package/src/widget/hooks/useTokenList.ts +155 -122
- package/src/widget/widget.tsx +503 -523
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SequenceIndexerGateway } from "@0xsequence/indexer"
|
|
2
1
|
import { ResourceStatus } from "@0xsequence/indexer"
|
|
3
2
|
import { Address } from "ox"
|
|
4
3
|
import { useEffect, useMemo, useState } from "react"
|
|
@@ -16,7 +15,8 @@ import {
|
|
|
16
15
|
useHasSufficientBalanceUsd,
|
|
17
16
|
useTokenBalances,
|
|
18
17
|
} from "../../tokenBalances.js"
|
|
19
|
-
import { getFormatttedTokenName,
|
|
18
|
+
import { getFormatttedTokenName, useSupportedTokens } from "../../tokens.js"
|
|
19
|
+
import { useIndexerGatewayClient } from "../../indexerClient.js"
|
|
20
20
|
|
|
21
21
|
export interface Token {
|
|
22
22
|
id: number
|
|
@@ -50,9 +50,9 @@ export type TokenFormatted = Token &
|
|
|
50
50
|
export type UseTokenListProps = {
|
|
51
51
|
onContinue: (selectedToken: Token) => void
|
|
52
52
|
targetAmountUsd?: number | null
|
|
53
|
-
indexerGatewayClient: SequenceIndexerGateway
|
|
54
53
|
onError: (error: Error | string | null) => void
|
|
55
54
|
fundMethod?: string | null
|
|
55
|
+
allSupportedTokens?: boolean
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export type UseTokenListReturn = {
|
|
@@ -76,27 +76,31 @@ export type UseTokenListReturn = {
|
|
|
76
76
|
export function useTokenList({
|
|
77
77
|
onContinue,
|
|
78
78
|
targetAmountUsd,
|
|
79
|
-
indexerGatewayClient,
|
|
80
79
|
onError,
|
|
81
80
|
fundMethod,
|
|
81
|
+
allSupportedTokens = false,
|
|
82
82
|
}: UseTokenListProps): UseTokenListReturn {
|
|
83
83
|
const [selectedToken, setSelectedToken] = useState<Token | null>(null)
|
|
84
84
|
const [searchQuery, setSearchQuery] = useState("")
|
|
85
|
-
const [allSupportedTokens, setAllSupportedTokens] = useState<any[]>([])
|
|
86
|
-
const [isLoadingSupportedTokens, setIsLoadingSupportedTokens] =
|
|
87
|
-
useState(false)
|
|
88
85
|
const { address } = useAccount()
|
|
86
|
+
const indexerGatewayClient = useIndexerGatewayClient()
|
|
89
87
|
const {
|
|
90
88
|
sortedTokens: allSortedTokens,
|
|
91
89
|
isLoadingSortedTokens,
|
|
92
90
|
balanceError,
|
|
93
91
|
} = useTokenBalances(address as Address.Address, indexerGatewayClient)
|
|
94
92
|
|
|
95
|
-
//
|
|
93
|
+
// Use cached supported tokens hook
|
|
94
|
+
const { supportedTokens, isLoadingTokens: isLoadingSupportedTokens } =
|
|
95
|
+
useSupportedTokens()
|
|
96
|
+
|
|
97
|
+
// Determine loading state based on fund method and allSupportedTokens
|
|
96
98
|
const isLoadingTokens =
|
|
97
99
|
fundMethod === "qr-code" || fundMethod === "exchange"
|
|
98
100
|
? isLoadingSupportedTokens
|
|
99
|
-
:
|
|
101
|
+
: allSupportedTokens
|
|
102
|
+
? isLoadingSortedTokens || isLoadingSupportedTokens
|
|
103
|
+
: isLoadingSortedTokens
|
|
100
104
|
|
|
101
105
|
const {
|
|
102
106
|
totalBalanceUsd,
|
|
@@ -111,32 +115,17 @@ export function useTokenList({
|
|
|
111
115
|
const showContinueButton = false
|
|
112
116
|
const { supportedChains: supportedToChains } = useSupportedChains()
|
|
113
117
|
|
|
114
|
-
//
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
if (fundMethod === "qr-code" || fundMethod === "exchange") {
|
|
117
|
-
setIsLoadingSupportedTokens(true)
|
|
118
|
-
getSupportedTokens()
|
|
119
|
-
.then((tokens) => {
|
|
120
|
-
setAllSupportedTokens(tokens)
|
|
121
|
-
})
|
|
122
|
-
.catch((error) => {
|
|
123
|
-
console.error("[trails-sdk] Failed to fetch supported tokens:", error)
|
|
124
|
-
})
|
|
125
|
-
.finally(() => {
|
|
126
|
-
setIsLoadingSupportedTokens(false)
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
}, [fundMethod])
|
|
118
|
+
// Note: Supported tokens are now fetched via useSupportedTokens hook with caching
|
|
130
119
|
|
|
131
120
|
const supportedChainIds = useMemo(() => {
|
|
132
121
|
return new Set(supportedToChains.map((c) => c.id))
|
|
133
122
|
}, [supportedToChains])
|
|
134
123
|
|
|
135
124
|
const sortedTokens = useMemo<Array<TokenBalanceExtended>>(() => {
|
|
136
|
-
// If fundMethod is "qr-code" or "exchange", use
|
|
125
|
+
// If fundMethod is "qr-code" or "exchange", use filtered supported tokens
|
|
137
126
|
if (fundMethod === "qr-code" || fundMethod === "exchange") {
|
|
138
127
|
// Filter to only show specific tokens for QR code and exchange modes
|
|
139
|
-
const filteredTokens =
|
|
128
|
+
const filteredTokens = supportedTokens.filter((token: any) => {
|
|
140
129
|
const symbol = token.symbol.toUpperCase()
|
|
141
130
|
return ["ETH", "POL", "USDC", "USDT", "DAI", "BAT", "WETH"].includes(
|
|
142
131
|
symbol,
|
|
@@ -144,7 +133,7 @@ export function useTokenList({
|
|
|
144
133
|
})
|
|
145
134
|
|
|
146
135
|
// Convert SupportedToken to TokenBalanceExtended format
|
|
147
|
-
return filteredTokens.map((token) => {
|
|
136
|
+
return filteredTokens.map((token: any) => {
|
|
148
137
|
// Check if it's a native token (like ETH)
|
|
149
138
|
if (
|
|
150
139
|
token.contractAddress === "0x0000000000000000000000000000000000000000"
|
|
@@ -199,16 +188,10 @@ export function useTokenList({
|
|
|
199
188
|
}
|
|
200
189
|
return true
|
|
201
190
|
})
|
|
202
|
-
}, [
|
|
203
|
-
allSortedTokens,
|
|
204
|
-
supportedChainIds,
|
|
205
|
-
fundMethod,
|
|
206
|
-
allSupportedTokens,
|
|
207
|
-
address,
|
|
208
|
-
])
|
|
191
|
+
}, [allSortedTokens, supportedChainIds, fundMethod, supportedTokens, address])
|
|
209
192
|
|
|
210
193
|
useEffect(() => {
|
|
211
|
-
if (onError) {
|
|
194
|
+
if (onError && balanceError) {
|
|
212
195
|
onError(balanceError)
|
|
213
196
|
}
|
|
214
197
|
}, [balanceError, onError])
|
|
@@ -359,95 +342,145 @@ export function useTokenList({
|
|
|
359
342
|
}, [sortedTokens, searchQuery])
|
|
360
343
|
|
|
361
344
|
const filteredTokensFormatted = useMemo(() => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
imageContractAddress =
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
isSufficientBalance =
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
345
|
+
// Get base formatted tokens
|
|
346
|
+
const baseFormattedTokens = filteredTokens.map(
|
|
347
|
+
(token: TokenBalanceExtended): TokenFormatted => {
|
|
348
|
+
const isNative = !("contractAddress" in token)
|
|
349
|
+
const chainInfo = getChainInfo(token.chainId)
|
|
350
|
+
const nativeSymbol = chainInfo?.nativeCurrency.symbol || "ETH"
|
|
351
|
+
const tokenSymbol = isNative
|
|
352
|
+
? nativeSymbol
|
|
353
|
+
: token.contractInfo?.symbol || "???"
|
|
354
|
+
const contractAddress = isNative ? zeroAddress : token.contractAddress
|
|
355
|
+
let imageContractAddress = contractAddress
|
|
356
|
+
if (tokenSymbol === "WETH") {
|
|
357
|
+
imageContractAddress = zeroAddress
|
|
358
|
+
}
|
|
359
|
+
const imageUrl = `https://assets.sequence.info/images/tokens/small/${token.chainId}/${imageContractAddress}.webp`
|
|
360
|
+
const currentTokenName =
|
|
361
|
+
(token as TokenBalanceWithPrice).contractInfo?.name || ""
|
|
362
|
+
const tokenName = getFormatttedTokenName(
|
|
363
|
+
currentTokenName,
|
|
364
|
+
tokenSymbol,
|
|
365
|
+
token.chainId,
|
|
366
|
+
)
|
|
367
|
+
const formattedBalance = formatRawAmount(
|
|
368
|
+
token.balance,
|
|
369
|
+
isNative ? 18 : token.contractInfo?.decimals,
|
|
370
|
+
)
|
|
371
|
+
const priceUsd = Number(token.price?.value) ?? 0
|
|
372
|
+
const balanceUsdFormatted = token.balanceUsdFormatted ?? ""
|
|
373
|
+
const decimals = isNative ? 18 : (token.contractInfo?.decimals ?? 18)
|
|
374
|
+
let isSufficientBalance = true
|
|
375
|
+
if (targetAmountUsd) {
|
|
376
|
+
isSufficientBalance = (token.balanceUsd ?? 0) >= targetAmountUsd
|
|
377
|
+
}
|
|
378
|
+
const chainName = chainInfo?.name || ""
|
|
379
|
+
|
|
380
|
+
return {
|
|
381
|
+
...token,
|
|
382
|
+
id: token.chainId,
|
|
383
|
+
contractInfo: {
|
|
384
|
+
...(token as TokenBalanceWithPrice).contractInfo,
|
|
385
|
+
chainId: Number(token.chainId),
|
|
386
|
+
source: (token as TokenBalanceWithPrice).contractInfo?.source || "",
|
|
387
|
+
type: (token as TokenBalanceWithPrice).contractInfo?.type || "",
|
|
388
|
+
logoURI:
|
|
389
|
+
(token as TokenBalanceWithPrice).contractInfo?.logoURI || "",
|
|
390
|
+
deployed:
|
|
391
|
+
(token as TokenBalanceWithPrice).contractInfo?.deployed || false,
|
|
392
|
+
bytecodeHash:
|
|
393
|
+
(token as TokenBalanceWithPrice).contractInfo?.bytecodeHash || "",
|
|
394
|
+
updatedAt:
|
|
395
|
+
(token as TokenBalanceWithPrice).contractInfo?.updatedAt || "",
|
|
396
|
+
queuedAt:
|
|
397
|
+
(token as TokenBalanceWithPrice).contractInfo?.queuedAt || "",
|
|
398
|
+
extensions: (token as TokenBalanceWithPrice).contractInfo
|
|
399
|
+
?.extensions || {
|
|
400
|
+
link: "",
|
|
401
|
+
description: "",
|
|
402
|
+
categories: [],
|
|
403
|
+
ogImage: "",
|
|
404
|
+
ogName: "",
|
|
405
|
+
originChainId: 0,
|
|
406
|
+
originAddress: "",
|
|
407
|
+
blacklist: false,
|
|
408
|
+
verified: false,
|
|
409
|
+
featureIndex: 0,
|
|
410
|
+
verifiedBy: "",
|
|
411
|
+
featured: false,
|
|
412
|
+
},
|
|
413
|
+
status:
|
|
414
|
+
(token as TokenBalanceWithPrice).contractInfo?.status ||
|
|
415
|
+
ResourceStatus.NOT_AVAILABLE,
|
|
416
|
+
address: contractAddress,
|
|
417
|
+
name: tokenName,
|
|
418
|
+
symbol: tokenSymbol,
|
|
419
|
+
decimals: decimals,
|
|
426
420
|
},
|
|
427
|
-
status:
|
|
428
|
-
(token as TokenBalanceWithPrice).contractInfo?.status ||
|
|
429
|
-
ResourceStatus.NOT_AVAILABLE,
|
|
430
|
-
address: contractAddress,
|
|
431
421
|
name: tokenName,
|
|
432
422
|
symbol: tokenSymbol,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
423
|
+
balanceFormatted: formattedBalance,
|
|
424
|
+
imageUrl,
|
|
425
|
+
chainId: token.chainId,
|
|
426
|
+
contractAddress: contractAddress,
|
|
427
|
+
balanceUsdFormatted,
|
|
428
|
+
tokenPriceUsd: priceUsd,
|
|
429
|
+
isNative: isNative,
|
|
430
|
+
tokenName: tokenName,
|
|
431
|
+
priceUsd: priceUsd,
|
|
432
|
+
isSufficientBalance,
|
|
433
|
+
chainName,
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
// If allSupportedTokens is true, combine with supported tokens
|
|
439
|
+
if (allSupportedTokens) {
|
|
440
|
+
// Create a set of existing token keys for quick lookup
|
|
441
|
+
const existingTokenKeys = new Set(
|
|
442
|
+
baseFormattedTokens.map(
|
|
443
|
+
(token) => `${token.chainId}-${token.contractAddress.toLowerCase()}`,
|
|
444
|
+
),
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
// Add supported tokens that don't exist in the base list
|
|
448
|
+
const additionalSupportedTokens = supportedTokens
|
|
449
|
+
.filter((supportedToken) => {
|
|
450
|
+
const key = `${supportedToken.chainId}-${supportedToken.contractAddress.toLowerCase()}`
|
|
451
|
+
return !existingTokenKeys.has(key)
|
|
452
|
+
})
|
|
453
|
+
.map((supportedToken) => {
|
|
454
|
+
const tokenName = getFormatttedTokenName(
|
|
455
|
+
supportedToken.name,
|
|
456
|
+
supportedToken.symbol,
|
|
457
|
+
supportedToken.chainId,
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
return {
|
|
461
|
+
...supportedToken,
|
|
462
|
+
tokenName: tokenName,
|
|
463
|
+
contractInfo: {
|
|
464
|
+
decimals: supportedToken.decimals,
|
|
465
|
+
symbol: supportedToken.symbol,
|
|
466
|
+
name: supportedToken.name,
|
|
467
|
+
},
|
|
468
|
+
// Add minimal required properties to make it work
|
|
469
|
+
balance: "",
|
|
470
|
+
balanceFormatted: "",
|
|
471
|
+
balanceUsdFormatted: "",
|
|
472
|
+
priceUsd: 0,
|
|
473
|
+
isSufficientBalance: true,
|
|
474
|
+
// Use any type to bypass strict type checking for now
|
|
475
|
+
} as any
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
// Combine lists with base tokens taking precedence
|
|
479
|
+
return [...baseFormattedTokens, ...additionalSupportedTokens]
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return baseFormattedTokens
|
|
483
|
+
}, [filteredTokens, targetAmountUsd, allSupportedTokens, supportedTokens])
|
|
451
484
|
|
|
452
485
|
const showInsufficientBalance = useMemo(() => {
|
|
453
486
|
return (
|