0xtrails 0.13.0 → 0.13.2
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/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
- package/dist/chains.d.ts +4 -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/customTokens.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/gasless.d.ts +1 -2
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +385 -333
- package/dist/intents.d.ts +8 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/keyMachineClient.d.ts +9 -0
- package/dist/keyMachineClient.d.ts.map +1 -0
- package/dist/keymachine/index.d.ts +14 -0
- package/dist/keymachine/index.d.ts.map +1 -0
- package/dist/keymachine/key-machine.gen.d.ts +461 -0
- package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +18 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
- package/dist/onramp/MeshConnectIframe.d.ts +13 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
- package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
- package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
- package/dist/onramp/index.d.ts +13 -0
- package/dist/onramp/index.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +30 -0
- package/dist/onramp/meshconnect.d.ts.map +1 -0
- package/dist/onramp/trailsOnramp.d.ts +24 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -0
- package/dist/onramp-client/index.d.ts +3 -3
- package/dist/onramp-client/index.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/balance.fetchers.d.ts +31 -2
- package/dist/query/balance.fetchers.d.ts.map +1 -1
- package/dist/query/balance.hooks.d.ts +21 -2
- package/dist/query/balance.hooks.d.ts.map +1 -1
- package/dist/query/balance.queries.d.ts +18 -1
- package/dist/query/balance.queries.d.ts.map +1 -1
- package/dist/query/chains.queries.d.ts.map +1 -1
- package/dist/query/meld.fetchers.d.ts +1 -1
- package/dist/query/meld.fetchers.d.ts.map +1 -1
- package/dist/query/meld.hooks.d.ts +3 -3
- package/dist/query/meld.hooks.d.ts.map +1 -1
- package/dist/query/meld.queries.d.ts +1 -1
- package/dist/query/meld.queries.d.ts.map +1 -1
- package/dist/query/price.fetchers.d.ts +15 -0
- package/dist/query/price.fetchers.d.ts.map +1 -0
- package/dist/query/price.hooks.d.ts +352 -0
- package/dist/query/price.hooks.d.ts.map +1 -0
- package/dist/query/price.queries.d.ts +34 -0
- package/dist/query/price.queries.d.ts.map +1 -0
- package/dist/query/tokenList.queries.d.ts +54 -0
- package/dist/query/tokenList.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +6 -4
- package/dist/recover.d.ts.map +1 -1
- package/dist/tokens.d.ts +13 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +1 -1
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +291 -202
- package/dist/utils/format.d.ts +7 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +2 -1
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/wallets.d.ts +13 -54
- 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/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DirectTransfer.d.ts +1 -1
- package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/ExecutionStatusBadge.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/HighPriceImpactBlock.d.ts +7 -0
- package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
- package/dist/widget/components/MeshExchangeSelection.d.ts.map +1 -0
- package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
- package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.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/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
- package/dist/widget/components/QRCodeWalletSelect.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/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.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/TransactionHistoryItem.d.ts +2 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletImage.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
- package/dist/widget/hooks/useGetIntent.d.ts +3 -2
- package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +2 -2
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useViewManager.d.ts +1 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +2 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
- package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
- package/dist/widget/utils/historyFilters.d.ts +13 -0
- package/dist/widget/utils/historyFilters.d.ts.map +1 -0
- package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
- package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
- package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
- package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
- package/dist/widget/utils/onrampConfig.d.ts +11 -0
- package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
- package/dist/widget/utils/statusLabel.d.ts +2 -0
- package/dist/widget/utils/statusLabel.d.ts.map +1 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +24 -8
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/chains.ts +26 -9
- package/src/constants.ts +2 -0
- package/src/customTokens.ts +22 -7
- package/src/error.ts +7 -0
- package/src/gasless.ts +5 -2
- package/src/index.ts +8 -5
- package/src/intents.ts +56 -60
- package/src/keyMachineClient.ts +29 -0
- package/src/keymachine/index.ts +175 -0
- package/src/keymachine/key-machine.gen.ts +993 -0
- package/src/onramp/MeshConnectFlow.tsx +86 -0
- package/src/onramp/MeshConnectIframe.tsx +661 -0
- package/src/onramp/SendFromExchangeButton.tsx +81 -0
- package/src/onramp/TrailsOnRampProvider.tsx +59 -0
- package/src/onramp/index.ts +31 -0
- package/src/onramp/meshconnect.ts +277 -0
- package/src/onramp/trailsOnramp.tsx +130 -0
- package/src/onramp-client/index.ts +4 -6
- package/src/paymasterSend.ts +0 -5
- package/src/prepareSend.ts +45 -44
- package/src/query/balance.fetchers.ts +172 -17
- package/src/query/balance.hooks.ts +69 -6
- package/src/query/balance.queries.ts +63 -0
- package/src/query/chains.queries.ts +1 -6
- package/src/query/meld.fetchers.ts +1 -1
- package/src/query/meld.hooks.ts +1 -1
- package/src/query/meld.queries.ts +1 -1
- package/src/query/price.fetchers.ts +53 -0
- package/src/query/price.hooks.ts +46 -0
- package/src/query/price.queries.ts +364 -0
- package/src/query/tokenList.queries.ts +118 -0
- package/src/recover.ts +89 -26
- package/src/tokens.ts +108 -26
- package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
- package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
- package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
- package/src/transactionIntent/handlers/intentHandler.ts +29 -12
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
- package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
- package/src/transactionIntent/types.ts +1 -1
- package/src/transactions.ts +5 -1
- package/src/utils/format.ts +85 -1
- package/src/walletUtils.ts +2 -1
- package/src/wallets.ts +184 -380
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
- package/src/widget/components/ClassicSwap.tsx +26 -24
- package/src/widget/components/ConnectWallet.tsx +4 -2
- package/src/widget/components/ConnectedWallets.tsx +2 -5
- package/src/widget/components/DirectTransfer.tsx +5 -2
- package/src/widget/components/EarnPools.tsx +1 -2
- package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
- package/src/widget/components/Fund.tsx +169 -110
- package/src/widget/components/FundMethods.tsx +5 -9
- package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
- package/src/widget/components/MeldHistory.tsx +4 -28
- package/src/widget/components/MeshExchangeSelection.tsx +218 -0
- package/src/widget/components/OnrampHistoryRow.tsx +3 -27
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
- package/src/widget/components/Pay.tsx +20 -36
- package/src/widget/components/PoolDeposit.tsx +14 -24
- package/src/widget/components/PoolWithdraw.tsx +1 -63
- package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
- package/src/widget/components/QuoteDetails.tsx +113 -106
- package/src/widget/components/Receipt.tsx +0 -11
- package/src/widget/components/Recipients.tsx +2 -1
- package/src/widget/components/RefundWarning.tsx +5 -10
- package/src/widget/components/ThemeProvider.tsx +4 -4
- package/src/widget/components/TokenSelector.tsx +85 -16
- package/src/widget/components/TransactionDetails.tsx +46 -0
- package/src/widget/components/TransactionHistoryItem.tsx +14 -23
- package/src/widget/components/TransferPendingVertical.tsx +17 -11
- package/src/widget/components/WaasFeeOptions.tsx +4 -42
- package/src/widget/components/WalletConnect.tsx +2 -5
- package/src/widget/components/WalletImage.tsx +6 -18
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/components/Withdraw.tsx +22 -23
- package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
- package/src/widget/hooks/useAmountUsd.ts +1 -1
- package/src/widget/hooks/useCombinedHistory.ts +37 -93
- package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
- package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
- package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
- package/src/widget/hooks/useGetIntent.ts +5 -4
- package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
- package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
- package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
- package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
- package/src/widget/hooks/useOnRampQuote.ts +3 -3
- package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
- package/src/widget/hooks/useQuote.ts +56 -48
- package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
- package/src/widget/hooks/useSendForm.ts +52 -31
- package/src/widget/hooks/useTokenList.ts +209 -140
- package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
- package/src/widget/hooks/useViewManager.tsx +1 -0
- package/src/widget/providers/TrailsProvider.tsx +5 -0
- package/src/widget/styles.ts +1 -1
- package/src/widget/utils/createWagmiConfig.ts +7 -2
- package/src/widget/utils/fundMethodSwitchState.ts +2 -0
- package/src/widget/utils/historyFilters.ts +157 -0
- package/src/widget/utils/meldProviderUtils.ts +8 -2
- package/src/widget/utils/meshSupportedTokens.ts +28 -0
- package/src/widget/utils/onrampConfig.ts +15 -0
- package/src/widget/utils/statusLabel.ts +3 -0
- package/src/widget/utils/trailsOnrampConfig.ts +39 -0
- package/src/widget/widget.tsx +235 -185
- package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
- package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
- package/dist/prices.d.ts +0 -34
- package/dist/prices.d.ts.map +0 -1
- package/dist/useGasEstimation.d.ts +0 -34
- package/dist/useGasEstimation.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
- package/src/onramp-client/trails-onramp.gen.ts +0 -1320
- package/src/prices.ts +0 -528
- package/src/useGasEstimation.ts +0 -147
- package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
- package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
- package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
- package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
- package/src/widget/assets/sequence-logo.svg +0 -15
- package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
- package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
|
@@ -5,7 +5,6 @@ import { useAccount } from "wagmi"
|
|
|
5
5
|
import { useQuery } from "@tanstack/react-query"
|
|
6
6
|
import { getChainInfo } from "../../chains.js"
|
|
7
7
|
import { useSupportedChains } from "../../query/chains.hooks.js"
|
|
8
|
-
import { SECOND_MS, MINUTE_MS, DAY_MS } from "../../utils/time.js"
|
|
9
8
|
import type { Token } from "../../tokens.js"
|
|
10
9
|
import {
|
|
11
10
|
addressEqual,
|
|
@@ -25,13 +24,22 @@ import {
|
|
|
25
24
|
} from "../../utils/format.js"
|
|
26
25
|
import { useSupportedTokens, useGetTokenImageUrl } from "../../tokens.js"
|
|
27
26
|
import { useTrailsClient } from "../../trailsClient.js"
|
|
28
|
-
import { useTokenPrices } from "../../
|
|
27
|
+
import { useTokenPrices } from "../../query/price.hooks.js"
|
|
29
28
|
import { logger } from "../../logger.js"
|
|
29
|
+
import { useOnrampClient } from "../../onrampClient.js"
|
|
30
|
+
import type { MeshSupportedToken } from "@0xtrails/api/onramp"
|
|
30
31
|
import { useTrails } from "../providers/TrailsProvider.js"
|
|
31
|
-
import {
|
|
32
|
+
import { isMeshAssetSupported } from "../utils/meshSupportedTokens.js"
|
|
33
|
+
import { getActiveMeshEnvironment } from "../utils/onrampConfig.js"
|
|
34
|
+
import { getWidgetOnrampConfig } from "../utils/trailsOnrampConfig.js"
|
|
35
|
+
import { DAY_MS } from "../../utils/time.js"
|
|
32
36
|
import { useChainFilter } from "./useChainFilter.js"
|
|
37
|
+
import { useCustomTokenSearch } from "./useCustomTokenSearch.js"
|
|
33
38
|
import { useDebounce } from "./useDebounce.js"
|
|
39
|
+
import { useSelectedFundMethod } from "./useSelectedFundMethod.js"
|
|
40
|
+
import { useWidgetProps } from "./useWidgetProps.js"
|
|
34
41
|
import type { FundMethod } from "../../transactionIntent/types.js"
|
|
42
|
+
import { tokenListQueries } from "../../query/tokenList.queries.js"
|
|
35
43
|
|
|
36
44
|
// Standard tokens for QR code and exchange modes
|
|
37
45
|
const STANDARD_TOKENS = [
|
|
@@ -162,6 +170,7 @@ export type UseTokenListProps = {
|
|
|
162
170
|
fundMethod?: FundMethod | null
|
|
163
171
|
allSupportedTokens?: boolean
|
|
164
172
|
includePrice?: boolean
|
|
173
|
+
balanceRefetchInterval?: number | false
|
|
165
174
|
}
|
|
166
175
|
|
|
167
176
|
export type UseTokenListReturn = {
|
|
@@ -169,9 +178,14 @@ export type UseTokenListReturn = {
|
|
|
169
178
|
searchQuery: string
|
|
170
179
|
handleTokenSelect: (token: Token) => void
|
|
171
180
|
filteredTokens: Token[]
|
|
181
|
+
chainFilteredTokens: Token[]
|
|
182
|
+
/** All tokens found by findContractInfo across every supported chain (unfiltered by chain selector). */
|
|
183
|
+
foundTokensAllChains: Token[]
|
|
172
184
|
isLoadingSortedTokens: boolean
|
|
173
185
|
isLoadingSearchTokens?: boolean
|
|
186
|
+
isLoadingCustomToken: boolean
|
|
174
187
|
isSearching: boolean // True when search is in progress (typing)
|
|
188
|
+
customTokenError: Error | null
|
|
175
189
|
balanceError: Error | null
|
|
176
190
|
showContinueButton: boolean
|
|
177
191
|
isTokenSelected: (token: Token) => boolean
|
|
@@ -191,26 +205,50 @@ export function useTokenList({
|
|
|
191
205
|
fundMethod,
|
|
192
206
|
allSupportedTokens = false,
|
|
193
207
|
includePrice = false,
|
|
208
|
+
balanceRefetchInterval = WIDGET_REFRESH_INTERVAL,
|
|
194
209
|
}: UseTokenListProps): UseTokenListReturn {
|
|
195
210
|
const [selectedToken, setSelectedToken] = useState<Token | null>(null)
|
|
196
211
|
const [searchQuery, setSearchQuery] = useState("")
|
|
197
212
|
const { address } = useAccount()
|
|
198
213
|
const trailsClient = useTrailsClient()
|
|
199
214
|
const { getTokenImageUrl } = useGetTokenImageUrl()
|
|
215
|
+
const shouldSkipBalanceQueries = !!fundMethod && fundMethod !== "wallet"
|
|
216
|
+
const balanceQueryAccount = shouldSkipBalanceQueries
|
|
217
|
+
? null
|
|
218
|
+
: (address as Address.Address)
|
|
219
|
+
|
|
200
220
|
const {
|
|
201
221
|
sortedTokens: allSortedTokens,
|
|
202
222
|
isLoadingSortedTokens,
|
|
203
223
|
balanceError,
|
|
204
|
-
} = useTokenBalances(
|
|
205
|
-
|
|
224
|
+
} = useTokenBalances(balanceQueryAccount, undefined, {
|
|
225
|
+
disabled: shouldSkipBalanceQueries,
|
|
226
|
+
refetchInterval: shouldSkipBalanceQueries ? false : balanceRefetchInterval,
|
|
206
227
|
})
|
|
207
228
|
|
|
208
|
-
//
|
|
229
|
+
// Only fetch the full token catalog when needed (non-wallet fund methods
|
|
230
|
+
// or destination selector with allSupportedTokens). For the wallet source
|
|
231
|
+
// selector we only show user balance tokens.
|
|
232
|
+
const needsSupportedTokens =
|
|
233
|
+
(fundMethod && fundMethod !== "wallet") || allSupportedTokens
|
|
209
234
|
const { supportedTokens, isLoadingTokens: isLoadingSupportedTokens } =
|
|
210
|
-
useSupportedTokens()
|
|
235
|
+
useSupportedTokens({ disabled: !needsSupportedTokens })
|
|
211
236
|
|
|
212
237
|
// Get trails config for API calls
|
|
213
238
|
const trailsConfig = useTrails()
|
|
239
|
+
const { onramp: onrampFactory } = useWidgetProps()
|
|
240
|
+
const { selectedMeshExchange } = useSelectedFundMethod()
|
|
241
|
+
const onrampClient = useOnrampClient()
|
|
242
|
+
const meshOnrampConfig = getWidgetOnrampConfig(onrampFactory)
|
|
243
|
+
const meshEnvironment = getActiveMeshEnvironment(meshOnrampConfig)
|
|
244
|
+
const meshEnabled = !!meshOnrampConfig?.mesh
|
|
245
|
+
const meshAllowedExchanges = meshOnrampConfig?.mesh?.exchanges ?? null
|
|
246
|
+
const activeMeshIntegrationIds = selectedMeshExchange
|
|
247
|
+
? [selectedMeshExchange.integrationId]
|
|
248
|
+
: null
|
|
249
|
+
const activeMeshExchangeKeys = selectedMeshExchange
|
|
250
|
+
? null
|
|
251
|
+
: meshAllowedExchanges
|
|
214
252
|
|
|
215
253
|
// Get supported chains for getTokenList API
|
|
216
254
|
const { data: supportedChains = [] } = useSupportedChains()
|
|
@@ -223,6 +261,8 @@ export function useTokenList({
|
|
|
223
261
|
// For other modes, we only filter user's token balances locally
|
|
224
262
|
const shouldUseApiSearch =
|
|
225
263
|
(fundMethod && fundMethod !== "wallet") || allSupportedTokens
|
|
264
|
+
const shouldFilterMeshTokens =
|
|
265
|
+
fundMethod === "onramp-mesh" && !allSupportedTokens
|
|
226
266
|
|
|
227
267
|
// Memoize chain IDs to avoid recalculating
|
|
228
268
|
const apiSearchChainIds = useMemo(
|
|
@@ -245,60 +285,25 @@ export function useTokenList({
|
|
|
245
285
|
// Call getTokenList API when there's a search query (for any search, not just addresses)
|
|
246
286
|
const { data: searchTokensResult, isLoading: isLoadingSearchTokens } =
|
|
247
287
|
useQuery({
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return { tokens: [] }
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
const response = await trailsClient.getTokenList({
|
|
267
|
-
searchQuery: debouncedSearchQuery,
|
|
268
|
-
chainIds: apiSearchChainIds,
|
|
269
|
-
includeAllListed: true,
|
|
270
|
-
limit: 30,
|
|
271
|
-
})
|
|
272
|
-
return response
|
|
273
|
-
} catch (error) {
|
|
274
|
-
logger.console.warn("[trails-sdk] Error searching tokens:", error)
|
|
275
|
-
return { tokens: [] }
|
|
276
|
-
}
|
|
277
|
-
},
|
|
288
|
+
...tokenListQueries.search(
|
|
289
|
+
trailsClient,
|
|
290
|
+
{
|
|
291
|
+
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
292
|
+
trailsApiKey: trailsConfig.trailsApiKey,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
searchQuery: debouncedSearchQuery,
|
|
296
|
+
// For getTokenList, pass a chain id if selected
|
|
297
|
+
chainIds:
|
|
298
|
+
filterByChainId !== null ? [filterByChainId] : apiSearchChainIds,
|
|
299
|
+
limit: 30,
|
|
300
|
+
},
|
|
301
|
+
),
|
|
278
302
|
enabled:
|
|
279
303
|
shouldUseApiSearch &&
|
|
280
304
|
debouncedSearchQuery.length > 0 &&
|
|
281
305
|
!!trailsClient &&
|
|
282
306
|
!!trailsConfig.trailsApiKey,
|
|
283
|
-
staleTime: 30 * SECOND_MS, // 30 seconds
|
|
284
|
-
gcTime: 5 * MINUTE_MS, // 5 minutes
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
// Fetch custom token info if searching by address and getTokenList returned no results
|
|
288
|
-
const hasNoSearchResults = searchTokensResult?.tokens?.length === 0
|
|
289
|
-
const shouldFetchCustomToken =
|
|
290
|
-
shouldUseApiSearch &&
|
|
291
|
-
isSearchQueryAddress &&
|
|
292
|
-
hasNoSearchResults &&
|
|
293
|
-
!isLoadingSearchTokens &&
|
|
294
|
-
trimmedSearchQuery.length > 0
|
|
295
|
-
const customTokenChainId = supportedChains[0]?.id ?? null
|
|
296
|
-
|
|
297
|
-
const { tokenInfo: customTokenInfo, isLoading: isLoadingCustomToken } =
|
|
298
|
-
useCustomTokenFetch({
|
|
299
|
-
address: shouldFetchCustomToken ? trimmedSearchQuery : null,
|
|
300
|
-
chainId: customTokenChainId,
|
|
301
|
-
enabled: shouldFetchCustomToken,
|
|
302
307
|
})
|
|
303
308
|
|
|
304
309
|
// Fetch tokens from getTokenList when a chain is selected (for destination token list only)
|
|
@@ -306,51 +311,77 @@ export function useTokenList({
|
|
|
306
311
|
const {
|
|
307
312
|
data: chainFilteredTokenList,
|
|
308
313
|
isLoading: isLoadingChainFilteredTokens,
|
|
314
|
+
} = useQuery({
|
|
315
|
+
...tokenListQueries.byChain(
|
|
316
|
+
trailsClient,
|
|
317
|
+
{
|
|
318
|
+
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
319
|
+
trailsApiKey: trailsConfig.trailsApiKey,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
chainId: filterByChainId,
|
|
323
|
+
limit: 100,
|
|
324
|
+
},
|
|
325
|
+
),
|
|
326
|
+
enabled:
|
|
327
|
+
shouldUseApiSearch &&
|
|
328
|
+
filterByChainId !== null &&
|
|
329
|
+
!!trailsClient &&
|
|
330
|
+
!!trailsConfig.trailsApiKey,
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
const {
|
|
334
|
+
data: meshSupportedTokens = [],
|
|
335
|
+
isLoading: isLoadingMeshSupportedTokens,
|
|
309
336
|
} = useQuery({
|
|
310
337
|
queryKey: [
|
|
311
|
-
"
|
|
312
|
-
|
|
338
|
+
"mesh-supported-tokens",
|
|
339
|
+
meshEnvironment,
|
|
340
|
+
activeMeshExchangeKeys,
|
|
313
341
|
trailsConfig.trailsApiUrl,
|
|
314
342
|
trailsConfig.trailsApiKey,
|
|
315
343
|
],
|
|
316
344
|
queryFn: async () => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
!trailsConfig.trailsApiKey ||
|
|
321
|
-
!shouldUseApiSearch
|
|
322
|
-
) {
|
|
323
|
-
return { tokens: [] }
|
|
324
|
-
}
|
|
345
|
+
const response = await onrampClient.getMeshSupportedTokens({
|
|
346
|
+
environment: meshEnvironment,
|
|
347
|
+
})
|
|
325
348
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
limit: 100,
|
|
332
|
-
})
|
|
333
|
-
return response
|
|
334
|
-
} catch (error) {
|
|
335
|
-
logger.console.warn(
|
|
336
|
-
"[trails-sdk] Error fetching tokens for chain filter:",
|
|
337
|
-
error,
|
|
349
|
+
if (activeMeshIntegrationIds?.length) {
|
|
350
|
+
return (response.tokens || []).filter((token: MeshSupportedToken) =>
|
|
351
|
+
(token.integrationIds || []).some((integrationId) =>
|
|
352
|
+
activeMeshIntegrationIds.includes(integrationId),
|
|
353
|
+
),
|
|
338
354
|
)
|
|
339
|
-
return { tokens: [] }
|
|
340
355
|
}
|
|
356
|
+
|
|
357
|
+
if (!activeMeshExchangeKeys?.length) {
|
|
358
|
+
return response.tokens || []
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return (response.tokens || []).filter((token: MeshSupportedToken) =>
|
|
362
|
+
(token.exchangeKeys || []).some((exchangeKey) =>
|
|
363
|
+
activeMeshExchangeKeys.includes(exchangeKey),
|
|
364
|
+
),
|
|
365
|
+
)
|
|
341
366
|
},
|
|
342
367
|
enabled:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
!!
|
|
346
|
-
!!trailsConfig.
|
|
347
|
-
staleTime: DAY_MS,
|
|
348
|
-
gcTime: DAY_MS,
|
|
368
|
+
fundMethod === "onramp-mesh" &&
|
|
369
|
+
meshEnabled &&
|
|
370
|
+
!!trailsConfig.trailsApiKey &&
|
|
371
|
+
!!trailsConfig.trailsApiUrl,
|
|
372
|
+
staleTime: DAY_MS,
|
|
373
|
+
gcTime: DAY_MS,
|
|
349
374
|
refetchOnMount: false,
|
|
350
375
|
refetchOnWindowFocus: false,
|
|
351
376
|
refetchOnReconnect: false,
|
|
352
377
|
})
|
|
353
378
|
|
|
379
|
+
const isSupportedMeshToken = useMemo(
|
|
380
|
+
() => (chainId?: number | null, symbol?: string | null) =>
|
|
381
|
+
isMeshAssetSupported(meshSupportedTokens, chainId, symbol),
|
|
382
|
+
[meshSupportedTokens],
|
|
383
|
+
)
|
|
384
|
+
|
|
354
385
|
// Fetch prices for supported tokens when allSupportedTokens is true OR for qr-code/exchange/meld modes
|
|
355
386
|
const supportedTokensForPricing = useMemo(() => {
|
|
356
387
|
if (
|
|
@@ -363,7 +394,9 @@ export function useTokenList({
|
|
|
363
394
|
|
|
364
395
|
const filteredTokens = supportedTokens.filter((token: any) => {
|
|
365
396
|
const symbol = token.symbol.toUpperCase()
|
|
366
|
-
return
|
|
397
|
+
return shouldFilterMeshTokens
|
|
398
|
+
? isSupportedMeshToken(token.chainId, token.symbol)
|
|
399
|
+
: STANDARD_TOKENS.includes(symbol as any)
|
|
367
400
|
})
|
|
368
401
|
|
|
369
402
|
return filteredTokens.map((token: any) => ({
|
|
@@ -380,7 +413,13 @@ export function useTokenList({
|
|
|
380
413
|
tokenAddress: token.contractAddress || zeroAddress,
|
|
381
414
|
tokenSymbol: token.symbol,
|
|
382
415
|
}))
|
|
383
|
-
}, [
|
|
416
|
+
}, [
|
|
417
|
+
allSupportedTokens,
|
|
418
|
+
supportedTokens,
|
|
419
|
+
fundMethod,
|
|
420
|
+
isSupportedMeshToken,
|
|
421
|
+
shouldFilterMeshTokens,
|
|
422
|
+
])
|
|
384
423
|
|
|
385
424
|
const {
|
|
386
425
|
tokenPrices: supportedTokenPrices,
|
|
@@ -392,8 +431,8 @@ export function useTokenList({
|
|
|
392
431
|
fundMethod && fundMethod !== "wallet"
|
|
393
432
|
? isLoadingSupportedTokens ||
|
|
394
433
|
isLoadingSupportedTokenPrices ||
|
|
434
|
+
isLoadingMeshSupportedTokens ||
|
|
395
435
|
isLoadingSearchTokens ||
|
|
396
|
-
isLoadingCustomToken ||
|
|
397
436
|
isLoadingChainFilteredTokens
|
|
398
437
|
: allSupportedTokens
|
|
399
438
|
? isLoadingSortedTokens ||
|
|
@@ -403,28 +442,32 @@ export function useTokenList({
|
|
|
403
442
|
: isLoadingSortedTokens
|
|
404
443
|
|
|
405
444
|
const { data: totalBalanceUsd = 0, isLoading: isLoadingTotalBalanceUsd } =
|
|
406
|
-
useAccountTotalBalanceUsd(
|
|
445
|
+
useAccountTotalBalanceUsd(balanceQueryAccount)
|
|
407
446
|
const totalBalanceUsdFormatted = formatUsdAmountDisplay(totalBalanceUsd)
|
|
408
447
|
const {
|
|
409
448
|
data: hasSufficientBalanceUsd = false,
|
|
410
449
|
isLoading: isLoadingHasSufficientBalanceUsd,
|
|
411
450
|
error: hasSufficientBalanceUsdError,
|
|
412
|
-
} = useHasSufficientBalanceUsd(
|
|
451
|
+
} = useHasSufficientBalanceUsd(
|
|
452
|
+
balanceQueryAccount,
|
|
453
|
+
shouldSkipBalanceQueries ? null : targetAmountUsd,
|
|
454
|
+
)
|
|
413
455
|
const showContinueButton = false
|
|
414
456
|
// Note: Supported tokens are now fetched via useSupportedTokens hook with caching
|
|
415
457
|
|
|
416
458
|
// Map chain-filtered token list results to Token format
|
|
417
459
|
// Used when a chain is selected for destination token list
|
|
418
460
|
const chainFilteredApiTokens = useMemo(() => {
|
|
461
|
+
const chainTokens = (chainFilteredTokenList?.tokens ?? []) as ApiTokenInfo[]
|
|
419
462
|
if (
|
|
420
463
|
!shouldUseApiSearch ||
|
|
421
|
-
|
|
464
|
+
chainTokens.length === 0 ||
|
|
422
465
|
filterByChainId === null
|
|
423
466
|
) {
|
|
424
467
|
return []
|
|
425
468
|
}
|
|
426
469
|
|
|
427
|
-
|
|
470
|
+
const tokens = chainTokens
|
|
428
471
|
.filter((tokenInfo: ApiTokenInfo) => {
|
|
429
472
|
if (!isValidDecimals(tokenInfo.decimals)) {
|
|
430
473
|
logger.console.warn(
|
|
@@ -442,11 +485,19 @@ export function useTokenList({
|
|
|
442
485
|
.map((tokenInfo: ApiTokenInfo) =>
|
|
443
486
|
convertApiTokenToToken(tokenInfo, getTokenImageUrl),
|
|
444
487
|
)
|
|
488
|
+
|
|
489
|
+
return shouldFilterMeshTokens
|
|
490
|
+
? tokens.filter((token) =>
|
|
491
|
+
isSupportedMeshToken(token.chainId, token.symbol),
|
|
492
|
+
)
|
|
493
|
+
: tokens
|
|
445
494
|
}, [
|
|
446
495
|
chainFilteredTokenList,
|
|
447
496
|
getTokenImageUrl,
|
|
448
497
|
shouldUseApiSearch,
|
|
449
498
|
filterByChainId,
|
|
499
|
+
shouldFilterMeshTokens,
|
|
500
|
+
isSupportedMeshToken,
|
|
450
501
|
])
|
|
451
502
|
|
|
452
503
|
const sortedTokens = useMemo<Array<Token>>(() => {
|
|
@@ -501,13 +552,19 @@ export function useTokenList({
|
|
|
501
552
|
}
|
|
502
553
|
}
|
|
503
554
|
|
|
504
|
-
return
|
|
555
|
+
return shouldFilterMeshTokens
|
|
556
|
+
? mergedTokens.filter((token) =>
|
|
557
|
+
isSupportedMeshToken(token.chainId, token.symbol),
|
|
558
|
+
)
|
|
559
|
+
: mergedTokens
|
|
505
560
|
}
|
|
506
561
|
|
|
507
562
|
// Filter to only show specific tokens for QR code and exchange modes
|
|
508
563
|
const filteredTokens = supportedTokens.filter((token: any) => {
|
|
509
564
|
const symbol = token.symbol.toUpperCase()
|
|
510
|
-
return
|
|
565
|
+
return shouldFilterMeshTokens
|
|
566
|
+
? isSupportedMeshToken(token.chainId, token.symbol)
|
|
567
|
+
: STANDARD_TOKENS.includes(symbol as any)
|
|
511
568
|
})
|
|
512
569
|
|
|
513
570
|
// Convert SupportedToken to Token format and add price data
|
|
@@ -541,9 +598,15 @@ export function useTokenList({
|
|
|
541
598
|
)
|
|
542
599
|
|
|
543
600
|
// Sort by price (highest first) since volume is not available
|
|
544
|
-
|
|
601
|
+
const sortedMeshTokens = tokensWithPrices.sort((a, b) => {
|
|
545
602
|
return (b.priceUsd || 0) - (a.priceUsd || 0)
|
|
546
603
|
})
|
|
604
|
+
|
|
605
|
+
return shouldFilterMeshTokens
|
|
606
|
+
? sortedMeshTokens.filter((token) =>
|
|
607
|
+
isSupportedMeshToken(token.chainId, token.symbol),
|
|
608
|
+
)
|
|
609
|
+
: sortedMeshTokens
|
|
547
610
|
}
|
|
548
611
|
|
|
549
612
|
// If allSupportedTokens is true and chain filter is active, use chain-filtered tokens
|
|
@@ -604,6 +667,8 @@ export function useTokenList({
|
|
|
604
667
|
fundMethod,
|
|
605
668
|
supportedTokens,
|
|
606
669
|
supportedTokenPrices,
|
|
670
|
+
isSupportedMeshToken,
|
|
671
|
+
shouldFilterMeshTokens,
|
|
607
672
|
shouldUseApiSearch,
|
|
608
673
|
filterByChainId,
|
|
609
674
|
chainFilteredApiTokens,
|
|
@@ -665,11 +730,12 @@ export function useTokenList({
|
|
|
665
730
|
// Map API search results to Token format
|
|
666
731
|
// Only used for exchange/qr-code modes
|
|
667
732
|
const apiSearchTokens = useMemo(() => {
|
|
668
|
-
|
|
733
|
+
const searchTokens = (searchTokensResult?.tokens ?? []) as ApiTokenInfo[]
|
|
734
|
+
if (!shouldUseApiSearch || searchTokens.length === 0) {
|
|
669
735
|
return []
|
|
670
736
|
}
|
|
671
737
|
|
|
672
|
-
|
|
738
|
+
const tokens = searchTokens
|
|
673
739
|
.filter((tokenInfo: ApiTokenInfo) => {
|
|
674
740
|
if (!isValidDecimals(tokenInfo.decimals)) {
|
|
675
741
|
logger.console.warn(
|
|
@@ -687,42 +753,21 @@ export function useTokenList({
|
|
|
687
753
|
.map((tokenInfo: ApiTokenInfo) =>
|
|
688
754
|
convertApiTokenToToken(tokenInfo, getTokenImageUrl),
|
|
689
755
|
)
|
|
690
|
-
}, [searchTokensResult, getTokenImageUrl, shouldUseApiSearch])
|
|
691
|
-
|
|
692
|
-
// Convert custom token info to Token format
|
|
693
|
-
const customTokenAsTokenBalance = useMemo(() => {
|
|
694
|
-
if (!customTokenInfo || !customTokenChainId) return null
|
|
695
|
-
|
|
696
|
-
const chainInfo = getChainInfo(customTokenChainId)
|
|
697
|
-
const validatedDecimals = validateDecimals(customTokenInfo.decimals)
|
|
698
|
-
|
|
699
|
-
return {
|
|
700
|
-
symbol: customTokenInfo.symbol,
|
|
701
|
-
name: customTokenInfo.name,
|
|
702
|
-
decimals: validatedDecimals,
|
|
703
|
-
contractAddress: customTokenInfo.contractAddress,
|
|
704
|
-
chainId: customTokenChainId,
|
|
705
|
-
chainName: chainInfo?.name || `Chain ${customTokenChainId}`,
|
|
706
|
-
imageUrl: getTokenImageUrl({
|
|
707
|
-
chainId: customTokenChainId,
|
|
708
|
-
contractAddress: customTokenInfo.contractAddress,
|
|
709
|
-
symbol: customTokenInfo.symbol,
|
|
710
|
-
}),
|
|
711
|
-
isCustomToken: true,
|
|
712
|
-
} as Token
|
|
713
|
-
}, [customTokenInfo, customTokenChainId, getTokenImageUrl])
|
|
714
756
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
757
|
+
return shouldFilterMeshTokens
|
|
758
|
+
? tokens.filter((token) =>
|
|
759
|
+
isSupportedMeshToken(token.chainId, token.symbol),
|
|
760
|
+
)
|
|
761
|
+
: tokens
|
|
762
|
+
}, [
|
|
763
|
+
searchTokensResult,
|
|
764
|
+
getTokenImageUrl,
|
|
765
|
+
shouldUseApiSearch,
|
|
766
|
+
shouldFilterMeshTokens,
|
|
767
|
+
isSupportedMeshToken,
|
|
768
|
+
])
|
|
725
769
|
|
|
770
|
+
const filteredTokens = useMemo(() => {
|
|
726
771
|
// sortedTokens is already Token[] from useTokenBalances
|
|
727
772
|
// Only use API search results for exchange/qr-code modes
|
|
728
773
|
if (
|
|
@@ -853,15 +898,7 @@ export function useTokenList({
|
|
|
853
898
|
|
|
854
899
|
return bScore - aScore // Higher score first
|
|
855
900
|
})
|
|
856
|
-
}, [
|
|
857
|
-
sortedTokens,
|
|
858
|
-
trimmedSearchQuery,
|
|
859
|
-
apiSearchTokens,
|
|
860
|
-
shouldUseApiSearch,
|
|
861
|
-
isSearchQueryAddress,
|
|
862
|
-
hasNoSearchResults,
|
|
863
|
-
customTokenAsTokenBalance,
|
|
864
|
-
])
|
|
901
|
+
}, [sortedTokens, trimmedSearchQuery, apiSearchTokens, shouldUseApiSearch])
|
|
865
902
|
|
|
866
903
|
const filteredTokensFormatted = useMemo(() => {
|
|
867
904
|
// Get base formatted tokens - filteredTokens is already Token[]
|
|
@@ -924,6 +961,13 @@ export function useTokenList({
|
|
|
924
961
|
// Add supported tokens that don't exist in the base list
|
|
925
962
|
const additionalSupportedTokens: Token[] = supportedTokens
|
|
926
963
|
.filter((supportedToken) => {
|
|
964
|
+
if (
|
|
965
|
+
shouldFilterMeshTokens &&
|
|
966
|
+
!isSupportedMeshToken(supportedToken.chainId, supportedToken.symbol)
|
|
967
|
+
) {
|
|
968
|
+
return false
|
|
969
|
+
}
|
|
970
|
+
|
|
927
971
|
const key = `${supportedToken.chainId || 0}-${normalizeAddress(supportedToken.contractAddress)}`
|
|
928
972
|
return !existingTokenKeys.has(key)
|
|
929
973
|
})
|
|
@@ -1053,6 +1097,8 @@ export function useTokenList({
|
|
|
1053
1097
|
supportedTokens,
|
|
1054
1098
|
supportedTokenPrices,
|
|
1055
1099
|
searchQuery,
|
|
1100
|
+
shouldFilterMeshTokens,
|
|
1101
|
+
isSupportedMeshToken,
|
|
1056
1102
|
])
|
|
1057
1103
|
|
|
1058
1104
|
const showInsufficientBalance = useMemo(() => {
|
|
@@ -1077,14 +1123,37 @@ export function useTokenList({
|
|
|
1077
1123
|
// isSearching: true when user is typing (debounce pending) or API is fetching
|
|
1078
1124
|
const isSearching = isSearchPending || isLoadingSearchTokens
|
|
1079
1125
|
|
|
1126
|
+
// True when an address search via the trailsApi.getTokenList has finished with zero results.
|
|
1127
|
+
const isApiAddressSearchComplete =
|
|
1128
|
+
isSearchQueryAddress &&
|
|
1129
|
+
!isLoadingSearchTokens &&
|
|
1130
|
+
!isSearchPending &&
|
|
1131
|
+
(searchTokensResult?.tokens?.length ?? 0) === 0
|
|
1132
|
+
|
|
1133
|
+
const {
|
|
1134
|
+
chainFilteredTokens,
|
|
1135
|
+
foundTokensAllChains,
|
|
1136
|
+
isLoadingCustomToken,
|
|
1137
|
+
customTokenError,
|
|
1138
|
+
} = useCustomTokenSearch({
|
|
1139
|
+
searchQuery,
|
|
1140
|
+
filteredTokensFormatted,
|
|
1141
|
+
filterByChainId,
|
|
1142
|
+
isApiAddressSearchComplete,
|
|
1143
|
+
})
|
|
1144
|
+
|
|
1080
1145
|
return {
|
|
1081
1146
|
selectedToken,
|
|
1082
1147
|
searchQuery,
|
|
1083
1148
|
handleTokenSelect,
|
|
1084
1149
|
filteredTokens,
|
|
1150
|
+
chainFilteredTokens,
|
|
1151
|
+
foundTokensAllChains,
|
|
1085
1152
|
isLoadingSortedTokens: isLoadingSortedTokens || isLoadingSearchTokens,
|
|
1086
1153
|
isLoadingSearchTokens,
|
|
1154
|
+
isLoadingCustomToken,
|
|
1087
1155
|
isSearching,
|
|
1156
|
+
customTokenError,
|
|
1088
1157
|
balanceError,
|
|
1089
1158
|
showContinueButton,
|
|
1090
1159
|
isTokenSelected,
|
|
@@ -18,7 +18,7 @@ import { balanceQueries } from "../../query/balance.queries.js"
|
|
|
18
18
|
import { checkSufficientToken } from "../../query/balance.fetchers.js"
|
|
19
19
|
import { useSupportedTokens } from "../../tokens.js"
|
|
20
20
|
import { getChainInfo } from "../../chains.js"
|
|
21
|
-
import { getTokenPrice } from "../../
|
|
21
|
+
import { getTokenPrice } from "../../query/price.queries.js"
|
|
22
22
|
import { findSupportedToken } from "../utils/tokens.js"
|
|
23
23
|
import { zeroAddress, erc20Abi, type Address, type Hex } from "viem"
|
|
24
24
|
import { useCommitIntent, useExecuteIntent } from "../../mutations.js"
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
PROD_TRAILS_API_URL,
|
|
18
18
|
PROD_TRAILS_APP_URL,
|
|
19
19
|
PROD_SEQUENCE_API_URL,
|
|
20
|
+
PROD_KEYMACHINE_URL,
|
|
20
21
|
} from "../../constants.js"
|
|
21
22
|
import { declareCommitHash, updateGlobalConfig } from "../../config.js"
|
|
22
23
|
import { updateProjectAccessKey } from "../../analytics.js"
|
|
@@ -33,6 +34,7 @@ export interface TrailsConfig {
|
|
|
33
34
|
sequenceNodeGatewayUrl: string
|
|
34
35
|
sequenceMetadataUrl: string
|
|
35
36
|
sequenceApiUrl: string
|
|
37
|
+
keyMachineUrl: string
|
|
36
38
|
walletConnectProjectId: string
|
|
37
39
|
slippageTolerance: string | number
|
|
38
40
|
debug: boolean
|
|
@@ -49,6 +51,7 @@ export interface TrailsProviderProps {
|
|
|
49
51
|
sequenceNodeGatewayUrl?: string
|
|
50
52
|
sequenceMetadataUrl?: string
|
|
51
53
|
sequenceApiUrl?: string
|
|
54
|
+
keyMachineUrl?: string
|
|
52
55
|
walletConnectProjectId?: string
|
|
53
56
|
slippageTolerance?: string | number
|
|
54
57
|
debug?: boolean
|
|
@@ -76,6 +79,7 @@ export const TrailsProvider = ({ children, config }: TrailsProviderProps) => {
|
|
|
76
79
|
sequenceMetadataUrl:
|
|
77
80
|
config.sequenceMetadataUrl || PROD_SEQUENCE_METADATA_URL,
|
|
78
81
|
sequenceApiUrl: config.sequenceApiUrl || PROD_SEQUENCE_API_URL,
|
|
82
|
+
keyMachineUrl: config.keyMachineUrl || PROD_KEYMACHINE_URL,
|
|
79
83
|
walletConnectProjectId:
|
|
80
84
|
config.walletConnectProjectId || DEFAULT_WALLETCONNECT_PROJECT_ID,
|
|
81
85
|
slippageTolerance: config.slippageTolerance ?? DEFAULT_SLIPPAGE_TOLERANCE,
|
|
@@ -91,6 +95,7 @@ export const TrailsProvider = ({ children, config }: TrailsProviderProps) => {
|
|
|
91
95
|
config.sequenceMetadataUrl,
|
|
92
96
|
config.sequenceNodeGatewayUrl,
|
|
93
97
|
config.sequenceApiUrl,
|
|
98
|
+
config.keyMachineUrl,
|
|
94
99
|
config.walletConnectProjectId,
|
|
95
100
|
config.slippageTolerance,
|
|
96
101
|
resolvedDebug,
|