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,3 +1,4 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query"
|
|
1
2
|
import { ArrowLeftRight } from "lucide-react"
|
|
2
3
|
import type React from "react"
|
|
3
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
@@ -17,6 +18,9 @@ import { useSupportedTokens, type Token } from "../../tokens.js"
|
|
|
17
18
|
import type { FundMethod } from "../../transactionIntent/types.js"
|
|
18
19
|
import { isPassthroughEligible } from "../../utils/passthrough.js"
|
|
19
20
|
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
21
|
+
import { getMatchingMeshSupportedTokens } from "../utils/meshSupportedTokens.js"
|
|
22
|
+
import { getActiveMeshEnvironment } from "../utils/onrampConfig.js"
|
|
23
|
+
import { getWidgetOnrampConfig } from "../utils/trailsOnrampConfig.js"
|
|
20
24
|
import type { Screen } from "../hooks/useViewManager.js"
|
|
21
25
|
import { useViewManager } from "../hooks/useViewManager.js"
|
|
22
26
|
import { useDefaultDestinationToken } from "../hooks/useDefaultDestinationToken.js"
|
|
@@ -33,9 +37,9 @@ import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
|
|
|
33
37
|
import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
|
|
34
38
|
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
35
39
|
import { useSelectedRecipient } from "../hooks/useSelectedRecipient.js"
|
|
36
|
-
import { useSendForm } from "../hooks/useSendForm.js"
|
|
40
|
+
import { useSendForm, type OnCompleteProps } from "../hooks/useSendForm.js"
|
|
37
41
|
import { useSwapState } from "../hooks/useSwapState.js"
|
|
38
|
-
import {
|
|
42
|
+
import { useAccountTokenBalanceOnchain } from "../../query/balance.hooks.js"
|
|
39
43
|
import type { BaseProps, OnrampConfirmCallback } from "../types/commonProps.js"
|
|
40
44
|
import { isWithinCooldown, SECOND_MS } from "../../utils/time.js"
|
|
41
45
|
import { forexRateStore } from "../utils/forexRateStore.js"
|
|
@@ -58,6 +62,7 @@ import { TokenSelectorButton } from "./TokenSelectorButton.js"
|
|
|
58
62
|
import LoadingSpinner from "./LoadingSpinner.js"
|
|
59
63
|
|
|
60
64
|
import { addressEqual } from "../../utils/address.js"
|
|
65
|
+
import { useOnrampClient } from "../../onrampClient.js"
|
|
61
66
|
interface FundProps extends BaseProps {
|
|
62
67
|
onWaitingForOnrampConfirm?: OnrampConfirmCallback
|
|
63
68
|
title?: string
|
|
@@ -102,7 +107,14 @@ const Fund: React.FC<FundProps> = ({
|
|
|
102
107
|
defaultInputMode,
|
|
103
108
|
}) => {
|
|
104
109
|
const { mode, navigate } = useViewManager()
|
|
105
|
-
const
|
|
110
|
+
const widgetProps = useWidgetProps()
|
|
111
|
+
const {
|
|
112
|
+
fundOptions,
|
|
113
|
+
onramp: onrampFactory,
|
|
114
|
+
apiKey,
|
|
115
|
+
trailsApiUrl,
|
|
116
|
+
} = widgetProps
|
|
117
|
+
const onrampClient = useOnrampClient()
|
|
106
118
|
const {
|
|
107
119
|
selectedToken: originToken,
|
|
108
120
|
setSelectedToken: setOriginToken,
|
|
@@ -116,7 +128,21 @@ const Fund: React.FC<FundProps> = ({
|
|
|
116
128
|
setHasManualSelection: setHasManualDestinationSelection,
|
|
117
129
|
isControlledByProps: isDestinationControlledByProps,
|
|
118
130
|
} = useDestinationSelectedToken()
|
|
119
|
-
const { paymentMethod } = useSelectedFundMethod()
|
|
131
|
+
const { paymentMethod, selectedMeshExchange } = useSelectedFundMethod()
|
|
132
|
+
const meshOnrampConfig = getWidgetOnrampConfig(onrampFactory)
|
|
133
|
+
const meshEnvironment = getActiveMeshEnvironment(meshOnrampConfig)
|
|
134
|
+
const meshEnabled = !!meshOnrampConfig?.mesh
|
|
135
|
+
const meshAllowedExchanges = meshOnrampConfig?.mesh?.exchanges ?? null
|
|
136
|
+
const activeMeshIntegrationIds = selectedMeshExchange
|
|
137
|
+
? [selectedMeshExchange.integrationId]
|
|
138
|
+
: null
|
|
139
|
+
const activeMeshExchangeKeys = selectedMeshExchange
|
|
140
|
+
? null
|
|
141
|
+
: meshAllowedExchanges
|
|
142
|
+
const isCoinbaseMeshOnramp =
|
|
143
|
+
fundMethod === "onramp-mesh" &&
|
|
144
|
+
(selectedMeshExchange?.exchangeKey === "coinbase" ||
|
|
145
|
+
selectedMeshExchange?.exchangeKey === "coinbaseRamp")
|
|
120
146
|
|
|
121
147
|
// Check if fee options will be shown (not needed for onramp/direct-transfer modes)
|
|
122
148
|
const skipFeeBalanceFetch =
|
|
@@ -129,11 +155,9 @@ const Fund: React.FC<FundProps> = ({
|
|
|
129
155
|
const {
|
|
130
156
|
token: freshOriginToken,
|
|
131
157
|
isLoadingBalance: isLoadingFreshOriginBalance,
|
|
132
|
-
} =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
skipFeeBalanceFetch,
|
|
136
|
-
)
|
|
158
|
+
} = useAccountTokenBalanceOnchain(originToken, account?.address, {
|
|
159
|
+
disabled: skipFeeBalanceFetch,
|
|
160
|
+
})
|
|
137
161
|
|
|
138
162
|
const { selectedRecipient, setSelectedRecipient } = useSelectedRecipient()
|
|
139
163
|
const {
|
|
@@ -179,6 +203,14 @@ const Fund: React.FC<FundProps> = ({
|
|
|
179
203
|
const [isUserTyping, setIsUserTyping] = useState(false)
|
|
180
204
|
const typingTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
181
205
|
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
return () => {
|
|
208
|
+
if (typingTimeoutRef.current) {
|
|
209
|
+
clearTimeout(typingTimeoutRef.current)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}, [])
|
|
213
|
+
|
|
182
214
|
// Get country defaults when onramp is active
|
|
183
215
|
const {
|
|
184
216
|
countryCode: detectedCountryCode,
|
|
@@ -314,6 +346,7 @@ const Fund: React.FC<FundProps> = ({
|
|
|
314
346
|
setSellAmount,
|
|
315
347
|
buyAmount,
|
|
316
348
|
setBuyAmount,
|
|
349
|
+
resetSwapState,
|
|
317
350
|
enterFormMode,
|
|
318
351
|
} = useSwapState()
|
|
319
352
|
|
|
@@ -351,6 +384,16 @@ const Fund: React.FC<FundProps> = ({
|
|
|
351
384
|
const [isCreatingWidgetSession, setIsCreatingWidgetSession] = useState(false)
|
|
352
385
|
const [widgetError, setWidgetError] = useState<string | null>(null)
|
|
353
386
|
|
|
387
|
+
const handleCompleteAndClearAmounts = useCallback(
|
|
388
|
+
(result: OnCompleteProps) => {
|
|
389
|
+
setInputDisplayValue("")
|
|
390
|
+
setSellFiatAmount("")
|
|
391
|
+
resetSwapState()
|
|
392
|
+
onComplete(result)
|
|
393
|
+
},
|
|
394
|
+
[onComplete, resetSwapState, setSellFiatAmount],
|
|
395
|
+
)
|
|
396
|
+
|
|
354
397
|
// Initialize and update selected recipient from toRecipient prop (but don't auto-set to account address)
|
|
355
398
|
// biome-ignore lint/correctness/useExhaustiveDependencies: selectedRecipient is intentionally excluded to avoid infinite loops
|
|
356
399
|
useEffect(() => {
|
|
@@ -435,7 +478,6 @@ const Fund: React.FC<FundProps> = ({
|
|
|
435
478
|
isSubmitting,
|
|
436
479
|
isLoadingQuote,
|
|
437
480
|
selectedDestToken,
|
|
438
|
-
setAmount,
|
|
439
481
|
setSelectedDestinationChain,
|
|
440
482
|
setSelectedDestToken,
|
|
441
483
|
buttonText,
|
|
@@ -463,7 +505,7 @@ const Fund: React.FC<FundProps> = ({
|
|
|
463
505
|
paymasterUrls,
|
|
464
506
|
onSend,
|
|
465
507
|
onConfirm,
|
|
466
|
-
onComplete,
|
|
508
|
+
onComplete: handleCompleteAndClearAmounts,
|
|
467
509
|
selectedToken: effectiveOriginToken as any,
|
|
468
510
|
setWalletConfirmRetryHandler,
|
|
469
511
|
tradeType: tradeType,
|
|
@@ -490,6 +532,60 @@ const Fund: React.FC<FundProps> = ({
|
|
|
490
532
|
: undefined,
|
|
491
533
|
})
|
|
492
534
|
|
|
535
|
+
const {
|
|
536
|
+
data: isMeshRouteSupported = true,
|
|
537
|
+
isLoading: isLoadingMeshRouteSupport,
|
|
538
|
+
} = useQuery({
|
|
539
|
+
queryKey: [
|
|
540
|
+
"mesh-route-support",
|
|
541
|
+
meshEnvironment,
|
|
542
|
+
activeMeshExchangeKeys,
|
|
543
|
+
prepareSendQuote?.originChain?.id,
|
|
544
|
+
prepareSendQuote?.originToken?.symbol,
|
|
545
|
+
trailsApiUrl,
|
|
546
|
+
apiKey,
|
|
547
|
+
],
|
|
548
|
+
queryFn: async () => {
|
|
549
|
+
const response = await onrampClient.getMeshSupportedTokens({
|
|
550
|
+
environment: meshEnvironment,
|
|
551
|
+
})
|
|
552
|
+
|
|
553
|
+
const allowedTokens = !activeMeshExchangeKeys?.length
|
|
554
|
+
? !activeMeshIntegrationIds?.length
|
|
555
|
+
? response.tokens || []
|
|
556
|
+
: (response.tokens || []).filter((token) =>
|
|
557
|
+
(token.integrationIds || []).some((integrationId) =>
|
|
558
|
+
activeMeshIntegrationIds.includes(integrationId),
|
|
559
|
+
),
|
|
560
|
+
)
|
|
561
|
+
: (response.tokens || []).filter((token) =>
|
|
562
|
+
(token.exchangeKeys || []).some((exchangeKey) =>
|
|
563
|
+
activeMeshExchangeKeys.includes(exchangeKey),
|
|
564
|
+
),
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
return (
|
|
568
|
+
getMatchingMeshSupportedTokens(
|
|
569
|
+
allowedTokens,
|
|
570
|
+
prepareSendQuote?.originChain?.id,
|
|
571
|
+
prepareSendQuote?.originToken?.symbol,
|
|
572
|
+
).length > 0
|
|
573
|
+
)
|
|
574
|
+
},
|
|
575
|
+
enabled:
|
|
576
|
+
fundMethod === "onramp-mesh" &&
|
|
577
|
+
meshEnabled &&
|
|
578
|
+
!!prepareSendQuote?.originChain?.id &&
|
|
579
|
+
!!prepareSendQuote?.originToken?.symbol &&
|
|
580
|
+
!!apiKey &&
|
|
581
|
+
!!trailsApiUrl,
|
|
582
|
+
staleTime: 24 * 60 * 60 * 1000,
|
|
583
|
+
gcTime: 24 * 60 * 60 * 1000,
|
|
584
|
+
refetchOnMount: false,
|
|
585
|
+
refetchOnWindowFocus: false,
|
|
586
|
+
refetchOnReconnect: false,
|
|
587
|
+
})
|
|
588
|
+
|
|
493
589
|
const selectedOnrampProviderQuote =
|
|
494
590
|
selectedOnrampProvider || autoSelectedOnrampQuote
|
|
495
591
|
|
|
@@ -706,8 +802,7 @@ const Fund: React.FC<FundProps> = ({
|
|
|
706
802
|
useState(false)
|
|
707
803
|
|
|
708
804
|
const { supportedTokens } = useSupportedTokens({
|
|
709
|
-
disabled:
|
|
710
|
-
!!toToken || showSourceTokenSelector || showDestinationTokenSelector,
|
|
805
|
+
disabled: !toToken,
|
|
711
806
|
})
|
|
712
807
|
|
|
713
808
|
// Use a ref to track if we've already auto-selected from toToken prop
|
|
@@ -779,15 +874,6 @@ const Fund: React.FC<FundProps> = ({
|
|
|
779
874
|
}
|
|
780
875
|
}, [exactInputOnly, setTradeType, setBuyAmount])
|
|
781
876
|
|
|
782
|
-
// Update amount based on last input type
|
|
783
|
-
useEffect(() => {
|
|
784
|
-
if (tradeType === TradeType.EXACT_INPUT) {
|
|
785
|
-
setAmount(sellAmount)
|
|
786
|
-
} else {
|
|
787
|
-
setAmount(buyAmount)
|
|
788
|
-
}
|
|
789
|
-
}, [sellAmount, buyAmount, tradeType, setAmount])
|
|
790
|
-
|
|
791
877
|
// Handle sell amount input changes
|
|
792
878
|
const handleSellAmountChange = useCallback(
|
|
793
879
|
(value: string) => {
|
|
@@ -900,9 +986,33 @@ const Fund: React.FC<FundProps> = ({
|
|
|
900
986
|
setHasManualOriginSelection,
|
|
901
987
|
])
|
|
902
988
|
|
|
989
|
+
useEffect(() => {
|
|
990
|
+
if (hasManualOriginSelection || !isCoinbaseMeshOnramp) {
|
|
991
|
+
return
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
const isUsdcBaseSelected =
|
|
995
|
+
!!originToken &&
|
|
996
|
+
originToken.chainId === USDC_BASE.chainId &&
|
|
997
|
+
addressEqual(originToken.contractAddress, USDC_BASE.contractAddress)
|
|
998
|
+
|
|
999
|
+
if (!isUsdcBaseSelected) {
|
|
1000
|
+
logger.console.log(
|
|
1001
|
+
"[Fund] Preselecting USDC on Base for Coinbase Mesh onramp",
|
|
1002
|
+
)
|
|
1003
|
+
setOriginToken(USDC_BASE as Token)
|
|
1004
|
+
}
|
|
1005
|
+
}, [
|
|
1006
|
+
hasManualOriginSelection,
|
|
1007
|
+
isCoinbaseMeshOnramp,
|
|
1008
|
+
originToken,
|
|
1009
|
+
setOriginToken,
|
|
1010
|
+
])
|
|
1011
|
+
|
|
903
1012
|
// Auto-select origin token using separated hook
|
|
904
1013
|
useEffect(() => {
|
|
905
1014
|
if (
|
|
1015
|
+
fundMethod !== "onramp-mesh" &&
|
|
906
1016
|
!originToken &&
|
|
907
1017
|
!isLoadingOriginDefaults &&
|
|
908
1018
|
defaultOriginToken &&
|
|
@@ -920,6 +1030,7 @@ const Fund: React.FC<FundProps> = ({
|
|
|
920
1030
|
defaultOriginToken,
|
|
921
1031
|
setOriginToken,
|
|
922
1032
|
hasManualOriginSelection,
|
|
1033
|
+
fundMethod,
|
|
923
1034
|
])
|
|
924
1035
|
|
|
925
1036
|
// Auto-select destination token using separated hook
|
|
@@ -988,14 +1099,6 @@ const Fund: React.FC<FundProps> = ({
|
|
|
988
1099
|
const [showDestinationChainList, setShowDestinationChainList] =
|
|
989
1100
|
useState(false)
|
|
990
1101
|
|
|
991
|
-
useEffect(() => {
|
|
992
|
-
if (selectedDestToken) {
|
|
993
|
-
setSelectedDestinationChain(
|
|
994
|
-
getChainInfo((selectedDestToken as any)?.chainId as any) as any,
|
|
995
|
-
)
|
|
996
|
-
}
|
|
997
|
-
}, [selectedDestToken, setSelectedDestinationChain])
|
|
998
|
-
|
|
999
1102
|
// Sync destination token from hook with useSendForm
|
|
1000
1103
|
// This ensures the destination token auto-selection flows into useSendForm
|
|
1001
1104
|
useEffect(() => {
|
|
@@ -1797,7 +1900,7 @@ const Fund: React.FC<FundProps> = ({
|
|
|
1797
1900
|
}
|
|
1798
1901
|
}
|
|
1799
1902
|
}}
|
|
1800
|
-
className="text-
|
|
1903
|
+
className="text-base text-blue-500 hover:text-blue-600 transition-colors cursor-pointer flex items-center gap-2 py-1.5"
|
|
1801
1904
|
title={
|
|
1802
1905
|
originToken
|
|
1803
1906
|
? `Toggle between USD and ${originToken.symbol}`
|
|
@@ -1806,8 +1909,8 @@ const Fund: React.FC<FundProps> = ({
|
|
|
1806
1909
|
>
|
|
1807
1910
|
<svg
|
|
1808
1911
|
aria-hidden="true"
|
|
1809
|
-
width="
|
|
1810
|
-
height="
|
|
1912
|
+
width="20"
|
|
1913
|
+
height="20"
|
|
1811
1914
|
viewBox="0 0 16 16"
|
|
1812
1915
|
fill="none"
|
|
1813
1916
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -1994,83 +2097,28 @@ const Fund: React.FC<FundProps> = ({
|
|
|
1994
2097
|
fundMethod !== "direct-transfer" &&
|
|
1995
2098
|
fundMethod !== "onramp-mesh" ? (
|
|
1996
2099
|
<div className="mt-3 flex justify-center items-center space-x-2">
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
onClick={() => {
|
|
2020
|
-
// Convert USD amount to selected currency
|
|
2021
|
-
if (selectedFiatCurrency?.currencyCode === "USD") {
|
|
2022
|
-
setSellFiatAmount("50")
|
|
2023
|
-
} else if (fiatToUsdExchangeRate) {
|
|
2024
|
-
// Convert $50 USD to the selected currency
|
|
2025
|
-
const convertedAmount = 50 * fiatToUsdExchangeRate
|
|
2026
|
-
setSellFiatAmount(convertedAmount.toFixed(2))
|
|
2027
|
-
}
|
|
2028
|
-
}}
|
|
2029
|
-
>
|
|
2030
|
-
$50
|
|
2031
|
-
</button>
|
|
2032
|
-
<button
|
|
2033
|
-
type="button"
|
|
2034
|
-
className="py-0.5 px-1.5 text-xs font-medium rounded-full transition-colors cursor-pointer trails-bg-percentage-button trails-text-percentage-button trails-hover-percentage-button"
|
|
2035
|
-
onClick={() => {
|
|
2036
|
-
// Convert USD amount to selected currency
|
|
2037
|
-
if (selectedFiatCurrency?.currencyCode === "USD") {
|
|
2038
|
-
setSellFiatAmount("100")
|
|
2039
|
-
} else if (fiatToUsdExchangeRate) {
|
|
2040
|
-
// Convert $100 USD to the selected currency
|
|
2041
|
-
const convertedAmount = 100 * fiatToUsdExchangeRate
|
|
2042
|
-
setSellFiatAmount(convertedAmount.toFixed(2))
|
|
2043
|
-
}
|
|
2044
|
-
}}
|
|
2045
|
-
>
|
|
2046
|
-
$100
|
|
2047
|
-
</button>
|
|
2048
|
-
</div>
|
|
2049
|
-
) : (
|
|
2050
|
-
<PercentageMaxButtons
|
|
2051
|
-
userBalance={balanceFormatted}
|
|
2052
|
-
userBalanceRaw={balanceRaw}
|
|
2053
|
-
decimals={tokenDecimals}
|
|
2054
|
-
isNativeToken={originToken.isNativeToken ?? false}
|
|
2055
|
-
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
2056
|
-
chainId={originChainId || undefined}
|
|
2057
|
-
onAmountSelect={(amount) => {
|
|
2058
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
2059
|
-
setSellAmount(amount)
|
|
2060
|
-
setBuyAmount("")
|
|
2061
|
-
// Update display value based on current mode
|
|
2062
|
-
if (isEnteringFiat && tokenPriceUsd > 0) {
|
|
2063
|
-
const usdAmount = parseFloat(amount) * tokenPriceUsd
|
|
2064
|
-
setInputDisplayValue(
|
|
2065
|
-
Number(usdAmount.toFixed(2)).toString(),
|
|
2066
|
-
)
|
|
2067
|
-
} else {
|
|
2068
|
-
setInputDisplayValue(amount)
|
|
2069
|
-
}
|
|
2070
|
-
}}
|
|
2071
|
-
className="opacity-100"
|
|
2072
|
-
/>
|
|
2073
|
-
)}
|
|
2100
|
+
<PercentageMaxButtons
|
|
2101
|
+
userBalance={balanceFormatted}
|
|
2102
|
+
userBalanceRaw={balanceRaw}
|
|
2103
|
+
decimals={tokenDecimals}
|
|
2104
|
+
isNativeToken={originToken.isNativeToken ?? false}
|
|
2105
|
+
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
2106
|
+
chainId={originChainId || undefined}
|
|
2107
|
+
onAmountSelect={(amount) => {
|
|
2108
|
+
setTradeType(TradeType.EXACT_INPUT)
|
|
2109
|
+
setSellAmount(amount)
|
|
2110
|
+
setBuyAmount("")
|
|
2111
|
+
if (isEnteringFiat && tokenPriceUsd > 0) {
|
|
2112
|
+
const usdAmount = parseFloat(amount) * tokenPriceUsd
|
|
2113
|
+
setInputDisplayValue(
|
|
2114
|
+
Number(usdAmount.toFixed(2)).toString(),
|
|
2115
|
+
)
|
|
2116
|
+
} else {
|
|
2117
|
+
setInputDisplayValue(amount)
|
|
2118
|
+
}
|
|
2119
|
+
}}
|
|
2120
|
+
className="opacity-100"
|
|
2121
|
+
/>
|
|
2074
2122
|
</div>
|
|
2075
2123
|
) : null}
|
|
2076
2124
|
</div>
|
|
@@ -2331,6 +2379,8 @@ const Fund: React.FC<FundProps> = ({
|
|
|
2331
2379
|
!isValidCustomToken ||
|
|
2332
2380
|
isLoadingQuote ||
|
|
2333
2381
|
!prepareSendQuote ||
|
|
2382
|
+
(fundMethod === "onramp-mesh" &&
|
|
2383
|
+
(isLoadingMeshRouteSupport || !isMeshRouteSupported)) ||
|
|
2334
2384
|
(!isMeldOnRampActive &&
|
|
2335
2385
|
fundMethod !== "direct-transfer" &&
|
|
2336
2386
|
prepareSendQuote?.noSufficientBalance) ||
|
|
@@ -2368,6 +2418,15 @@ const Fund: React.FC<FundProps> = ({
|
|
|
2368
2418
|
) : fundMethod !== "direct-transfer" &&
|
|
2369
2419
|
prepareSendQuote?.noSufficientBalance ? (
|
|
2370
2420
|
"Insufficient Balance"
|
|
2421
|
+
) : fundMethod === "onramp-mesh" && isLoadingMeshRouteSupport ? (
|
|
2422
|
+
<div className="flex items-center justify-center">
|
|
2423
|
+
<LoadingSpinner className="mr-2" />
|
|
2424
|
+
<span>Checking exchange funding...</span>
|
|
2425
|
+
</div>
|
|
2426
|
+
) : fundMethod === "onramp-mesh" &&
|
|
2427
|
+
prepareSendQuote &&
|
|
2428
|
+
!isMeshRouteSupported ? (
|
|
2429
|
+
"Exchange funding unavailable"
|
|
2371
2430
|
) : isMeldOnRampActive && !sellFiatAmount ? (
|
|
2372
2431
|
"Enter amount"
|
|
2373
2432
|
) : !isMeldOnRampActive && !sellAmount ? (
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
2
|
import { ChevronRight, CreditCard, Wallet, ZapIcon } from "lucide-react"
|
|
3
|
+
import { wagmiConnectorToWalletId } from "@0xtrails/wallet-registry"
|
|
3
4
|
import { useAccount, useConnections, useSwitchAccount } from "wagmi"
|
|
4
5
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
5
6
|
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
6
7
|
import { useViewManager } from "../hooks/useViewManager.js"
|
|
7
8
|
import { useWalletConnectionContext } from "../hooks/useWalletConnectionContext.js"
|
|
8
|
-
import { useWallets
|
|
9
|
+
import { useWallets } from "../../wallets.js"
|
|
9
10
|
import ExchangeIcon from "../assets/Exchange-icon-black.svg"
|
|
10
11
|
import WalletChange from "../assets/WalletChange-black.svg"
|
|
11
12
|
import { truncateAddress } from "../../utils/address.js"
|
|
12
13
|
import { useResolveEns } from "../../ens.js"
|
|
13
14
|
import { AddressWalletIcon } from "./AddressWalletIcon.js"
|
|
14
15
|
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
15
|
-
import { useAccountTotalBalanceUsd } from "../../query/balance.hooks.js"
|
|
16
16
|
import type { FundMethod } from "../../transactionIntent/types.js"
|
|
17
17
|
import type { FundMethodListOption } from "../widget.js"
|
|
18
18
|
|
|
@@ -107,17 +107,13 @@ const FundMethods: React.FC<FundMethodsProps> = ({
|
|
|
107
107
|
eligibleConnectedWallets.find((wallet) => wallet.isActive) ||
|
|
108
108
|
eligibleConnectedWallets[0]
|
|
109
109
|
|
|
110
|
-
const
|
|
111
|
-
activeConnection?.address || null,
|
|
112
|
-
)
|
|
113
|
-
const hasActiveWalletBalance = activeWalletBalanceUsd > 0
|
|
114
|
-
|
|
115
|
-
const showWalletInline = !!activeConnection && hasActiveWalletBalance
|
|
110
|
+
const showWalletInline = !!activeConnection
|
|
116
111
|
|
|
117
112
|
const fundMethodAliases: Record<FundMethodListOption, FundMethod> = {
|
|
118
113
|
"connected-wallet": "wallet",
|
|
119
114
|
"crypto-transfer": "direct-transfer",
|
|
120
115
|
"cc-onramp": "onramp-meld",
|
|
116
|
+
exchange: "onramp-mesh",
|
|
121
117
|
"exchange-onramp": "onramp-mesh",
|
|
122
118
|
}
|
|
123
119
|
|
|
@@ -170,7 +166,7 @@ const FundMethods: React.FC<FundMethodsProps> = ({
|
|
|
170
166
|
listedInternalSet.size > 0 &&
|
|
171
167
|
!listedInternalSet.has(method)
|
|
172
168
|
|
|
173
|
-
const displayMeshExchange = !!onramp
|
|
169
|
+
const displayMeshExchange = !!onramp
|
|
174
170
|
|
|
175
171
|
const renderFundMethod = (method: FundMethod) => {
|
|
176
172
|
const forceDisabled = isUnlisted(method)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { getIsHighPriceImpactError } from "../../error.js"
|
|
3
|
+
|
|
4
|
+
interface HighPriceImpactBlockProps {
|
|
5
|
+
quoteError: string | null
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const HighPriceImpactBlock: React.FC<HighPriceImpactBlockProps> = ({
|
|
9
|
+
quoteError,
|
|
10
|
+
}) => {
|
|
11
|
+
if (!quoteError || !getIsHighPriceImpactError(quoteError)) return null
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="mb-2 p-3 rounded-lg bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-800">
|
|
15
|
+
<div className="flex items-start gap-2">
|
|
16
|
+
<svg
|
|
17
|
+
className="w-4 h-4 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"
|
|
18
|
+
fill="none"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
viewBox="0 0 24 24"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
>
|
|
23
|
+
<path
|
|
24
|
+
strokeLinecap="round"
|
|
25
|
+
strokeLinejoin="round"
|
|
26
|
+
strokeWidth={2}
|
|
27
|
+
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
28
|
+
/>
|
|
29
|
+
</svg>
|
|
30
|
+
<div className="flex-1 min-w-0">
|
|
31
|
+
<p className="text-xs font-medium text-red-700 dark:text-red-300">
|
|
32
|
+
Quote Unavailable — High Price Impact
|
|
33
|
+
</p>
|
|
34
|
+
<p className="text-xs text-red-600 dark:text-red-400 mt-0.5">
|
|
35
|
+
This transfer has a price impact over 30% on an amount over $100.
|
|
36
|
+
Try a smaller amount or a different route.
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default HighPriceImpactBlock
|
|
@@ -6,7 +6,7 @@ import { isValidNumber } from "../../utils/validation.js"
|
|
|
6
6
|
import { getChainName } from "../../chains.js"
|
|
7
7
|
import { logger } from "../../logger.js"
|
|
8
8
|
import { useMeldServiceProviders } from "../../query/meld.hooks.js"
|
|
9
|
-
import type { MeldServiceProvider } from "
|
|
9
|
+
import type { MeldServiceProvider } from "@0xtrails/api/onramp"
|
|
10
10
|
import { SECOND_MS, formatRelativeDate } from "../../utils/time.js"
|
|
11
11
|
import {
|
|
12
12
|
useMeldTransactionHistory,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type MeldTransactionStatus,
|
|
15
15
|
} from "../hooks/useMeldTransactionHistory.js"
|
|
16
16
|
import { getProviderImage } from "../utils/meldProviderUtils.js"
|
|
17
|
+
import { formatRawStatusLabel } from "../utils/statusLabel.js"
|
|
17
18
|
import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
18
19
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
19
20
|
import { TokenImage } from "./TokenImage.js"
|
|
@@ -51,31 +52,6 @@ function getStatusColor(status: MeldTransactionStatus): string {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
function getStatusLabel(status: MeldTransactionStatus): string {
|
|
55
|
-
switch (status) {
|
|
56
|
-
case "COMPLETED":
|
|
57
|
-
return "Completed"
|
|
58
|
-
case "SETTLED":
|
|
59
|
-
return "Settled"
|
|
60
|
-
case "DECLINED":
|
|
61
|
-
return "Declined"
|
|
62
|
-
case "FAILED":
|
|
63
|
-
return "Failed"
|
|
64
|
-
case "CANCELLED":
|
|
65
|
-
return "Cancelled"
|
|
66
|
-
case "ERROR":
|
|
67
|
-
return "Error"
|
|
68
|
-
case "REFUNDED":
|
|
69
|
-
return "Refunded"
|
|
70
|
-
case "PENDING":
|
|
71
|
-
return "Pending"
|
|
72
|
-
case "PROCESSING":
|
|
73
|
-
return "Processing"
|
|
74
|
-
default:
|
|
75
|
-
return status
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
55
|
function formatAmount(amount?: string): string {
|
|
80
56
|
if (!amount) return "-"
|
|
81
57
|
|
|
@@ -191,9 +167,9 @@ const TransactionItem: React.FC<{
|
|
|
191
167
|
<div className="flex items-center gap-2">
|
|
192
168
|
<span
|
|
193
169
|
className={`px-2 py-0.5 rounded text-xs font-medium ${getStatusColor(transaction.status)}`}
|
|
194
|
-
title={`Status: ${
|
|
170
|
+
title={`Status: ${formatRawStatusLabel(transaction.status)}`}
|
|
195
171
|
>
|
|
196
|
-
{
|
|
172
|
+
{formatRawStatusLabel(transaction.status)}
|
|
197
173
|
</span>
|
|
198
174
|
<span className="text-xs trails-text-tertiary">
|
|
199
175
|
{formatDate(transaction.createdAt || transaction.updatedAt)}
|