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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useMemo, useEffect, useCallback } from "react"
|
|
2
2
|
import { isAddress } from "viem"
|
|
3
|
-
import { useQuery } from "@tanstack/react-query"
|
|
3
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
|
4
4
|
import { getChainInfo } from "../../chains.js"
|
|
5
5
|
import { useSupportedChains } from "../../query/chains.hooks.js"
|
|
6
|
-
import { getSupportedTokens,
|
|
6
|
+
import { getSupportedTokens, searchTokenByAddress } from "../../tokens.js"
|
|
7
7
|
import { useCustomTokens } from "../../customTokens.js"
|
|
8
|
-
// Removed convertTokenToSupportedToken import - addCustomToken now accepts Token directly
|
|
9
8
|
import type { Token } from "../../tokens.js"
|
|
10
9
|
import { logger } from "../../logger.js"
|
|
11
10
|
import { MINUTE_MS, DAY_MS } from "../../utils/time.js"
|
|
@@ -17,10 +16,15 @@ interface UseCustomTokenSearchProps {
|
|
|
17
16
|
searchQuery: string
|
|
18
17
|
filteredTokensFormatted: Token[]
|
|
19
18
|
filterByChainId: number | null
|
|
19
|
+
/** True once the API search (getTokenList) for an address query
|
|
20
|
+
* has completed with zero results. */
|
|
21
|
+
isApiAddressSearchComplete: boolean
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
interface UseCustomTokenSearchReturn {
|
|
23
25
|
chainFilteredTokens: Token[]
|
|
26
|
+
/** All tokens found by findContractInfo across every supported chain (unfiltered by chain selector). */
|
|
27
|
+
foundTokensAllChains: Token[]
|
|
24
28
|
isLoadingCustomToken: boolean
|
|
25
29
|
customTokenError: Error | null
|
|
26
30
|
isCustomToken: (chainId: number, contractAddress: string) => boolean
|
|
@@ -34,21 +38,23 @@ export function useCustomTokenSearch({
|
|
|
34
38
|
searchQuery,
|
|
35
39
|
filteredTokensFormatted,
|
|
36
40
|
filterByChainId,
|
|
41
|
+
isApiAddressSearchComplete,
|
|
37
42
|
}: UseCustomTokenSearchProps): UseCustomTokenSearchReturn {
|
|
38
43
|
const { data: supportedChains = [] } = useSupportedChains()
|
|
39
44
|
const { addCustomToken, customTokens } = useCustomTokens()
|
|
40
45
|
const trailsConfig = useTrails()
|
|
46
|
+
const queryClient = useQueryClient()
|
|
41
47
|
// Get official supported tokens (before merging with custom tokens) to check if token is truly custom
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
],
|
|
48
|
+
const {
|
|
49
|
+
data: officialSupportedTokens = [],
|
|
50
|
+
isSuccess: officialTokensLoaded,
|
|
51
|
+
} = useQuery({
|
|
52
|
+
queryKey: ["supportedTokens"],
|
|
48
53
|
queryFn: () =>
|
|
49
54
|
getSupportedTokens({
|
|
50
55
|
trailsApiKey: trailsConfig.trailsApiKey,
|
|
51
56
|
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
57
|
+
queryClient,
|
|
52
58
|
}),
|
|
53
59
|
staleTime: DAY_MS, // 24 hours - token list is static
|
|
54
60
|
gcTime: DAY_MS, // 24 hours
|
|
@@ -96,7 +102,12 @@ export function useCustomTokenSearch({
|
|
|
96
102
|
)
|
|
97
103
|
}, [searchAddress, filteredTokensFormatted, filterByChainId, customTokens])
|
|
98
104
|
|
|
99
|
-
//
|
|
105
|
+
// Single request to find the token across all chains via SearchContractInfo
|
|
106
|
+
const supportedChainIds = useMemo(
|
|
107
|
+
() => new Set(supportedChains.map((c) => c.id)),
|
|
108
|
+
[supportedChains],
|
|
109
|
+
)
|
|
110
|
+
|
|
100
111
|
const {
|
|
101
112
|
data: foundTokensAllChains = [],
|
|
102
113
|
isLoading: isLoadingCustomToken,
|
|
@@ -110,24 +121,15 @@ export function useCustomTokenSearch({
|
|
|
110
121
|
`[trails-sdk] Searching for token ${searchAddress} across all chains`,
|
|
111
122
|
)
|
|
112
123
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
trailsApiKey: trailsConfig.trailsApiKey,
|
|
118
|
-
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
119
|
-
sequenceMetadataUrl: trailsConfig.sequenceMetadataUrl,
|
|
120
|
-
})
|
|
121
|
-
return tokenInfo ? { ...tokenInfo, chainId: chain.id } : null
|
|
122
|
-
}),
|
|
123
|
-
)
|
|
124
|
+
const allTokens = await searchTokenByAddress(searchAddress, {
|
|
125
|
+
sequenceMetadataUrl: trailsConfig.sequenceMetadataUrl,
|
|
126
|
+
trailsApiKey: trailsConfig.trailsApiKey,
|
|
127
|
+
})
|
|
124
128
|
|
|
125
|
-
//
|
|
126
|
-
const validTokens =
|
|
127
|
-
.
|
|
128
|
-
|
|
129
|
-
)
|
|
130
|
-
.map((result) => (result as PromiseFulfilledResult<Token>).value)
|
|
129
|
+
// Keep only tokens on supported chains
|
|
130
|
+
const validTokens = allTokens.filter(
|
|
131
|
+
(t) => t.chainId != null && supportedChainIds.has(t.chainId),
|
|
132
|
+
)
|
|
131
133
|
|
|
132
134
|
logger.console.log(
|
|
133
135
|
`[trails-sdk] Found ${validTokens.length} tokens across all chains`,
|
|
@@ -136,24 +138,37 @@ export function useCustomTokenSearch({
|
|
|
136
138
|
return validTokens
|
|
137
139
|
},
|
|
138
140
|
enabled:
|
|
139
|
-
!!searchAddress &&
|
|
141
|
+
!!searchAddress &&
|
|
142
|
+
!addressExistsInList &&
|
|
143
|
+
supportedChains.length > 0 &&
|
|
144
|
+
isApiAddressSearchComplete,
|
|
140
145
|
staleTime: 5 * MINUTE_MS,
|
|
141
146
|
gcTime: DAY_MS,
|
|
142
147
|
retry: 1,
|
|
143
148
|
refetchOnWindowFocus: false,
|
|
144
149
|
})
|
|
145
150
|
|
|
146
|
-
// Add found tokens to storage
|
|
151
|
+
// Add found tokens to storage only after officialSupportedTokens has loaded
|
|
152
|
+
// to avoid incorrectly persisting official tokens as custom tokens.
|
|
147
153
|
useEffect(() => {
|
|
148
|
-
if (
|
|
154
|
+
if (
|
|
155
|
+
foundTokensAllChains.length > 0 &&
|
|
156
|
+
!customTokenError &&
|
|
157
|
+
officialTokensLoaded
|
|
158
|
+
) {
|
|
149
159
|
foundTokensAllChains.forEach((tokenInfo) => {
|
|
150
160
|
const existsInOfficialTokens = officialSupportedTokens.some(
|
|
151
161
|
(token) =>
|
|
152
162
|
token.chainId === tokenInfo.chainId &&
|
|
153
163
|
addressEqual(token.contractAddress, tokenInfo.contractAddress),
|
|
154
164
|
)
|
|
165
|
+
const existsInCustomTokens = customTokens.some(
|
|
166
|
+
(token) =>
|
|
167
|
+
token.chainId === tokenInfo.chainId &&
|
|
168
|
+
addressEqual(token.contractAddress, tokenInfo.contractAddress),
|
|
169
|
+
)
|
|
155
170
|
|
|
156
|
-
if (!existsInOfficialTokens) {
|
|
171
|
+
if (!existsInOfficialTokens && !existsInCustomTokens) {
|
|
157
172
|
addCustomToken(tokenInfo)
|
|
158
173
|
logger.console.log(
|
|
159
174
|
"[trails-sdk] Added custom token to storage:",
|
|
@@ -167,6 +182,8 @@ export function useCustomTokenSearch({
|
|
|
167
182
|
customTokenError,
|
|
168
183
|
addCustomToken,
|
|
169
184
|
officialSupportedTokens,
|
|
185
|
+
officialTokensLoaded,
|
|
186
|
+
customTokens,
|
|
170
187
|
])
|
|
171
188
|
|
|
172
189
|
// Show error if custom token fetch failed
|
|
@@ -190,9 +207,10 @@ export function useCustomTokenSearch({
|
|
|
190
207
|
}, [filteredTokensFormatted])
|
|
191
208
|
|
|
192
209
|
// Convert custom tokens from localStorage to TokenFormatted format
|
|
193
|
-
//
|
|
210
|
+
// Only include custom tokens that match the current search query
|
|
194
211
|
const customTokensFromStorage = useMemo(() => {
|
|
195
212
|
const searchAddressLower = searchAddress?.toLowerCase()
|
|
213
|
+
const trimmedQuery = searchQuery.trim().toLowerCase()
|
|
196
214
|
|
|
197
215
|
return customTokens
|
|
198
216
|
.filter((token) => {
|
|
@@ -200,6 +218,11 @@ export function useCustomTokenSearch({
|
|
|
200
218
|
if (searchAddressLower) {
|
|
201
219
|
if (token.contractAddress.toLowerCase() !== searchAddressLower)
|
|
202
220
|
return false
|
|
221
|
+
} else if (trimmedQuery) {
|
|
222
|
+
const sym = (token.symbol || "").toLowerCase()
|
|
223
|
+
const name = (token.name || "").toLowerCase()
|
|
224
|
+
if (!sym.includes(trimmedQuery) && !name.includes(trimmedQuery))
|
|
225
|
+
return false
|
|
203
226
|
}
|
|
204
227
|
// Apply chain filter if active
|
|
205
228
|
if (filterByChainId !== null) {
|
|
@@ -233,7 +256,13 @@ export function useCustomTokenSearch({
|
|
|
233
256
|
isCustomToken: token.isCustomToken ?? true,
|
|
234
257
|
}
|
|
235
258
|
})
|
|
236
|
-
}, [
|
|
259
|
+
}, [
|
|
260
|
+
customTokens,
|
|
261
|
+
filterByChainId,
|
|
262
|
+
filteredTokensMap,
|
|
263
|
+
searchAddress,
|
|
264
|
+
searchQuery,
|
|
265
|
+
])
|
|
237
266
|
|
|
238
267
|
// Helper function to check if a token has a balance
|
|
239
268
|
const hasBalance = useCallback((token: Token): boolean => {
|
|
@@ -332,6 +361,7 @@ export function useCustomTokenSearch({
|
|
|
332
361
|
|
|
333
362
|
return {
|
|
334
363
|
chainFilteredTokens,
|
|
364
|
+
foundTokensAllChains,
|
|
335
365
|
isLoadingCustomToken,
|
|
336
366
|
customTokenError,
|
|
337
367
|
isCustomToken,
|
|
@@ -4,10 +4,7 @@ import { base, arbitrum } from "viem/chains"
|
|
|
4
4
|
import type { Address } from "ox"
|
|
5
5
|
import { useSupportedTokens } from "../../tokens.js"
|
|
6
6
|
import type { Token } from "../../tokens.js"
|
|
7
|
-
import {
|
|
8
|
-
useTokenBalances,
|
|
9
|
-
WIDGET_REFRESH_INTERVAL,
|
|
10
|
-
} from "../../query/balance.hooks.js"
|
|
7
|
+
import { useTokenBalances } from "../../query/balance.hooks.js"
|
|
11
8
|
import { logger } from "../../logger.js"
|
|
12
9
|
|
|
13
10
|
/**
|
|
@@ -36,7 +33,7 @@ export function useDefaultDestinationToken(originToken: Token | null) {
|
|
|
36
33
|
const { sortedTokens, isLoadingSortedTokens } = useTokenBalances(
|
|
37
34
|
originToken ? (address as Address.Address) : null,
|
|
38
35
|
undefined,
|
|
39
|
-
{ refetchInterval:
|
|
36
|
+
{ refetchInterval: false },
|
|
40
37
|
)
|
|
41
38
|
|
|
42
39
|
const isLoading = isLoadingTokens || isLoadingSortedTokens
|
|
@@ -3,10 +3,7 @@ import { useAccount } from "wagmi"
|
|
|
3
3
|
import type { Address } from "ox"
|
|
4
4
|
import { useWidgetProps } from "./useWidgetProps.js"
|
|
5
5
|
import { useTargetAmount } from "./useTargetAmount.js"
|
|
6
|
-
import {
|
|
7
|
-
useTokenBalances,
|
|
8
|
-
WIDGET_REFRESH_INTERVAL,
|
|
9
|
-
} from "../../query/balance.hooks.js"
|
|
6
|
+
import { useTokenBalances } from "../../query/balance.hooks.js"
|
|
10
7
|
import type { Token } from "../../tokens.js"
|
|
11
8
|
import { getChainInfo } from "../../chains.js"
|
|
12
9
|
import { isNativeToken } from "../../utils/address.js"
|
|
@@ -90,7 +87,7 @@ export function useDefaultOriginToken() {
|
|
|
90
87
|
const { sortedTokens, isLoadingSortedTokens } = useTokenBalances(
|
|
91
88
|
address as Address.Address,
|
|
92
89
|
undefined,
|
|
93
|
-
{ refetchInterval:
|
|
90
|
+
{ refetchInterval: false },
|
|
94
91
|
)
|
|
95
92
|
|
|
96
93
|
const isLoading = isLoadingSortedTokens
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
2
|
import type { TrailsOnramp } from "../../onrampClient.js"
|
|
3
3
|
import { useOnrampClient } from "../../onrampClient.js"
|
|
4
|
-
import type { MeldFiatCurrency } from "
|
|
4
|
+
import type { MeldFiatCurrency } from "@0xtrails/api/onramp"
|
|
5
5
|
import { meldQueries } from "../../query/meld.queries.js"
|
|
6
6
|
|
|
7
7
|
export type OnrampFiatCurrency = MeldFiatCurrency
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
|
+
import type { Intent } from "@0xtrails/api"
|
|
2
3
|
import { useTrailsClient } from "../../trailsClient.js"
|
|
3
4
|
import { getIntent } from "../../intents.js"
|
|
4
5
|
import { useTrails } from "../providers/TrailsProvider.js"
|
|
@@ -9,11 +10,11 @@ export interface UseGetIntentParams {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export interface UseGetIntentReturn {
|
|
12
|
-
intent:
|
|
13
|
+
intent: Intent | null
|
|
13
14
|
isLoading: boolean
|
|
14
15
|
isError: boolean
|
|
15
16
|
error: Error | null
|
|
16
|
-
refetch: () => void
|
|
17
|
+
refetch: () => Promise<void>
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -46,8 +47,8 @@ export function useGetIntent({
|
|
|
46
47
|
isLoading,
|
|
47
48
|
isError,
|
|
48
49
|
error: error as Error | null,
|
|
49
|
-
refetch: () => {
|
|
50
|
-
refetch()
|
|
50
|
+
refetch: async () => {
|
|
51
|
+
await refetch()
|
|
51
52
|
},
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -20,7 +20,7 @@ interface UseIntentReceiptBalancesResult {
|
|
|
20
20
|
hasRecoverableFunds: boolean
|
|
21
21
|
isLoading: boolean
|
|
22
22
|
error: Error | null
|
|
23
|
-
refetch: () => void
|
|
23
|
+
refetch: () => Promise<void>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
type HistoryBalanceGroup = {
|
|
@@ -134,8 +134,8 @@ export function useIntentReceiptBalances({
|
|
|
134
134
|
hasRecoverableFunds: (data?.hasBalance ?? false) && chainGroups.length > 0,
|
|
135
135
|
isLoading,
|
|
136
136
|
error: (error as Error) || null,
|
|
137
|
-
refetch: () => {
|
|
138
|
-
|
|
137
|
+
refetch: async () => {
|
|
138
|
+
await refetch()
|
|
139
139
|
},
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -39,11 +39,13 @@ function mapIntentHistoryToTransaction(
|
|
|
39
39
|
const depositTransactionHash = receipt.depositTransaction?.txnHash
|
|
40
40
|
const originTransactionHash = receipt.originTransaction?.txnHash
|
|
41
41
|
const destinationTransactionHash = receipt.destinationTransaction?.txnHash
|
|
42
|
+
const refundTransactionHash = receipt.refundTransaction?.txnHash
|
|
42
43
|
|
|
43
44
|
// Get transaction statuses from the transaction objects
|
|
44
45
|
const depositStatus = receipt.depositTransaction?.status
|
|
45
46
|
const originStatus = receipt.originTransaction?.status
|
|
46
47
|
const destinationStatus = receipt.destinationTransaction?.status
|
|
48
|
+
const refundStatus = receipt.refundTransaction?.status
|
|
47
49
|
|
|
48
50
|
// Use summary if available, otherwise construct from transaction data
|
|
49
51
|
const intentId = intentHistory.intentId
|
|
@@ -89,49 +91,6 @@ function mapIntentHistoryToTransaction(
|
|
|
89
91
|
const originTokenMetadata = receipt.summary?.originTokenMetadata
|
|
90
92
|
const destinationTokenMetadata = receipt.summary?.destinationTokenMetadata
|
|
91
93
|
|
|
92
|
-
// Determine effective status based on transaction status fields
|
|
93
|
-
// Priority: destinationTransactionStatus > originTransactionStatus > depositTransactionStatus > main status
|
|
94
|
-
let effectiveStatus = normalizeApiStatus(status)
|
|
95
|
-
|
|
96
|
-
// If destinationTransactionStatus exists and is not ABORTED or UNKNOWN, use it
|
|
97
|
-
if (
|
|
98
|
-
destinationStatus &&
|
|
99
|
-
destinationStatus !== "ABORTED" &&
|
|
100
|
-
destinationStatus !== "UNKNOWN"
|
|
101
|
-
) {
|
|
102
|
-
effectiveStatus = normalizeApiStatus(destinationStatus)
|
|
103
|
-
}
|
|
104
|
-
// If destinationTransactionStatus doesn't exist but originTransactionStatus exists and is not ABORTED or UNKNOWN, use it
|
|
105
|
-
else if (
|
|
106
|
-
!destinationStatus &&
|
|
107
|
-
originStatus &&
|
|
108
|
-
originStatus !== "ABORTED" &&
|
|
109
|
-
originStatus !== "UNKNOWN"
|
|
110
|
-
) {
|
|
111
|
-
effectiveStatus = normalizeApiStatus(originStatus)
|
|
112
|
-
}
|
|
113
|
-
// If depositTransactionStatus is ABORTED but origin/destination have non-ABORTED statuses, don't use aborted
|
|
114
|
-
// Only use aborted if deposit is ABORTED and origin/destination are also ABORTED or don't exist
|
|
115
|
-
else if (depositStatus === "ABORTED") {
|
|
116
|
-
// Check if origin or destination have non-ABORTED statuses
|
|
117
|
-
const hasNonAbortedOrigin = originStatus && originStatus !== "ABORTED"
|
|
118
|
-
const hasNonAbortedDestination =
|
|
119
|
-
destinationStatus && destinationStatus !== "ABORTED"
|
|
120
|
-
|
|
121
|
-
if (!hasNonAbortedOrigin && !hasNonAbortedDestination) {
|
|
122
|
-
// Only mark as aborted if no non-aborted statuses exist
|
|
123
|
-
effectiveStatus = "ABORTED"
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// If originTransactionStatus is ABORTED and no destination status, use aborted
|
|
127
|
-
else if (originStatus === "ABORTED" && !destinationStatus) {
|
|
128
|
-
effectiveStatus = "ABORTED"
|
|
129
|
-
}
|
|
130
|
-
// If destinationTransactionStatus is ABORTED, use aborted
|
|
131
|
-
else if (destinationStatus === "ABORTED") {
|
|
132
|
-
effectiveStatus = "ABORTED"
|
|
133
|
-
}
|
|
134
|
-
|
|
135
94
|
return {
|
|
136
95
|
originIntentAddress: originIntentAddress,
|
|
137
96
|
destinationIntentAddress: destinationIntentAddress,
|
|
@@ -139,7 +98,8 @@ function mapIntentHistoryToTransaction(
|
|
|
139
98
|
intentId: intentId,
|
|
140
99
|
metaTxnId: intentId,
|
|
141
100
|
txnHash: originTransactionHash || destinationTransactionHash || undefined,
|
|
142
|
-
|
|
101
|
+
intentStatus: normalizeApiStatus(status),
|
|
102
|
+
executionStatus: normalizeApiStatus(status),
|
|
143
103
|
originChainId: originChainId,
|
|
144
104
|
destinationChainId: destinationChainId,
|
|
145
105
|
originTokenAddress: originTokenAddress,
|
|
@@ -154,6 +114,9 @@ function mapIntentHistoryToTransaction(
|
|
|
154
114
|
depositTransactionStatus: depositStatus,
|
|
155
115
|
originTransactionStatus: originStatus,
|
|
156
116
|
destinationTransactionStatus: destinationStatus,
|
|
117
|
+
refundTransactionHash: refundTransactionHash,
|
|
118
|
+
refundTransactionStatus: refundStatus,
|
|
119
|
+
refundTransactionChainId: receipt.refundTransaction?.chainId,
|
|
157
120
|
originToken:
|
|
158
121
|
originTokenMetadata && originTokenAddress && originTokenAddress !== ""
|
|
159
122
|
? ({
|
|
@@ -618,13 +581,14 @@ export type UseIntentTransactionHistoryParams = {
|
|
|
618
581
|
pageSize?: number
|
|
619
582
|
enabled?: boolean
|
|
620
583
|
refetchInterval?: number | false
|
|
584
|
+
intentStatuses?: string[]
|
|
621
585
|
}
|
|
622
586
|
|
|
623
587
|
export type UseIntentTransactionHistoryReturn = {
|
|
624
588
|
transactions: IntentTransaction[]
|
|
625
589
|
loading: boolean
|
|
626
590
|
error: string | null
|
|
627
|
-
refetch: () => void
|
|
591
|
+
refetch: () => Promise<void>
|
|
628
592
|
loadMore: () => void
|
|
629
593
|
hasMore: boolean
|
|
630
594
|
page: number
|
|
@@ -644,6 +608,7 @@ export function useIntentTransactionHistory({
|
|
|
644
608
|
pageSize = 10,
|
|
645
609
|
enabled = true,
|
|
646
610
|
refetchInterval,
|
|
611
|
+
intentStatuses,
|
|
647
612
|
}: UseIntentTransactionHistoryParams): UseIntentTransactionHistoryReturn {
|
|
648
613
|
const trailsConfig = useTrails()
|
|
649
614
|
|
|
@@ -659,7 +624,13 @@ export function useIntentTransactionHistory({
|
|
|
659
624
|
const currentPageObject = pageHistory[page]
|
|
660
625
|
|
|
661
626
|
const { data, isLoading, error, refetch, isFetching } = useQuery({
|
|
662
|
-
queryKey: [
|
|
627
|
+
queryKey: [
|
|
628
|
+
"intentTransactionHistory",
|
|
629
|
+
accountAddress,
|
|
630
|
+
pageSize,
|
|
631
|
+
page,
|
|
632
|
+
intentStatuses?.join(",") ?? "all",
|
|
633
|
+
],
|
|
663
634
|
queryFn: async () => {
|
|
664
635
|
if (!accountAddress || !trailsConfig.trailsApiKey) {
|
|
665
636
|
throw new Error("Account address and API key required")
|
|
@@ -676,6 +647,10 @@ export function useIntentTransactionHistory({
|
|
|
676
647
|
page: currentPageObject || { pageSize },
|
|
677
648
|
}
|
|
678
649
|
|
|
650
|
+
if (intentStatuses && intentStatuses.length > 0) {
|
|
651
|
+
requestParams.byStatuses = intentStatuses
|
|
652
|
+
}
|
|
653
|
+
|
|
679
654
|
logger.console.log(
|
|
680
655
|
"[trails-sdk] getIntentHistory request:",
|
|
681
656
|
requestParams,
|
|
@@ -801,7 +776,9 @@ export function useIntentTransactionHistory({
|
|
|
801
776
|
transactions,
|
|
802
777
|
loading: isLoading || isFetching,
|
|
803
778
|
error: error instanceof Error ? error.message : null,
|
|
804
|
-
refetch
|
|
779
|
+
refetch: async () => {
|
|
780
|
+
await refetch()
|
|
781
|
+
},
|
|
805
782
|
loadMore: loadMoreHandler,
|
|
806
783
|
hasMore,
|
|
807
784
|
page,
|
|
@@ -72,7 +72,7 @@ export interface UseMeldTransactionHistoryReturn {
|
|
|
72
72
|
transactions: MeldTransactionData[]
|
|
73
73
|
loading: boolean
|
|
74
74
|
error: string | null
|
|
75
|
-
refetch: () => void
|
|
75
|
+
refetch: () => Promise<void>
|
|
76
76
|
hasMore: boolean
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -176,7 +176,9 @@ export function useMeldTransactionHistory({
|
|
|
176
176
|
transactions,
|
|
177
177
|
loading: isLoading || isFetching,
|
|
178
178
|
error: error instanceof Error ? error.message : null,
|
|
179
|
-
refetch
|
|
179
|
+
refetch: async () => {
|
|
180
|
+
await refetch()
|
|
181
|
+
},
|
|
180
182
|
hasMore: data?.hasMore ?? false,
|
|
181
183
|
}
|
|
182
184
|
}
|
|
@@ -5,7 +5,7 @@ import { logger } from "../../logger.js"
|
|
|
5
5
|
import type {
|
|
6
6
|
SearchMeldTransactionsRequest,
|
|
7
7
|
SearchMeldTransactionsResponse,
|
|
8
|
-
} from "
|
|
8
|
+
} from "@0xtrails/api/onramp"
|
|
9
9
|
import { getAccountTransactionHistory } from "../../transactions.js"
|
|
10
10
|
import { addressEqual } from "../../utils/address.js"
|
|
11
11
|
import { toSeconds, elapsed, SECOND_MS } from "../../utils/time.js"
|
|
@@ -96,7 +96,7 @@ export interface UseMeldTransactionStatusResult {
|
|
|
96
96
|
settledAmount: string | null
|
|
97
97
|
|
|
98
98
|
// Actions
|
|
99
|
-
refetch: () => void
|
|
99
|
+
refetch: () => Promise<void>
|
|
100
100
|
reset: () => void
|
|
101
101
|
resetWindowClosed: () => void
|
|
102
102
|
setWindowRef: (windowRef: Window | null) => void
|
|
@@ -138,7 +138,7 @@ export function useMeldTransactionStatus(
|
|
|
138
138
|
const useSearchAPI = !!externalSessionId
|
|
139
139
|
|
|
140
140
|
// React Query for transaction status
|
|
141
|
-
const
|
|
141
|
+
const { data, refetch, isLoading, error } = useQuery({
|
|
142
142
|
queryKey: ["meld-transaction-status", activeId, useSearchAPI],
|
|
143
143
|
queryFn: async (): Promise<MeldTransaction> => {
|
|
144
144
|
if (!activeId) {
|
|
@@ -510,7 +510,7 @@ export function useMeldTransactionStatus(
|
|
|
510
510
|
}, [windowRef, windowClosed, onWindowClosed])
|
|
511
511
|
|
|
512
512
|
// Compute derived states
|
|
513
|
-
const transaction =
|
|
513
|
+
const transaction = data || null
|
|
514
514
|
const status = transaction?.status
|
|
515
515
|
|
|
516
516
|
const isComplete =
|
|
@@ -538,13 +538,13 @@ export function useMeldTransactionStatus(
|
|
|
538
538
|
let state: TransactionState = "idle"
|
|
539
539
|
if (windowClosed && !isComplete) {
|
|
540
540
|
state = "window-closed"
|
|
541
|
-
} else if (
|
|
541
|
+
} else if (error) {
|
|
542
542
|
state = "error"
|
|
543
543
|
} else if (isSuccess) {
|
|
544
544
|
state = "success"
|
|
545
545
|
} else if (isFailed) {
|
|
546
546
|
state = "failed"
|
|
547
|
-
} else if (activeId && popupOpened &&
|
|
547
|
+
} else if (activeId && popupOpened && isLoading) {
|
|
548
548
|
state = "polling"
|
|
549
549
|
} else if (activeId && popupOpened) {
|
|
550
550
|
state = "polling"
|
|
@@ -557,9 +557,9 @@ export function useMeldTransactionStatus(
|
|
|
557
557
|
message: getStatusMessage(state, status, timeElapsed),
|
|
558
558
|
timeElapsed,
|
|
559
559
|
transaction,
|
|
560
|
-
error:
|
|
560
|
+
error: error as Error | null,
|
|
561
561
|
}),
|
|
562
|
-
[state, status, timeElapsed, transaction,
|
|
562
|
+
[state, status, timeElapsed, transaction, error],
|
|
563
563
|
)
|
|
564
564
|
|
|
565
565
|
// Trigger status change callback
|
|
@@ -596,8 +596,8 @@ export function useMeldTransactionStatus(
|
|
|
596
596
|
return {
|
|
597
597
|
// Core status
|
|
598
598
|
transaction,
|
|
599
|
-
isLoading
|
|
600
|
-
error:
|
|
599
|
+
isLoading,
|
|
600
|
+
error: error as Error | null,
|
|
601
601
|
|
|
602
602
|
// Computed states
|
|
603
603
|
isComplete,
|
|
@@ -620,7 +620,9 @@ export function useMeldTransactionStatus(
|
|
|
620
620
|
settledAmount,
|
|
621
621
|
|
|
622
622
|
// Actions
|
|
623
|
-
refetch:
|
|
623
|
+
refetch: async () => {
|
|
624
|
+
await refetch()
|
|
625
|
+
},
|
|
624
626
|
reset,
|
|
625
627
|
resetWindowClosed,
|
|
626
628
|
setWindowRef,
|
|
@@ -35,7 +35,7 @@ export interface UseOnRampQuoteResult {
|
|
|
35
35
|
/**
|
|
36
36
|
* Manually trigger fetching with the current params
|
|
37
37
|
*/
|
|
38
|
-
refetch: () => void
|
|
38
|
+
refetch: () => Promise<void>
|
|
39
39
|
/**
|
|
40
40
|
* Tracking data for analytics
|
|
41
41
|
*/
|
|
@@ -332,8 +332,8 @@ export function useOnRampQuote(
|
|
|
332
332
|
selectedQuote,
|
|
333
333
|
isLoading,
|
|
334
334
|
error: error as Error | null,
|
|
335
|
-
refetch: () => {
|
|
336
|
-
|
|
335
|
+
refetch: async () => {
|
|
336
|
+
await refetch()
|
|
337
337
|
},
|
|
338
338
|
onrampTrackingData,
|
|
339
339
|
}
|
|
@@ -57,7 +57,7 @@ export interface UseOnRampTransactionStatusResult {
|
|
|
57
57
|
/**
|
|
58
58
|
* Refetch the transaction status manually
|
|
59
59
|
*/
|
|
60
|
-
refetch: () => void
|
|
60
|
+
refetch: () => Promise<void>
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -90,7 +90,7 @@ export function useOnRampTransactionStatus(
|
|
|
90
90
|
|
|
91
91
|
const defaultOnrampClient = useOnrampClient()
|
|
92
92
|
|
|
93
|
-
const
|
|
93
|
+
const { data, refetch, isLoading, error } = useQuery({
|
|
94
94
|
queryKey: ["onramp-transaction-status", transactionId, "onrampClient"],
|
|
95
95
|
queryFn: async (): Promise<MeldTransaction> => {
|
|
96
96
|
if (!transactionId) {
|
|
@@ -169,7 +169,7 @@ export function useOnRampTransactionStatus(
|
|
|
169
169
|
retryDelay: SECOND_MS,
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
-
const transaction =
|
|
172
|
+
const transaction = data || null
|
|
173
173
|
const status = transaction?.status
|
|
174
174
|
|
|
175
175
|
const isComplete =
|
|
@@ -178,17 +178,19 @@ export function useOnRampTransactionStatus(
|
|
|
178
178
|
const isFailed = status === "FAILED" || status === "CANCELLED"
|
|
179
179
|
|
|
180
180
|
// Don't expose 404 errors as actual errors since they're expected
|
|
181
|
-
const actualError =
|
|
181
|
+
const actualError = error as Error | null
|
|
182
182
|
const shouldShowError =
|
|
183
183
|
actualError && actualError.message !== "Transaction not registered yet"
|
|
184
184
|
|
|
185
185
|
return {
|
|
186
186
|
transaction,
|
|
187
|
-
isLoading
|
|
187
|
+
isLoading,
|
|
188
188
|
error: shouldShowError ? actualError : null,
|
|
189
189
|
isComplete,
|
|
190
190
|
isSuccess,
|
|
191
191
|
isFailed,
|
|
192
|
-
refetch:
|
|
192
|
+
refetch: async () => {
|
|
193
|
+
await refetch()
|
|
194
|
+
},
|
|
193
195
|
}
|
|
194
196
|
}
|