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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query"
|
|
2
|
+
import { ChevronRight } from "lucide-react"
|
|
3
|
+
import type React from "react"
|
|
4
|
+
import { useState } from "react"
|
|
5
|
+
import { useOnrampClient } from "../../onrampClient.js"
|
|
6
|
+
import { logger } from "../../logger.js"
|
|
7
|
+
import { ScreenHeader } from "./ScreenHeader.js"
|
|
8
|
+
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
9
|
+
import { getActiveMeshEnvironment } from "../utils/onrampConfig.js"
|
|
10
|
+
import { getWidgetOnrampConfig } from "../utils/trailsOnrampConfig.js"
|
|
11
|
+
|
|
12
|
+
const INITIAL_VISIBLE_EXCHANGES = 3
|
|
13
|
+
|
|
14
|
+
export interface MeshExchangeSelectionProps {
|
|
15
|
+
onBack: () => void
|
|
16
|
+
onSelectExchange: (exchange: {
|
|
17
|
+
integrationId: string
|
|
18
|
+
exchangeKey: string
|
|
19
|
+
exchangeName: string
|
|
20
|
+
}) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getExchangeBackgroundClassName(exchangeKey: string): string {
|
|
24
|
+
switch (exchangeKey) {
|
|
25
|
+
case "coinbase":
|
|
26
|
+
case "coinbaseRamp":
|
|
27
|
+
case "sandboxCoinbase":
|
|
28
|
+
return "bg-white"
|
|
29
|
+
case "binanceInternational":
|
|
30
|
+
case "binanceInternationalDirect":
|
|
31
|
+
case "binanceUs":
|
|
32
|
+
case "binanceUsDirect":
|
|
33
|
+
case "sandbox":
|
|
34
|
+
case "binanceConnect":
|
|
35
|
+
return "bg-black"
|
|
36
|
+
case "bitfinex":
|
|
37
|
+
case "bitfinexDirect":
|
|
38
|
+
return "bg-[#0e3452]"
|
|
39
|
+
case "kraken":
|
|
40
|
+
case "krakenDirect":
|
|
41
|
+
return "bg-[#5841d7]"
|
|
42
|
+
case "uphold":
|
|
43
|
+
case "upholdDirect":
|
|
44
|
+
return "bg-[#49cc68]"
|
|
45
|
+
case "paribu":
|
|
46
|
+
case "paribuOAuth":
|
|
47
|
+
return "bg-[#9cba3b]"
|
|
48
|
+
case "robinhood":
|
|
49
|
+
case "robinhoodDirect":
|
|
50
|
+
case "robinhoodConnect":
|
|
51
|
+
return "bg-[#ccff00]"
|
|
52
|
+
default:
|
|
53
|
+
return "bg-gray-700"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const MeshExchangeSelection: React.FC<MeshExchangeSelectionProps> = ({
|
|
58
|
+
onBack,
|
|
59
|
+
onSelectExchange,
|
|
60
|
+
}) => {
|
|
61
|
+
const { onramp: onrampFactory, apiKey, trailsApiUrl } = useWidgetProps()
|
|
62
|
+
const onrampClient = useOnrampClient()
|
|
63
|
+
const meshOnrampConfig = getWidgetOnrampConfig(onrampFactory)
|
|
64
|
+
const [showAllExchanges, setShowAllExchanges] = useState(false)
|
|
65
|
+
const [failedLogos, setFailedLogos] = useState<Record<string, true>>({})
|
|
66
|
+
|
|
67
|
+
const meshEnvironment = getActiveMeshEnvironment(meshOnrampConfig)
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
data: exchangeOptions = [],
|
|
71
|
+
isLoading,
|
|
72
|
+
error,
|
|
73
|
+
} = useQuery({
|
|
74
|
+
queryKey: ["mesh-exchange-options", meshEnvironment, trailsApiUrl, apiKey],
|
|
75
|
+
queryFn: async () => {
|
|
76
|
+
const response = await onrampClient.getMeshIntegrations({
|
|
77
|
+
environment: meshEnvironment,
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return (response.integrations || []).map((integration) => {
|
|
81
|
+
return {
|
|
82
|
+
key: integration.key,
|
|
83
|
+
integrationId: integration.id,
|
|
84
|
+
exchangeName: integration.displayName || integration.key,
|
|
85
|
+
imageUrl: integration.imageUrl || "",
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
},
|
|
89
|
+
enabled: !!apiKey && !!trailsApiUrl,
|
|
90
|
+
staleTime: 24 * 60 * 60 * 1000,
|
|
91
|
+
gcTime: 24 * 60 * 60 * 1000,
|
|
92
|
+
refetchOnMount: false,
|
|
93
|
+
refetchOnWindowFocus: false,
|
|
94
|
+
refetchOnReconnect: false,
|
|
95
|
+
})
|
|
96
|
+
const visibleExchangeOptions = showAllExchanges
|
|
97
|
+
? exchangeOptions
|
|
98
|
+
: exchangeOptions.slice(0, INITIAL_VISIBLE_EXCHANGES)
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div className="flex flex-col h-full">
|
|
102
|
+
<ScreenHeader
|
|
103
|
+
onBack={onBack}
|
|
104
|
+
headerContent="Select Exchange"
|
|
105
|
+
headerContentAlign="left"
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<div className="flex-1">
|
|
109
|
+
{isLoading ? (
|
|
110
|
+
<div className="flex h-full items-center justify-center">
|
|
111
|
+
<div className="text-center">
|
|
112
|
+
<div className="mt-4 mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-2 border-solid border-blue-500 border-t-transparent" />
|
|
113
|
+
<p className="text-sm text-gray-500 dark:text-gray-400">
|
|
114
|
+
Loading exchanges...
|
|
115
|
+
</p>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
) : error ? (
|
|
119
|
+
<div className="flex h-full items-center justify-center">
|
|
120
|
+
<div className="rounded-lg border border-solid border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300">
|
|
121
|
+
{error instanceof Error
|
|
122
|
+
? error.message
|
|
123
|
+
: "Failed to load exchanges"}
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
) : exchangeOptions.length === 0 ? (
|
|
127
|
+
<div className="flex h-full items-center justify-center">
|
|
128
|
+
<div className="rounded-lg border border-solid border-gray-200 bg-gray-50 p-4 text-sm text-gray-600 dark:border-gray-700 dark:bg-gray-800/70 dark:text-gray-300">
|
|
129
|
+
No supported exchanges are currently available.
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
) : (
|
|
133
|
+
<div className="max-h-[420px] overflow-y-auto pr-1 pt-4">
|
|
134
|
+
<div className="space-y-4">
|
|
135
|
+
{visibleExchangeOptions.map((exchange) => (
|
|
136
|
+
<button
|
|
137
|
+
key={exchange.integrationId}
|
|
138
|
+
type="button"
|
|
139
|
+
onClick={() => {
|
|
140
|
+
logger.console.log(
|
|
141
|
+
"[trails-sdk] Selected Mesh exchange in widget:",
|
|
142
|
+
exchange,
|
|
143
|
+
)
|
|
144
|
+
onSelectExchange({
|
|
145
|
+
integrationId: exchange.integrationId,
|
|
146
|
+
exchangeKey: exchange.key,
|
|
147
|
+
exchangeName: exchange.exchangeName,
|
|
148
|
+
})
|
|
149
|
+
}}
|
|
150
|
+
className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 rounded-lg transition-all duration-200 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-900 dark:text-white"
|
|
151
|
+
>
|
|
152
|
+
<div className="flex items-center space-x-3 flex-1">
|
|
153
|
+
<div
|
|
154
|
+
className={`flex h-12 w-12 items-center justify-center overflow-hidden rounded-lg border border-solid border-gray-200 dark:border-gray-700 ${getExchangeBackgroundClassName(exchange.key)}`}
|
|
155
|
+
>
|
|
156
|
+
{exchange.imageUrl &&
|
|
157
|
+
!failedLogos[exchange.integrationId] ? (
|
|
158
|
+
<img
|
|
159
|
+
src={exchange.imageUrl}
|
|
160
|
+
alt={`${exchange.exchangeName} logo`}
|
|
161
|
+
className="h-8 w-8 rounded object-contain"
|
|
162
|
+
loading="lazy"
|
|
163
|
+
referrerPolicy="no-referrer"
|
|
164
|
+
onError={() => {
|
|
165
|
+
setFailedLogos((current) => ({
|
|
166
|
+
...current,
|
|
167
|
+
[exchange.integrationId]: true,
|
|
168
|
+
}))
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
) : (
|
|
172
|
+
<span className="text-sm font-semibold text-white">
|
|
173
|
+
{exchange.exchangeName.slice(0, 2).toUpperCase()}
|
|
174
|
+
</span>
|
|
175
|
+
)}
|
|
176
|
+
</div>
|
|
177
|
+
<div className="flex-1 text-left">
|
|
178
|
+
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
179
|
+
{exchange.exchangeName}
|
|
180
|
+
</h4>
|
|
181
|
+
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
182
|
+
Connect your account to transfer funds
|
|
183
|
+
</p>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
187
|
+
</button>
|
|
188
|
+
))}
|
|
189
|
+
{!showAllExchanges &&
|
|
190
|
+
exchangeOptions.length > INITIAL_VISIBLE_EXCHANGES && (
|
|
191
|
+
<button
|
|
192
|
+
type="button"
|
|
193
|
+
onClick={() => setShowAllExchanges(true)}
|
|
194
|
+
className="w-full cursor-pointer rounded-lg border border-solid border-gray-200 px-6 py-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"
|
|
195
|
+
>
|
|
196
|
+
Show more
|
|
197
|
+
</button>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
{meshEnvironment === "sandbox" && (
|
|
205
|
+
<div className="mt-4 border border-solid border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-800 dark:bg-yellow-900/20">
|
|
206
|
+
<div className="text-center">
|
|
207
|
+
<p className="text-sm font-medium text-yellow-800 dark:text-yellow-200">
|
|
208
|
+
Sandbox environment
|
|
209
|
+
</p>
|
|
210
|
+
<p className="text-xs text-yellow-600 dark:text-yellow-300">
|
|
211
|
+
No real funds are used
|
|
212
|
+
</p>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
216
|
+
</div>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
@@ -4,11 +4,12 @@ import { useState } from "react"
|
|
|
4
4
|
import { getChainName } from "../../chains.js"
|
|
5
5
|
import { isValidNumber } from "../../utils/validation.js"
|
|
6
6
|
import { logger } from "../../logger.js"
|
|
7
|
-
import type { MeldServiceProvider } from "
|
|
7
|
+
import type { MeldServiceProvider } from "@0xtrails/api/onramp"
|
|
8
8
|
import { SECOND_MS, formatRelativeDate } from "../../utils/time.js"
|
|
9
9
|
import { truncateAddress } from "../../utils/address.js"
|
|
10
10
|
import type { MeldTransactionData } from "../hooks/useMeldTransactionHistory.js"
|
|
11
11
|
import { getProviderImage } from "../utils/meldProviderUtils.js"
|
|
12
|
+
import { formatRawStatusLabel } from "../utils/statusLabel.js"
|
|
12
13
|
import { TokenImage } from "./TokenImage.js"
|
|
13
14
|
|
|
14
15
|
function getStatusColor(status: string): string {
|
|
@@ -33,31 +34,6 @@ function getStatusColor(status: string): string {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
function getStatusLabel(status: string): string {
|
|
37
|
-
switch (status) {
|
|
38
|
-
case "COMPLETED":
|
|
39
|
-
return "Completed"
|
|
40
|
-
case "SETTLED":
|
|
41
|
-
return "Settled"
|
|
42
|
-
case "DECLINED":
|
|
43
|
-
return "Declined"
|
|
44
|
-
case "FAILED":
|
|
45
|
-
return "Failed"
|
|
46
|
-
case "CANCELLED":
|
|
47
|
-
return "Cancelled"
|
|
48
|
-
case "ERROR":
|
|
49
|
-
return "Error"
|
|
50
|
-
case "REFUNDED":
|
|
51
|
-
return "Refunded"
|
|
52
|
-
case "PENDING":
|
|
53
|
-
return "Pending"
|
|
54
|
-
case "PROCESSING":
|
|
55
|
-
return "Processing"
|
|
56
|
-
default:
|
|
57
|
-
return status
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
37
|
function formatAmount(amount?: string): string {
|
|
62
38
|
if (!amount) return "-"
|
|
63
39
|
|
|
@@ -206,7 +182,7 @@ export const OnrampHistoryRow: React.FC<OnrampHistoryRowProps> = ({
|
|
|
206
182
|
transaction.status,
|
|
207
183
|
)}`}
|
|
208
184
|
>
|
|
209
|
-
{
|
|
185
|
+
{formatRawStatusLabel(transaction.status)}
|
|
210
186
|
</span>
|
|
211
187
|
|
|
212
188
|
{/* Provider */}
|
|
@@ -226,31 +226,6 @@ export const OnrampProviderConfirmation: React.FC<
|
|
|
226
226
|
!isMeldSuccess &&
|
|
227
227
|
!hasSufficientDeposit
|
|
228
228
|
|
|
229
|
-
// Debug logging
|
|
230
|
-
useEffect(() => {
|
|
231
|
-
logger.console.log("[OnrampProviderConfirmation] Debug info:", {
|
|
232
|
-
externalSessionId,
|
|
233
|
-
transaction,
|
|
234
|
-
isLoadingTransaction,
|
|
235
|
-
transactionError,
|
|
236
|
-
isDirectDeposit,
|
|
237
|
-
hasSufficientDeposit,
|
|
238
|
-
lastTransactionHash,
|
|
239
|
-
meldTransactionHash,
|
|
240
|
-
meldSettledAmount,
|
|
241
|
-
})
|
|
242
|
-
}, [
|
|
243
|
-
externalSessionId,
|
|
244
|
-
transaction,
|
|
245
|
-
isLoadingTransaction,
|
|
246
|
-
transactionError,
|
|
247
|
-
isDirectDeposit,
|
|
248
|
-
hasSufficientDeposit,
|
|
249
|
-
lastTransactionHash,
|
|
250
|
-
meldTransactionHash,
|
|
251
|
-
meldSettledAmount,
|
|
252
|
-
])
|
|
253
|
-
|
|
254
229
|
useEffect(() => {
|
|
255
230
|
const completionKey = externalSessionId || quote?.intentId || "unknown"
|
|
256
231
|
if (
|
|
@@ -21,7 +21,7 @@ import { useSendForm } from "../hooks/useSendForm.js"
|
|
|
21
21
|
import { useSwapAmount } from "../hooks/useSwapAmount.js"
|
|
22
22
|
import { useSwapState } from "../hooks/useSwapState.js"
|
|
23
23
|
import { useTargetAmount } from "../hooks/useTargetAmount.js"
|
|
24
|
-
import {
|
|
24
|
+
import { useAccountTokenBalanceOnchain } from "../../query/balance.hooks.js"
|
|
25
25
|
import type { BaseProps } from "../types/commonProps.js"
|
|
26
26
|
import { AddressOrEnsName } from "./AddressOrEnsName.js"
|
|
27
27
|
import { AddressWalletIcon } from "./AddressWalletIcon.js"
|
|
@@ -130,27 +130,11 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
130
130
|
const { trackClick } = useClickTracking()
|
|
131
131
|
const paymentRequestInputRef = useRef<HTMLInputElement>(null)
|
|
132
132
|
|
|
133
|
-
// Get
|
|
134
|
-
const {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
allSupportedTokens: true, // Show all tokens for destination selection
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
// Get origin token balance for display
|
|
142
|
-
const originTokenBalance = useMemo(() => {
|
|
143
|
-
if (!originToken || !filteredTokensFormatted) return null
|
|
144
|
-
|
|
145
|
-
const foundToken = filteredTokensFormatted.find(
|
|
146
|
-
(token) =>
|
|
147
|
-
token.contractAddress?.toLowerCase() ===
|
|
148
|
-
originToken.contractAddress?.toLowerCase() &&
|
|
149
|
-
token.chainId === originToken.chainId,
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
return foundToken
|
|
153
|
-
}, [originToken, filteredTokensFormatted])
|
|
133
|
+
// Get origin token with fresh balance for display and fee option checks
|
|
134
|
+
const {
|
|
135
|
+
token: freshOriginToken,
|
|
136
|
+
isLoadingBalance: isLoadingFreshOriginBalance,
|
|
137
|
+
} = useAccountTokenBalanceOnchain(originToken, account?.address)
|
|
154
138
|
|
|
155
139
|
// Calculate effective recipient for useSendForm
|
|
156
140
|
const effectiveRecipient =
|
|
@@ -782,9 +766,9 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
782
766
|
type="button"
|
|
783
767
|
className="text-xs text-gray-500 dark:text-gray-400 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none p-0"
|
|
784
768
|
onClick={() => {
|
|
785
|
-
if (
|
|
769
|
+
if (freshOriginToken?.balanceFormatted) {
|
|
786
770
|
const balance = parseFloat(
|
|
787
|
-
|
|
771
|
+
freshOriginToken.balanceFormatted,
|
|
788
772
|
)
|
|
789
773
|
if (isValidNumber(balance)) {
|
|
790
774
|
setTokenAmountForBackend(balance.toFixed(6))
|
|
@@ -794,9 +778,9 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
794
778
|
onKeyDown={(e) => {
|
|
795
779
|
if (e.key === "Enter" || e.key === " ") {
|
|
796
780
|
e.preventDefault()
|
|
797
|
-
if (
|
|
781
|
+
if (freshOriginToken?.balanceFormatted) {
|
|
798
782
|
const balance = parseFloat(
|
|
799
|
-
|
|
783
|
+
freshOriginToken.balanceFormatted,
|
|
800
784
|
)
|
|
801
785
|
if (isValidNumber(balance)) {
|
|
802
786
|
setTokenAmountForBackend(balance.toFixed(6))
|
|
@@ -805,26 +789,26 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
805
789
|
}
|
|
806
790
|
}}
|
|
807
791
|
title="Click to use full balance"
|
|
808
|
-
disabled={!
|
|
792
|
+
disabled={!freshOriginToken?.balanceFormatted}
|
|
809
793
|
>
|
|
810
794
|
<span translate="no">
|
|
811
795
|
Balance:{" "}
|
|
812
|
-
{
|
|
796
|
+
{isLoadingFreshOriginBalance ? (
|
|
813
797
|
<span className="inline-block w-12 h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></span>
|
|
814
798
|
) : (
|
|
815
|
-
|
|
816
|
-
|
|
799
|
+
freshOriginToken?.balanceLocaleDisplay ||
|
|
800
|
+
freshOriginToken?.balanceFormatted ||
|
|
817
801
|
""
|
|
818
802
|
)}
|
|
819
803
|
</span>
|
|
820
804
|
</button>
|
|
821
805
|
|
|
822
806
|
{/* Percentage Buttons - Only show if toAmount is not set */}
|
|
823
|
-
{!toAmount &&
|
|
807
|
+
{!toAmount && freshOriginToken?.balanceFormatted && (
|
|
824
808
|
<PercentageMaxButtons
|
|
825
|
-
userBalance={
|
|
826
|
-
userBalanceRaw={
|
|
827
|
-
decimals={
|
|
809
|
+
userBalance={freshOriginToken.balanceFormatted}
|
|
810
|
+
userBalanceRaw={freshOriginToken.balance ?? "0"}
|
|
811
|
+
decimals={freshOriginToken.decimals ?? 18}
|
|
828
812
|
isNativeToken={originToken.isNativeToken ?? false}
|
|
829
813
|
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
830
814
|
chainId={originToken.chainId}
|
|
@@ -1064,7 +1048,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
1064
1048
|
originToken
|
|
1065
1049
|
? {
|
|
1066
1050
|
originToken,
|
|
1067
|
-
originTokenBalance:
|
|
1051
|
+
originTokenBalance: freshOriginToken?.balance ?? "0",
|
|
1068
1052
|
originTokenAmount:
|
|
1069
1053
|
prepareSendQuote?.originAmountFormatted ?? "0",
|
|
1070
1054
|
}
|
|
@@ -1129,7 +1113,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
1129
1113
|
(selectedFeeOption && originToken
|
|
1130
1114
|
? isFeeOptionDisabled(selectedFeeOption as ProcessedFeeOption, {
|
|
1131
1115
|
originToken: originToken,
|
|
1132
|
-
originTokenBalance:
|
|
1116
|
+
originTokenBalance: freshOriginToken?.balance ?? "0",
|
|
1133
1117
|
originTokenAmount:
|
|
1134
1118
|
prepareSendQuote?.originAmountFormatted ?? "0",
|
|
1135
1119
|
})
|
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
generateMorphoDepositCalldata,
|
|
12
12
|
} from "../../poolUtils.js"
|
|
13
13
|
import { TradeType, type PrepareSendQuote } from "../../prepareSend.js"
|
|
14
|
-
import { formatTvl } from "../../
|
|
15
|
-
import { formatUsdAmountLocaleDisplay } from "../../utils/format.js"
|
|
14
|
+
import { formatTvl, formatUsdAmountLocaleDisplay } from "../../utils/format.js"
|
|
16
15
|
import type { Token } from "../../tokens.js"
|
|
17
16
|
import type { FundMethod } from "../../transactionIntent/types.js"
|
|
18
17
|
import type { TransactionState } from "../../transactions.js"
|
|
@@ -26,9 +25,9 @@ import { useViewManager } from "../hooks/useViewManager.js"
|
|
|
26
25
|
import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
|
|
27
26
|
import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
|
|
28
27
|
import type { OnCompleteProps } from "../hooks/useSendForm.js"
|
|
28
|
+
import { useDefaultOriginToken } from "../hooks/useDefaultOriginToken.js"
|
|
29
29
|
import { useSendForm } from "../hooks/useSendForm.js"
|
|
30
|
-
import {
|
|
31
|
-
import { useTokenWithFreshBalance } from "../hooks/useTokenWithFreshBalance.js"
|
|
30
|
+
import { useAccountTokenBalanceOnchain } from "../../query/balance.hooks.js"
|
|
32
31
|
import { ChainList } from "./ChainList.js"
|
|
33
32
|
import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
|
|
34
33
|
import { EarnPools } from "./EarnPools.js"
|
|
@@ -97,24 +96,19 @@ export const PoolDeposit: React.FC<PoolDepositProps> = ({
|
|
|
97
96
|
const {
|
|
98
97
|
token: freshOriginToken,
|
|
99
98
|
isLoadingBalance: isLoadingFreshOriginBalance,
|
|
100
|
-
} =
|
|
99
|
+
} = useAccountTokenBalanceOnchain(originToken, account?.address)
|
|
101
100
|
|
|
102
101
|
const { selectedPool, setSelectedPool } = useEarnPool()
|
|
103
102
|
|
|
103
|
+
const { defaultOriginToken, isLoading: isLoadingOriginDefaults } =
|
|
104
|
+
useDefaultOriginToken()
|
|
105
|
+
|
|
104
106
|
const [showEarnPools, setShowEarnPools] = useState(false)
|
|
105
107
|
const [showOriginTokenSelector, setShowOriginTokenSelector] = useState(false)
|
|
106
108
|
const [showOriginChainList, setShowOriginChainList] = useState(false)
|
|
107
109
|
const [amount, setAmount] = useState("")
|
|
108
110
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
109
111
|
|
|
110
|
-
// Get sorted tokens to auto-select the highest USD value token
|
|
111
|
-
const { filteredTokensFormatted, isLoadingTokens } = useTokenList({
|
|
112
|
-
onContinue: () => {}, // Not used for auto-selection
|
|
113
|
-
onError: () => {}, // Not used for auto-selection
|
|
114
|
-
fundMethod: undefined,
|
|
115
|
-
allSupportedTokens: false,
|
|
116
|
-
})
|
|
117
|
-
|
|
118
112
|
// Memoized generated calldata
|
|
119
113
|
const generatedDepositCalldata = useMemo(() => {
|
|
120
114
|
if (!selectedPool || !amount || !walletClient || Number(amount) <= 0) {
|
|
@@ -233,19 +227,15 @@ export const PoolDeposit: React.FC<PoolDepositProps> = ({
|
|
|
233
227
|
chainId: originToken?.chainId,
|
|
234
228
|
})
|
|
235
229
|
|
|
236
|
-
// Auto-select the highest USD value token as origin token
|
|
237
230
|
useEffect(() => {
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (highestValueToken && Number(highestValueToken.balanceUsd) > 0) {
|
|
245
|
-
setOriginToken(highestValueToken)
|
|
246
|
-
}
|
|
231
|
+
if (!originToken && !isLoadingOriginDefaults && defaultOriginToken) {
|
|
232
|
+
logger.console.log(
|
|
233
|
+
"[trails-sdk] Auto-selecting origin token:",
|
|
234
|
+
defaultOriginToken,
|
|
235
|
+
)
|
|
236
|
+
setOriginToken(defaultOriginToken as any)
|
|
247
237
|
}
|
|
248
|
-
}, [originToken,
|
|
238
|
+
}, [originToken, isLoadingOriginDefaults, defaultOriginToken, setOriginToken])
|
|
249
239
|
|
|
250
240
|
// Auto-focus input field on component mount
|
|
251
241
|
useEffect(() => {
|
|
@@ -5,7 +5,6 @@ import type { Account, Chain, WalletClient } from "viem"
|
|
|
5
5
|
import { formatUnits, parseAbi, parseUnits } from "viem"
|
|
6
6
|
import { usePublicClient } from "wagmi"
|
|
7
7
|
import { getChainInfo } from "../../chains.js"
|
|
8
|
-
import { estimateGasCostFormatted, estimateGasLimit } from "../../estimate.js"
|
|
9
8
|
import { getExplorerUrlForAddress } from "../../explorer.js"
|
|
10
9
|
import { sendOriginTransaction } from "../../intents.js"
|
|
11
10
|
import { logger } from "../../logger.js"
|
|
@@ -13,8 +12,8 @@ import {
|
|
|
13
12
|
generateAaveWithdrawCalldata,
|
|
14
13
|
generateMorphoWithdrawCalldata,
|
|
15
14
|
} from "../../poolUtils.js"
|
|
16
|
-
import { formatTvl } from "../../prices.js"
|
|
17
15
|
import {
|
|
16
|
+
formatTvl,
|
|
18
17
|
formatAmount,
|
|
19
18
|
formatAmountLocaleDisplay,
|
|
20
19
|
formatUsdAmountLocaleDisplay,
|
|
@@ -71,23 +70,6 @@ export const PoolWithdraw: React.FC<PoolWithdrawProps> = ({
|
|
|
71
70
|
const [isLoadingBalance, setIsLoadingBalance] = useState(false)
|
|
72
71
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
73
72
|
|
|
74
|
-
// Log when pool is selected
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
if (selectedPool) {
|
|
77
|
-
logger.console.log("[pool-withdraw] Pool selected:", {
|
|
78
|
-
name: selectedPool.name,
|
|
79
|
-
protocol: selectedPool.protocol,
|
|
80
|
-
chainId: selectedPool.chainId,
|
|
81
|
-
depositAddress: selectedPool.depositAddress,
|
|
82
|
-
tokenAddress: selectedPool.token.address,
|
|
83
|
-
tokenSymbol: selectedPool.token.symbol,
|
|
84
|
-
tokenDecimals: selectedPool.token.decimals,
|
|
85
|
-
})
|
|
86
|
-
} else {
|
|
87
|
-
logger.console.log("[pool-withdraw] No pool selected")
|
|
88
|
-
}
|
|
89
|
-
}, [selectedPool])
|
|
90
|
-
|
|
91
73
|
// Fetch aToken address for Aave pools
|
|
92
74
|
useEffect(() => {
|
|
93
75
|
const fetchATokenAddress = async () => {
|
|
@@ -366,15 +348,6 @@ export const PoolWithdraw: React.FC<PoolWithdrawProps> = ({
|
|
|
366
348
|
chainId: selectedPool?.chainId,
|
|
367
349
|
})
|
|
368
350
|
|
|
369
|
-
// Log pool balance when it changes
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
logger.console.log("[pool-withdraw] Pool balance updated:", {
|
|
372
|
-
poolBalance,
|
|
373
|
-
hasBalance: !!poolBalance,
|
|
374
|
-
isLoadingBalance,
|
|
375
|
-
})
|
|
376
|
-
}, [poolBalance, isLoadingBalance])
|
|
377
|
-
|
|
378
351
|
// Auto-focus input field on component mount
|
|
379
352
|
useEffect(() => {
|
|
380
353
|
if (inputRef.current) {
|
|
@@ -390,8 +363,6 @@ export const PoolWithdraw: React.FC<PoolWithdrawProps> = ({
|
|
|
390
363
|
}
|
|
391
364
|
}, [showEarnPools, onPoolSelectorStateChange])
|
|
392
365
|
|
|
393
|
-
const [gasCostFormatted, setGasCostFormatted] = useState("")
|
|
394
|
-
|
|
395
366
|
// For Aave, check if wallet has enough aTokens in order to withdraw
|
|
396
367
|
const [hasEnoughATokens, setHasEnoughATokens] = useState<boolean | null>(null)
|
|
397
368
|
useEffect(() => {
|
|
@@ -426,38 +397,6 @@ export const PoolWithdraw: React.FC<PoolWithdrawProps> = ({
|
|
|
426
397
|
}
|
|
427
398
|
}, [publicClient, selectedPool, account, amountToWithdraw])
|
|
428
399
|
|
|
429
|
-
// Estimate gas when pool selected and amount is set
|
|
430
|
-
useEffect(() => {
|
|
431
|
-
const estimateGas = async () => {
|
|
432
|
-
if (publicClient && selectedPool && amountToWithdraw) {
|
|
433
|
-
try {
|
|
434
|
-
const gasLimit = await estimateGasLimit(publicClient, {
|
|
435
|
-
account: account?.address as `0x${string}`,
|
|
436
|
-
to: selectedPool.depositAddress as `0x${string}`,
|
|
437
|
-
data: withdrawCalldata as `0x${string}`,
|
|
438
|
-
value: 0n,
|
|
439
|
-
})
|
|
440
|
-
const gasCostFormatted = await estimateGasCostFormatted(
|
|
441
|
-
publicClient,
|
|
442
|
-
gasLimit || 100_000n,
|
|
443
|
-
18,
|
|
444
|
-
)
|
|
445
|
-
setGasCostFormatted(gasCostFormatted)
|
|
446
|
-
} catch (error) {
|
|
447
|
-
logger.console.error(
|
|
448
|
-
"[pool-withdraw] ❌ Error estimating gas:",
|
|
449
|
-
error,
|
|
450
|
-
)
|
|
451
|
-
}
|
|
452
|
-
} else {
|
|
453
|
-
logger.console.error(
|
|
454
|
-
"[pool-withdraw] ❌ Error estimating gas: no public client or selected pool or amount to withdraw",
|
|
455
|
-
)
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
estimateGas()
|
|
459
|
-
}, [publicClient, selectedPool, withdrawCalldata, account, amountToWithdraw])
|
|
460
|
-
|
|
461
400
|
const handleAmountChange = (value: string) => {
|
|
462
401
|
setAmount(value)
|
|
463
402
|
setAmountToWithdraw(value) // Sync with useSendForm for quote functionality
|
|
@@ -761,7 +700,6 @@ export const PoolWithdraw: React.FC<PoolWithdrawProps> = ({
|
|
|
761
700
|
userBalanceRaw={poolBalanceWei ?? "0"}
|
|
762
701
|
decimals={selectedPool.token.decimals ?? 18}
|
|
763
702
|
isNativeToken={false} // Pool tokens are never native tokens
|
|
764
|
-
gasCostFormatted={gasCostFormatted}
|
|
765
703
|
chainId={selectedPool.chainId}
|
|
766
704
|
onAmountSelect={handleAmountSelect}
|
|
767
705
|
className="opacity-100"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getQRCodeWallets,
|
|
3
|
+
type QRCodeWalletOption,
|
|
4
|
+
} from "@0xtrails/wallet-registry"
|
|
1
5
|
import type React from "react"
|
|
2
|
-
import { useQRCodeWallets, type QRCodeWalletOption } from "../../wallets.js"
|
|
3
6
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
4
7
|
|
|
5
8
|
interface QRCodeWalletSelectProps {
|
|
@@ -19,7 +22,7 @@ export const QRCodeWalletSelect: React.FC<QRCodeWalletSelectProps> = ({
|
|
|
19
22
|
title = "Which wallet will scan the QR code?",
|
|
20
23
|
disabled = false,
|
|
21
24
|
}) => {
|
|
22
|
-
const defaultQrCodeWallets =
|
|
25
|
+
const defaultQrCodeWallets = getQRCodeWallets()
|
|
23
26
|
const defaultWalletOptions = walletOptions || defaultQrCodeWallets
|
|
24
27
|
return (
|
|
25
28
|
<div className="space-y-6">
|