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
|
@@ -30,7 +30,7 @@ import type { Token } from "../../tokens.js"
|
|
|
30
30
|
import type { TransactionState } from "../../transactions.js"
|
|
31
31
|
import type { PrepareSendFees } from "../../prepareSend.js"
|
|
32
32
|
import type { TrailsFeeBreakdown } from "../../fees.js"
|
|
33
|
-
import { getTokenPrice } from "../../
|
|
33
|
+
import { getTokenPrice } from "../../query/price.queries.js"
|
|
34
34
|
import { useCommitIntent, useExecuteIntent } from "../../mutations.js"
|
|
35
35
|
import type { CheckoutOnHandlers } from "./useCheckout.js"
|
|
36
36
|
import type {
|
|
@@ -41,6 +41,7 @@ import type {
|
|
|
41
41
|
import type { OnrampTrackingData } from "../types/analytics.js"
|
|
42
42
|
import { isZeroOrInvalidAmount } from "../../utils/validation.js"
|
|
43
43
|
import { addressEqual } from "../../utils/address.js"
|
|
44
|
+
import { HOUR_MS } from "../../utils/time.js"
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Configuration options for the `useQuote` hook.
|
|
@@ -197,7 +198,7 @@ export type Quote = {
|
|
|
197
198
|
originAmountUsdFormatted: string
|
|
198
199
|
destinationAmountUsdFormatted: string
|
|
199
200
|
// Locale display fields
|
|
200
|
-
|
|
201
|
+
intentProtocol: string
|
|
201
202
|
originAmountFormattedLocale?: string
|
|
202
203
|
originAmountUsdLocaleDisplay?: string
|
|
203
204
|
destinationAmountFormattedLocale?: string
|
|
@@ -298,7 +299,7 @@ export type UseQuoteReturn = {
|
|
|
298
299
|
/** A user-friendly error message string. */
|
|
299
300
|
quoteErrorPrettified: string
|
|
300
301
|
/** Function to manually refetch the quote (useful for refreshing stale quotes). */
|
|
301
|
-
refetchQuote: () => void
|
|
302
|
+
refetchQuote: () => Promise<void>
|
|
302
303
|
/** Function to abort any in-flight quote requests. */
|
|
303
304
|
abort: () => void
|
|
304
305
|
/** Fee options available for this quote (e.g., pay gas in different tokens). */
|
|
@@ -586,9 +587,8 @@ export function useQuote({
|
|
|
586
587
|
!!senderAddress &&
|
|
587
588
|
!!fromChainId &&
|
|
588
589
|
!hasCachedContractResult(senderAddress, fromChainId),
|
|
589
|
-
// Only cache for 24h if it's a contract, otherwise keep checking
|
|
590
590
|
staleTime: (query) => (query.state.data === true ? Infinity : 0),
|
|
591
|
-
gcTime:
|
|
591
|
+
gcTime: HOUR_MS,
|
|
592
592
|
})
|
|
593
593
|
|
|
594
594
|
// Query for sender on destination chain - skip if same chain as origin (reuse origin result)
|
|
@@ -605,7 +605,7 @@ export function useQuote({
|
|
|
605
605
|
!isSameChain &&
|
|
606
606
|
!hasCachedContractResult(senderAddress, toChainId),
|
|
607
607
|
staleTime: (query) => (query.state.data === true ? Infinity : 0),
|
|
608
|
-
gcTime:
|
|
608
|
+
gcTime: HOUR_MS,
|
|
609
609
|
})
|
|
610
610
|
|
|
611
611
|
// Query for recipient on destination chain - skip if same address as sender (reuse sender result)
|
|
@@ -622,7 +622,7 @@ export function useQuote({
|
|
|
622
622
|
!isSameAddress &&
|
|
623
623
|
!hasCachedContractResult(recipientAddress, toChainId),
|
|
624
624
|
staleTime: (query) => (query.state.data === true ? Infinity : 0),
|
|
625
|
-
gcTime:
|
|
625
|
+
gcTime: HOUR_MS,
|
|
626
626
|
})
|
|
627
627
|
|
|
628
628
|
// Derive the final values, reusing results where addresses/chains match
|
|
@@ -728,48 +728,54 @@ export function useQuote({
|
|
|
728
728
|
const originChain = getChainInfo(fromChainId)
|
|
729
729
|
const nativeTokenSymbol = originChain?.nativeCurrency?.symbol ?? ""
|
|
730
730
|
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
.
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}),
|
|
753
|
-
|
|
754
|
-
nativeTokenSymbol
|
|
755
|
-
? getTokenPrice(trailsClient, {
|
|
756
|
-
tokenSymbol: nativeTokenSymbol,
|
|
757
|
-
tokenAddress: zeroAddress,
|
|
758
|
-
chainId: fromChainId,
|
|
759
|
-
}).catch((error) => {
|
|
760
|
-
logger.console.error(
|
|
761
|
-
"[trails-sdk] [useQuote] Error getting origin native token price:",
|
|
762
|
-
error,
|
|
763
|
-
)
|
|
764
|
-
return null
|
|
765
|
-
})
|
|
766
|
-
: Promise.resolve(null),
|
|
767
|
-
])
|
|
731
|
+
const balanceResult = await queryClient
|
|
732
|
+
.ensureQueryData(
|
|
733
|
+
balanceQueries.withPrices(
|
|
734
|
+
walletClient.account!.address,
|
|
735
|
+
indexerGatewayClient,
|
|
736
|
+
trailsClient,
|
|
737
|
+
),
|
|
738
|
+
)
|
|
739
|
+
.catch((balanceError: unknown) => {
|
|
740
|
+
if (isNetworkError(balanceError)) {
|
|
741
|
+
logger.console.warn(
|
|
742
|
+
"[trails-sdk] [useQuote] Network error fetching balances, proceeding with quote using zero balance:",
|
|
743
|
+
{
|
|
744
|
+
error: balanceError,
|
|
745
|
+
account: walletClient.account!.address,
|
|
746
|
+
},
|
|
747
|
+
)
|
|
748
|
+
return { balances: [] }
|
|
749
|
+
}
|
|
750
|
+
throw balanceError
|
|
751
|
+
})
|
|
768
752
|
|
|
769
753
|
const balances = balanceResult.balances
|
|
770
|
-
const
|
|
754
|
+
const nativeTokenFromBalances = balances.find(
|
|
755
|
+
(b: any) =>
|
|
756
|
+
b.chainId === fromChainId &&
|
|
757
|
+
(addressEqual(b.contractAddress, zeroAddress) || b.isNativeToken),
|
|
758
|
+
)
|
|
759
|
+
let originNativeTokenPriceUsd = nativeTokenFromBalances?.priceUsd ?? 0
|
|
760
|
+
|
|
761
|
+
// Reuse the price already fetched by balanceQueries.withPrices.
|
|
762
|
+
// Fallback only when native token is missing from the balances payload.
|
|
763
|
+
if (!originNativeTokenPriceUsd && nativeTokenSymbol) {
|
|
764
|
+
const nativePriceResult = await getTokenPrice(trailsClient, {
|
|
765
|
+
tokenSymbol: nativeTokenSymbol,
|
|
766
|
+
tokenAddress: zeroAddress,
|
|
767
|
+
chainId: fromChainId,
|
|
768
|
+
}).catch((error) => {
|
|
769
|
+
logger.console.error(
|
|
770
|
+
"[trails-sdk] [useQuote] Error getting origin native token price:",
|
|
771
|
+
error,
|
|
772
|
+
)
|
|
773
|
+
return null
|
|
774
|
+
})
|
|
775
|
+
originNativeTokenPriceUsd = nativePriceResult?.priceUsd ?? 0
|
|
776
|
+
}
|
|
771
777
|
|
|
772
|
-
if (
|
|
778
|
+
if (originNativeTokenPriceUsd) {
|
|
773
779
|
logger.console.log(
|
|
774
780
|
"[trails-sdk] [useQuote] Origin native token price:",
|
|
775
781
|
{
|
|
@@ -1065,7 +1071,7 @@ export function useQuote({
|
|
|
1065
1071
|
destinationApproveAddress:
|
|
1066
1072
|
prepareSendQuote.destinationApproveAddress ?? "",
|
|
1067
1073
|
destinationCalldata: prepareSendQuote.destinationCalldata ?? "",
|
|
1068
|
-
|
|
1074
|
+
intentProtocol: prepareSendQuote.intentProtocol,
|
|
1069
1075
|
// Fee breakdown fields
|
|
1070
1076
|
trailsFeeBreakdown: prepareSendQuote.trailsFeeBreakdown ?? null,
|
|
1071
1077
|
originGasUsd: prepareSendQuote.originGasUsd ?? null,
|
|
@@ -1203,7 +1209,9 @@ export function useQuote({
|
|
|
1203
1209
|
isLoadingQuote: isFetching,
|
|
1204
1210
|
quoteError: error,
|
|
1205
1211
|
quoteErrorPrettified: getPrettifiedErrorMessage(error),
|
|
1206
|
-
refetchQuote: () =>
|
|
1212
|
+
refetchQuote: async () => {
|
|
1213
|
+
await refetch()
|
|
1214
|
+
},
|
|
1207
1215
|
abort: () => {
|
|
1208
1216
|
logger.console.log("[trails-sdk] useQuote abort() called")
|
|
1209
1217
|
logger.console.log(
|
|
@@ -2,11 +2,19 @@ import { createContext, useContext, useState, type ReactNode } from "react"
|
|
|
2
2
|
import { logger } from "../../logger.js"
|
|
3
3
|
import type { FundMethod } from "../../transactionIntent/types.js"
|
|
4
4
|
|
|
5
|
+
export interface SelectedMeshExchange {
|
|
6
|
+
integrationId: string
|
|
7
|
+
exchangeKey: string
|
|
8
|
+
exchangeName: string
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
interface SelectedFundMethodContextType {
|
|
6
12
|
selectedFundMethod: FundMethod
|
|
7
13
|
paymentMethod: { id: string; name: string }
|
|
14
|
+
selectedMeshExchange: SelectedMeshExchange | null
|
|
8
15
|
setSelectedFundMethod: (method: FundMethod) => void
|
|
9
16
|
setPaymentMethod: (paymentMethod: { id: string; name: string }) => void
|
|
17
|
+
setSelectedMeshExchange: (exchange: SelectedMeshExchange | null) => void
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
const SelectedFundMethodContext = createContext<
|
|
@@ -26,12 +34,16 @@ export const SelectedFundMethodProvider = ({
|
|
|
26
34
|
id: string
|
|
27
35
|
name: string
|
|
28
36
|
}>({ id: "", name: "" })
|
|
37
|
+
const [selectedMeshExchange, setSelectedMeshExchange] =
|
|
38
|
+
useState<SelectedMeshExchange | null>(null)
|
|
29
39
|
|
|
30
40
|
const value: SelectedFundMethodContextType = {
|
|
31
41
|
selectedFundMethod,
|
|
32
42
|
paymentMethod,
|
|
43
|
+
selectedMeshExchange,
|
|
33
44
|
setSelectedFundMethod,
|
|
34
45
|
setPaymentMethod,
|
|
46
|
+
setSelectedMeshExchange,
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
return (
|
|
@@ -71,7 +83,8 @@ export function useSkipBalanceFetch(): {
|
|
|
71
83
|
// Check if current fund method should skip balance fetching
|
|
72
84
|
const shouldSkipBalanceFetch =
|
|
73
85
|
context.selectedFundMethod === "onramp-meld" ||
|
|
74
|
-
context.selectedFundMethod === "direct-transfer"
|
|
86
|
+
context.selectedFundMethod === "direct-transfer" ||
|
|
87
|
+
context.selectedFundMethod === "onramp-mesh"
|
|
75
88
|
|
|
76
89
|
return {
|
|
77
90
|
selectedFundMethod: context.selectedFundMethod,
|
|
@@ -15,7 +15,8 @@ import { useSupportedChains } from "../../query/chains.hooks.js"
|
|
|
15
15
|
import { getFullErrorMessage, getIsNetworkError } from "../../error.js"
|
|
16
16
|
import { TradeType, type PrepareSendQuote } from "../../prepareSend.js"
|
|
17
17
|
import type { TransactionState } from "../../transactions.js"
|
|
18
|
-
import { useTokenPrices
|
|
18
|
+
import { useTokenPrices } from "../../query/price.hooks.js"
|
|
19
|
+
import { normalizeNumber } from "../../utils/format.js"
|
|
19
20
|
import {
|
|
20
21
|
formatRawAmount,
|
|
21
22
|
formatUsdAmountDisplay,
|
|
@@ -23,11 +24,8 @@ import {
|
|
|
23
24
|
formatAmount,
|
|
24
25
|
formatAmountDisplay,
|
|
25
26
|
} from "../../utils/format.js"
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
WIDGET_REFRESH_INTERVAL,
|
|
29
|
-
} from "../../query/balance.hooks.js"
|
|
30
|
-
import { useTokenWithFreshBalance } from "./useTokenWithFreshBalance.js"
|
|
27
|
+
import { useTokenBalances } from "../../query/balance.hooks.js"
|
|
28
|
+
import { useAccountTokenBalanceOnchain } from "../../query/balance.hooks.js"
|
|
31
29
|
import type { Token } from "../../tokens.js"
|
|
32
30
|
import {
|
|
33
31
|
useSupportedTokens,
|
|
@@ -153,7 +151,6 @@ export type UseSendReturn = {
|
|
|
153
151
|
selectedDestinationChain: ChainInfo | null
|
|
154
152
|
selectedDestToken: Token | null
|
|
155
153
|
setAmount: (amount: string) => void
|
|
156
|
-
setRecipient: (recipient: string) => void
|
|
157
154
|
setRecipientInput: (recipientInput: string) => void
|
|
158
155
|
setSelectedDestinationChain: (chain: ChainInfo) => void
|
|
159
156
|
setSelectedDestToken: (token: Token | null) => void
|
|
@@ -224,20 +221,13 @@ export function useSendForm({
|
|
|
224
221
|
tradeType === TradeType.EXACT_INPUT ? (fromAmount ?? "") : (toAmount ?? ""),
|
|
225
222
|
)
|
|
226
223
|
const [recipientInput, setRecipientInput] = useState(toRecipient ?? "")
|
|
227
|
-
const [recipient, setRecipient] = useState(toRecipient ?? "")
|
|
228
224
|
const [error, setError] = useState<string | null>(null)
|
|
229
225
|
const { data: supportedChains = [] } = useSupportedChains()
|
|
230
226
|
const { ensAddress } = useResolveEnsAddress({
|
|
231
227
|
textInput: recipientInput,
|
|
232
228
|
})
|
|
233
229
|
|
|
234
|
-
|
|
235
|
-
if (ensAddress) {
|
|
236
|
-
setRecipient(ensAddress)
|
|
237
|
-
} else {
|
|
238
|
-
setRecipient(recipientInput)
|
|
239
|
-
}
|
|
240
|
-
}, [ensAddress, recipientInput])
|
|
230
|
+
const recipient = ensAddress || recipientInput
|
|
241
231
|
|
|
242
232
|
useEffect(() => {
|
|
243
233
|
if (onError) {
|
|
@@ -420,6 +410,17 @@ export function useSendForm({
|
|
|
420
410
|
}
|
|
421
411
|
}, [selectedDestToken, defaultDestToken])
|
|
422
412
|
|
|
413
|
+
// Auto-derive destination chain from destination token.
|
|
414
|
+
// This removes the need for external chain-sync effects in ClassicSwap/Fund/Withdraw.
|
|
415
|
+
useEffect(() => {
|
|
416
|
+
if (selectedDestToken?.chainId) {
|
|
417
|
+
const chainInfo = getChainInfo(selectedDestToken.chainId)
|
|
418
|
+
if (chainInfo) {
|
|
419
|
+
setSelectedDestinationChain(chainInfo)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}, [selectedDestToken])
|
|
423
|
+
|
|
423
424
|
// Verify that decimals are stable and loaded before calculating amountRaw
|
|
424
425
|
const isDecimalsVerified = useMemo(() => {
|
|
425
426
|
// Wait for supported tokens to load first
|
|
@@ -472,7 +473,7 @@ export function useSendForm({
|
|
|
472
473
|
const { sortedTokens: feeTokenBalances } = useTokenBalances(
|
|
473
474
|
skipFeeBalanceFetch ? null : (account?.address as Address | null),
|
|
474
475
|
undefined,
|
|
475
|
-
{ refetchInterval:
|
|
476
|
+
{ refetchInterval: false },
|
|
476
477
|
)
|
|
477
478
|
|
|
478
479
|
// Convert to TokenWithBalance format for setFeeOptions
|
|
@@ -488,9 +489,7 @@ export function useSendForm({
|
|
|
488
489
|
|
|
489
490
|
// Use ref to store latest tokensWithBalance without triggering re-renders
|
|
490
491
|
const tokensWithBalanceRef = useRef(tokensWithBalance)
|
|
491
|
-
|
|
492
|
-
tokensWithBalanceRef.current = tokensWithBalance
|
|
493
|
-
}, [tokensWithBalance])
|
|
492
|
+
tokensWithBalanceRef.current = tokensWithBalance
|
|
494
493
|
|
|
495
494
|
const destTokenAddress = useTokenAddress({
|
|
496
495
|
chainId: selectedDestinationChain?.id,
|
|
@@ -501,7 +500,6 @@ export function useSendForm({
|
|
|
501
500
|
// Skip only for onramp-meld mode where prices aren't needed
|
|
502
501
|
// (for onramp-meld, source token is always USDC and amount comes from Meld quote)
|
|
503
502
|
const combinedTokenPricesInput = useMemo(() => {
|
|
504
|
-
// Skip price fetching only for onramp-meld mode
|
|
505
503
|
if (fundMethod === "onramp-meld") {
|
|
506
504
|
return []
|
|
507
505
|
}
|
|
@@ -604,22 +602,26 @@ export function useSendForm({
|
|
|
604
602
|
isCustomToken,
|
|
605
603
|
])
|
|
606
604
|
|
|
607
|
-
//
|
|
605
|
+
// Sync amount from props: fromAmount drives EXACT_INPUT, toAmount drives EXACT_OUTPUT.
|
|
606
|
+
// This removes the need for external sync effects in ClassicSwap/Fund/Withdraw.
|
|
608
607
|
useEffect(() => {
|
|
609
|
-
if (tradeType === TradeType.
|
|
608
|
+
if (tradeType === TradeType.EXACT_INPUT && fromAmount !== undefined) {
|
|
609
|
+
setAmount(fromAmount)
|
|
610
|
+
} else if (tradeType === TradeType.EXACT_OUTPUT) {
|
|
610
611
|
setAmount(toAmount ?? "")
|
|
611
612
|
}
|
|
612
|
-
}, [toAmount, tradeType])
|
|
613
|
+
}, [fromAmount, toAmount, tradeType])
|
|
613
614
|
|
|
614
615
|
const toAmountFormatted = useMemo(() => {
|
|
615
616
|
return formatAmount(toAmount || 0)
|
|
616
617
|
}, [toAmount])
|
|
617
618
|
|
|
618
|
-
// Update
|
|
619
|
-
|
|
619
|
+
// Update recipientInput when toRecipient prop changes (recipient is derived from recipientInput + ENS)
|
|
620
|
+
const [prevToRecipient, setPrevToRecipient] = useState(toRecipient)
|
|
621
|
+
if (toRecipient !== prevToRecipient) {
|
|
622
|
+
setPrevToRecipient(toRecipient)
|
|
620
623
|
setRecipientInput(toRecipient ?? "")
|
|
621
|
-
|
|
622
|
-
}, [toRecipient])
|
|
624
|
+
}
|
|
623
625
|
|
|
624
626
|
const chainInfo = getChainInfo(selectedToken?.chainId)
|
|
625
627
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
|
@@ -647,7 +649,10 @@ export function useSendForm({
|
|
|
647
649
|
|
|
648
650
|
// Get token with fresh balance data
|
|
649
651
|
const { token: tokenWithFreshBalance, isLoadingBalance } =
|
|
650
|
-
|
|
652
|
+
useAccountTokenBalanceOnchain(selectedToken, account?.address, {
|
|
653
|
+
disabled: skipBalanceFetch,
|
|
654
|
+
withPrices: true,
|
|
655
|
+
})
|
|
651
656
|
|
|
652
657
|
// Use fresh balance if available
|
|
653
658
|
const balanceFormatted =
|
|
@@ -1110,9 +1115,26 @@ export function useSendForm({
|
|
|
1110
1115
|
throw new Error("[trails-sdk] Missing required props for onramp")
|
|
1111
1116
|
}
|
|
1112
1117
|
|
|
1113
|
-
// For onramp-mesh, we need to navigate to the onramp screen
|
|
1114
1118
|
if (fundMethod === "onramp-mesh") {
|
|
1115
|
-
|
|
1119
|
+
logger.console.log(
|
|
1120
|
+
"[trails-sdk] Preparing Mesh onramp intent before navigation",
|
|
1121
|
+
{
|
|
1122
|
+
hasSendFn: !!sendFn,
|
|
1123
|
+
intentId: quote?.intentId,
|
|
1124
|
+
},
|
|
1125
|
+
)
|
|
1126
|
+
|
|
1127
|
+
await sendFn!({
|
|
1128
|
+
selectedFeeOption: selectedFeeOption ?? null,
|
|
1129
|
+
})
|
|
1130
|
+
|
|
1131
|
+
logger.console.log(
|
|
1132
|
+
"[trails-sdk] Mesh onramp intent prepared successfully",
|
|
1133
|
+
{
|
|
1134
|
+
intentId: quote?.intentId,
|
|
1135
|
+
},
|
|
1136
|
+
)
|
|
1137
|
+
|
|
1116
1138
|
if (onNavigateToOnrampMesh) {
|
|
1117
1139
|
onNavigateToOnrampMesh({
|
|
1118
1140
|
toTokenSymbol,
|
|
@@ -1334,7 +1356,6 @@ export function useSendForm({
|
|
|
1334
1356
|
selectedDestinationChain,
|
|
1335
1357
|
selectedDestToken,
|
|
1336
1358
|
setAmount,
|
|
1337
|
-
setRecipient,
|
|
1338
1359
|
setRecipientInput,
|
|
1339
1360
|
setSelectedDestinationChain,
|
|
1340
1361
|
setSelectedDestToken,
|