0xtrails 0.6.6 → 0.7.0
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/aave.d.ts +10 -2
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +26 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-CbJrlK-L.js → ccip-fConRNoG.js} +21 -21
- package/dist/chains.d.ts +23 -8
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts +12 -0
- package/dist/customTokens.d.ts.map +1 -0
- package/dist/decoders.d.ts +2 -2
- package/dist/decoders.d.ts.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +37 -2
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +15 -36
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-w7_dK4c5.js → index-BbajxCG_.js} +59269 -77146
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +828 -359
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentReceiptMonitor.d.ts +1 -1
- package/dist/intentReceiptMonitor.d.ts.map +1 -1
- package/dist/intentReceiptPoller.d.ts +1 -1
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intents.d.ts +3 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/mutations.d.ts +2 -2
- package/dist/mutations.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +2 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/time.d.ts +6 -0
- package/dist/time.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +40 -25
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +54 -14
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +1 -1
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/trailsRouter.d.ts +2 -1
- package/dist/trailsRouter.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +5 -3
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +5 -3
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/feeExtractors.d.ts +1 -6
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +4 -2
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +28 -5
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +0 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/validators.d.ts +0 -2
- package/dist/transactionIntent/validators.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/wallets.d.ts +1 -0
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AddressWalletIcon.d.ts +6 -0
- package/dist/widget/components/AddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -6
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ChainImage.d.ts.map +1 -1
- package/dist/widget/components/ChainList.d.ts +0 -5
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +6 -6
- 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/DebugMenu.d.ts +1 -1
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DepositTracker.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts +5 -5
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +1 -1
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +2 -2
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Footer.d.ts +1 -1
- package/dist/widget/components/Footer.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +5 -5
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts +0 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +6 -6
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/HookModalContent.d.ts +8 -0
- package/dist/widget/components/HookModalContent.d.ts.map +1 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts +11 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +5 -5
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +5 -5
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -3
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts +2 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts +4 -4
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ShadowPortal.d.ts +6 -0
- package/dist/widget/components/ShadowPortal.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +6 -6
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts +3 -4
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +3 -4
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +6 -1
- package/dist/widget/components/Tooltip.d.ts.map +1 -1
- package/dist/widget/components/TrailsHookModal.d.ts +10 -0
- package/dist/widget/components/TrailsHookModal.d.ts.map +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts +3 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WidgetProviders.d.ts +14 -0
- package/dist/widget/components/WidgetProviders.d.ts.map +1 -0
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts +10 -0
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +13 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useConnector.d.ts +4 -0
- package/dist/widget/hooks/useConnector.d.ts.map +1 -0
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +19 -0
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +1 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +20 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -0
- package/dist/widget/hooks/useDebounce.d.ts +10 -0
- package/dist/widget/hooks/useDebounce.d.ts.map +1 -0
- package/dist/widget/hooks/useDebugScreens.d.ts +7 -2
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -19
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts +1 -14
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsMobile.d.ts +5 -0
- package/dist/widget/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/widget/hooks/useMode.d.ts +2 -2
- package/dist/widget/hooks/useMode.d.ts.map +1 -1
- package/dist/widget/hooks/useOriginSelectedToken.d.ts +2 -15
- package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +173 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts +3 -3
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useRecipients.d.ts +1 -1
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +2 -2
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +9 -31
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -1
- package/dist/widget/hooks/useTheme.d.ts +1 -1
- package/dist/widget/hooks/useTheme.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -31
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts +83 -0
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts +11 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -0
- package/dist/widget/hooks/useWidgetProps.d.ts +5 -0
- package/dist/widget/hooks/useWidgetProps.d.ts.map +1 -1
- package/dist/widget/index.d.ts +2 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +8 -5
- package/dist/widget/providers/TrailsModalProvider.d.ts +65 -0
- package/dist/widget/providers/TrailsModalProvider.d.ts.map +1 -0
- package/dist/widget/providers/TrailsProvider.d.ts +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/types.d.ts +11 -18
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +20 -11
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +45 -49
- package/src/aave.ts +387 -138
- package/src/analytics.ts +208 -2
- package/src/chains.ts +65 -64
- package/src/constants.ts +18 -14
- package/src/customTokens.ts +151 -0
- package/src/decoders.ts +4 -7
- package/src/error.ts +7 -3
- package/src/fees.ts +239 -125
- package/src/gasless.ts +54 -108
- package/src/index.ts +29 -9
- package/src/indexerClient.ts +2 -0
- package/src/intentReceiptMonitor.ts +1 -4
- package/src/intentReceiptPoller.ts +2 -2
- package/src/intents.ts +16 -5
- package/src/mode.ts +1 -1
- package/src/mutations.ts +7 -3
- package/src/prepareSend.ts +19 -14
- package/src/prices.ts +1 -1
- package/src/sequenceWallet.ts +2 -2
- package/src/time.ts +28 -0
- package/src/tokenBalances.ts +348 -153
- package/src/tokens.ts +393 -142
- package/src/trailsClient.ts +1 -1
- package/src/trailsRouter.ts +4 -5
- package/src/transactionIntent/deposits/depositOrchestrator.ts +6 -2
- package/src/transactionIntent/deposits/gaslessDeposit.ts +13 -7
- package/src/transactionIntent/deposits/standardDeposit.ts +1 -1
- package/src/transactionIntent/execution/transactionState.ts +1 -1
- package/src/transactionIntent/handlers/crossChain.ts +75 -37
- package/src/transactionIntent/handlers/sameChainSameToken.ts +66 -20
- package/src/transactionIntent/quote/feeExtractors.ts +1 -29
- package/src/transactionIntent/quote/normalizeQuote.ts +99 -7
- package/src/transactionIntent/quote/quoteHelpers.ts +1 -1
- package/src/transactionIntent/types.ts +31 -6
- package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
- package/src/transactionIntent/validators.ts +0 -30
- package/src/transactions.ts +3 -3
- package/src/utils.ts +18 -0
- package/src/wallets.ts +32 -10
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +2 -1
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +2 -2
- package/src/widget/components/AddressWalletIcon.tsx +29 -0
- package/src/widget/components/ChainFilterDropdown.tsx +2 -8
- package/src/widget/components/ChainImage.tsx +8 -5
- package/src/widget/components/ChainList.tsx +6 -8
- package/src/widget/components/ClassicSwap.tsx +93 -85
- package/src/widget/components/ConnectWallet.tsx +1 -2
- package/src/widget/components/ConnectedWallets.tsx +17 -4
- package/src/widget/components/DebugMenu.tsx +2 -2
- package/src/widget/components/DebugScreensList.tsx +0 -1
- package/src/widget/components/DepositTracker.tsx +20 -34
- package/src/widget/components/Earn.tsx +7 -6
- package/src/widget/components/FeeOption.tsx +4 -4
- package/src/widget/components/FeeOptions.tsx +19 -39
- package/src/widget/components/Footer.tsx +1 -1
- package/src/widget/components/Fund.tsx +23 -119
- package/src/widget/components/FundMethods.tsx +9 -6
- package/src/widget/components/FundSwap.tsx +6 -5
- package/src/widget/components/FundingMethodSelectorButton.tsx +2 -2
- package/src/widget/components/HookModalContent.tsx +306 -0
- package/src/widget/components/Modal.tsx +1 -1
- package/src/widget/components/OriginSelectionAmount.tsx +135 -0
- package/src/widget/components/Pay.tsx +66 -124
- package/src/widget/components/PoolDeposit.tsx +11 -55
- package/src/widget/components/PoolWithdraw.tsx +3 -3
- package/src/widget/components/QuoteDetails.tsx +473 -728
- package/src/widget/components/Receipt.tsx +74 -7
- package/src/widget/components/RecentTokens.tsx +8 -8
- package/src/widget/components/RecipientSelectorButton.tsx +4 -2
- package/src/widget/components/ScreenHeader.tsx +2 -2
- package/src/widget/components/SearchInputField.tsx +1 -1
- package/src/widget/components/ShadowPortal.tsx +58 -0
- package/src/widget/components/Swap.tsx +6 -5
- package/src/widget/components/ThemeProvider.tsx +1 -1
- package/src/widget/components/TokenList.tsx +3 -4
- package/src/widget/components/TokenSelector.tsx +211 -80
- package/src/widget/components/Tooltip.tsx +18 -7
- package/src/widget/components/TrailsHookModal.tsx +118 -0
- package/src/widget/components/WaasFeeOptions.tsx +333 -138
- package/src/widget/components/WalletConfirmation.tsx +7 -2
- package/src/widget/components/WalletConnect.tsx +197 -235
- package/src/widget/components/WidgetProviders.tsx +75 -0
- package/src/widget/hooks/useAddressWalletIcon.ts +53 -0
- package/src/widget/hooks/useBalanceVisible.tsx +1 -1
- package/src/widget/hooks/useChainFilter.tsx +1 -1
- package/src/widget/hooks/useCheckout.ts +13 -1
- package/src/widget/hooks/useConnector.tsx +18 -0
- package/src/widget/hooks/useCurrentScreen.tsx +3 -3
- package/src/widget/hooks/useCustomTokenFetch.tsx +72 -0
- package/src/widget/hooks/useCustomTokenSearch.tsx +402 -0
- package/src/widget/hooks/useDebounce.ts +25 -0
- package/src/widget/hooks/useDebugScreens.ts +26 -10
- package/src/widget/hooks/useDefaultTokenSelection.tsx +99 -143
- package/src/widget/hooks/useDestinationSelectedToken.tsx +1 -14
- package/src/widget/hooks/useEarnPool.tsx +1 -1
- package/src/widget/hooks/useIntentTransactionHistory.ts +20 -11
- package/src/widget/hooks/useIsMobile.tsx +50 -0
- package/src/widget/hooks/useMode.ts +2 -3
- package/src/widget/hooks/useOriginSelectedToken.tsx +2 -15
- package/src/widget/hooks/usePayMessage.tsx +31 -11
- package/src/widget/hooks/usePriceImpactWarning.ts +1 -1
- package/src/widget/hooks/useQuote.ts +189 -6
- package/src/widget/hooks/useRecentTokens.ts +6 -6
- package/src/widget/hooks/useRecipients.ts +1 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +2 -2
- package/src/widget/hooks/useSelectedFundMethod.tsx +1 -1
- package/src/widget/hooks/useSelectedRecipient.tsx +1 -1
- package/src/widget/hooks/useSendForm.ts +328 -152
- package/src/widget/hooks/useSwapAmount.tsx +1 -1
- package/src/widget/hooks/useTheme.tsx +1 -1
- package/src/widget/hooks/useTokenList.ts +672 -400
- package/src/widget/hooks/useTrailsSendTransaction.ts +949 -0
- package/src/widget/hooks/useWalletConnectUri.tsx +228 -0
- package/src/widget/hooks/useWidgetProps.tsx +3 -1
- package/src/widget/index.tsx +12 -0
- package/src/widget/providers/TrailsModalProvider.tsx +195 -0
- package/src/widget/providers/TrailsProvider.tsx +9 -3
- package/src/widget/types.ts +12 -20
- package/src/widget/widget.tsx +598 -385
- package/dist/cctp.d.ts +0 -3
- package/dist/cctp.d.ts.map +0 -1
- package/dist/lifi.d.ts +0 -4
- package/dist/lifi.d.ts.map +0 -1
- package/dist/meshconnect.d.ts +0 -171
- package/dist/meshconnect.d.ts.map +0 -1
- package/dist/relaySdk.d.ts +0 -87
- package/dist/relaySdk.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -7
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +0 -13
- package/dist/widget/components/MeshConnectFlow.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectIframe.d.ts +0 -15
- package/dist/widget/components/MeshConnectIframe.d.ts.map +0 -1
- package/dist/widget/components/Receive.d.ts +0 -12
- package/dist/widget/components/Receive.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +0 -14
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +0 -1
- package/src/cctp.ts +0 -54
- package/src/lifi.ts +0 -108
- package/src/meshconnect.ts +0 -531
- package/src/relaySdk.ts +0 -703
- package/src/widget/components/MeshConnectExchanges.tsx +0 -290
- package/src/widget/components/MeshConnectFlow.tsx +0 -90
- package/src/widget/components/MeshConnectIframe.tsx +0 -500
- package/src/widget/components/Receive.tsx +0 -175
- package/src/widget/hooks/useSelectedMeshExchange.tsx +0 -46
|
@@ -6,13 +6,11 @@ import { ChainImage } from "./ChainImage.js"
|
|
|
6
6
|
import { AllChainsIcon } from "./AllChainsIcon.js"
|
|
7
7
|
import { SearchInputField } from "./SearchInputField.js"
|
|
8
8
|
import { useChainFilter } from "../hooks/useChainFilter.js"
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
imageUrl?: string
|
|
15
|
-
}
|
|
9
|
+
import {
|
|
10
|
+
useSupportedChains,
|
|
11
|
+
getNormalizedChainName,
|
|
12
|
+
type ChainListItem,
|
|
13
|
+
} from "../../chains.js"
|
|
16
14
|
|
|
17
15
|
interface ChainListProps {
|
|
18
16
|
onBack: () => void
|
|
@@ -24,7 +22,7 @@ export const ChainList: React.FC<ChainListProps> = ({ onBack }) => {
|
|
|
24
22
|
const { supportedChains } = useSupportedChains()
|
|
25
23
|
|
|
26
24
|
// Convert chains to ChainListItem format
|
|
27
|
-
const chainList = useMemo(() => {
|
|
25
|
+
const chainList: ChainListItem[] = useMemo(() => {
|
|
28
26
|
return supportedChains.map((chain) => ({
|
|
29
27
|
chainId: chain.id,
|
|
30
28
|
name: chain.name,
|
|
@@ -2,10 +2,9 @@ import { Loader2, ArrowDown } from "lucide-react"
|
|
|
2
2
|
import type React from "react"
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
4
4
|
import type { Account, WalletClient } from "viem"
|
|
5
|
-
import { zeroAddress } from "viem"
|
|
6
5
|
import type { TransactionState } from "../../transactions.js"
|
|
7
|
-
import type { OnCompleteProps
|
|
8
|
-
import type {
|
|
6
|
+
import type { OnCompleteProps } from "../hooks/useSendForm.js"
|
|
7
|
+
import type { Token } from "../../tokens.js"
|
|
9
8
|
import { useSendForm } from "../hooks/useSendForm.js"
|
|
10
9
|
import type { CheckoutOnHandlers } from "../hooks/useCheckout.js"
|
|
11
10
|
import { QuoteDetails } from "./QuoteDetails.js"
|
|
@@ -13,7 +12,6 @@ import { type PrepareSendQuote, TradeType } from "../../prepareSend.js"
|
|
|
13
12
|
import { getChainInfo } from "../../chains.js"
|
|
14
13
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
15
14
|
import { TokenSelector } from "./TokenSelector.js"
|
|
16
|
-
import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
17
15
|
import { useMode } from "../hooks/useMode.js"
|
|
18
16
|
import { logger } from "../../logger.js"
|
|
19
17
|
import { useSelectedRecipient } from "../hooks/useSelectedRecipient.js"
|
|
@@ -33,6 +31,7 @@ import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
|
|
|
33
31
|
import { FeeOptions } from "./FeeOptions.js"
|
|
34
32
|
import { isFeeOptionDisabled } from "./FeeOption.js"
|
|
35
33
|
import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
|
|
34
|
+
import { formatRawAmount } from "../../tokenBalances.js"
|
|
36
35
|
|
|
37
36
|
interface ClassicSwapProps {
|
|
38
37
|
selectedToken: Token | null
|
|
@@ -54,7 +53,7 @@ interface ClassicSwapProps {
|
|
|
54
53
|
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
55
54
|
quoteProvider?: string
|
|
56
55
|
fundMethod?: string
|
|
57
|
-
|
|
56
|
+
onNavigateToOnramp?: (
|
|
58
57
|
props: {
|
|
59
58
|
toTokenSymbol: string
|
|
60
59
|
toTokenAmount: string
|
|
@@ -62,11 +61,12 @@ interface ClassicSwapProps {
|
|
|
62
61
|
toRecipientAddress: string
|
|
63
62
|
},
|
|
64
63
|
quote?: PrepareSendQuote | null,
|
|
64
|
+
continueSend?: () => Promise<void>,
|
|
65
65
|
) => void
|
|
66
66
|
onAmountUpdate?: (amount: string) => void
|
|
67
67
|
checkoutOnHandlers?: CheckoutOnHandlers
|
|
68
|
-
recentTokens?:
|
|
69
|
-
onRecentTokenSelect?: (token:
|
|
68
|
+
recentTokens?: Token[]
|
|
69
|
+
onRecentTokenSelect?: (token: Token) => void
|
|
70
70
|
onTrackToken?: (token: any) => void
|
|
71
71
|
title?: string
|
|
72
72
|
isSequenceWallet?: boolean
|
|
@@ -92,7 +92,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
92
92
|
setWalletConfirmRetryHandler,
|
|
93
93
|
quoteProvider,
|
|
94
94
|
fundMethod,
|
|
95
|
-
|
|
95
|
+
onNavigateToOnramp,
|
|
96
96
|
onAmountUpdate,
|
|
97
97
|
checkoutOnHandlers,
|
|
98
98
|
recentTokens,
|
|
@@ -180,8 +180,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
180
180
|
destinationTokenAddress,
|
|
181
181
|
isValidCustomToken,
|
|
182
182
|
prepareSendQuote,
|
|
183
|
-
quoteError,
|
|
184
|
-
quoteErrorPrettified,
|
|
185
183
|
processedFeeOptions,
|
|
186
184
|
selectedFeeOption,
|
|
187
185
|
setSelectedFeeOption,
|
|
@@ -206,10 +204,23 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
206
204
|
quoteProvider,
|
|
207
205
|
fundMethod,
|
|
208
206
|
mode,
|
|
209
|
-
|
|
207
|
+
onNavigateToOnramp,
|
|
210
208
|
checkoutOnHandlers,
|
|
211
209
|
})
|
|
212
210
|
|
|
211
|
+
const destinationBalanceDisplay = useMemo(() => {
|
|
212
|
+
if (!destinationToken) return "0.00"
|
|
213
|
+
try {
|
|
214
|
+
return formatRawAmount(
|
|
215
|
+
destinationToken.balance || "0",
|
|
216
|
+
destinationToken.decimals ?? 18,
|
|
217
|
+
)
|
|
218
|
+
} catch (err) {
|
|
219
|
+
logger.console.error("[trails-sdk] balance format failed", err)
|
|
220
|
+
return "0.00"
|
|
221
|
+
}
|
|
222
|
+
}, [destinationToken])
|
|
223
|
+
|
|
213
224
|
// Update amount based on last input type
|
|
214
225
|
useEffect(() => {
|
|
215
226
|
if (lastInputType === "sell") {
|
|
@@ -345,7 +356,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
345
356
|
}, [destinationToken, setSelectedDestToken])
|
|
346
357
|
|
|
347
358
|
// Handle flip functionality
|
|
348
|
-
const handleFlip = () => {
|
|
359
|
+
const handleFlip = useCallback(() => {
|
|
349
360
|
if (!selectedDestinationChain || !originToken || !selectedDestToken) return
|
|
350
361
|
|
|
351
362
|
setIsFlipped(!isFlipped)
|
|
@@ -354,6 +365,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
354
365
|
const tempOriginToken = originToken
|
|
355
366
|
const tempOriginChainId = originChainId
|
|
356
367
|
const tempBuyAmount = buyAmount || toAmountDisplay || ""
|
|
368
|
+
const tempSellAmount = sellAmount || amount || ""
|
|
357
369
|
|
|
358
370
|
// Swap origin and destination using hooks
|
|
359
371
|
setOriginToken(selectedDestToken as any)
|
|
@@ -367,38 +379,41 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
367
379
|
setSelectedDestinationChain(newChain)
|
|
368
380
|
}
|
|
369
381
|
|
|
370
|
-
// When flipping, always set the current visible amount as the new sell amount
|
|
371
382
|
if (tradeType === TradeType.EXACT_INPUT) {
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
378
|
-
setLastInputType("sell")
|
|
383
|
+
// Move the user-entered sell amount into the buy field and treat it as exact output
|
|
384
|
+
setBuyAmount(tempSellAmount)
|
|
385
|
+
setSellAmount("")
|
|
386
|
+
setTradeType(TradeType.EXACT_OUTPUT)
|
|
387
|
+
setLastInputType("buy")
|
|
379
388
|
} else {
|
|
380
389
|
// If we were in EXACT_OUTPUT, use the current buy amount as the new sell amount
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
setSellAmount("")
|
|
384
|
-
}
|
|
390
|
+
setSellAmount(tempBuyAmount)
|
|
391
|
+
setBuyAmount("")
|
|
385
392
|
setTradeType(TradeType.EXACT_INPUT)
|
|
386
393
|
setLastInputType("sell")
|
|
387
394
|
}
|
|
388
|
-
}
|
|
395
|
+
}, [
|
|
396
|
+
originToken,
|
|
397
|
+
selectedDestinationChain,
|
|
398
|
+
selectedDestToken,
|
|
399
|
+
originChainId,
|
|
400
|
+
setOriginToken,
|
|
401
|
+
setDestinationToken,
|
|
402
|
+
setSelectedDestToken,
|
|
403
|
+
setSelectedDestinationChain,
|
|
404
|
+
isFlipped,
|
|
405
|
+
tradeType,
|
|
406
|
+
sellAmount,
|
|
407
|
+
buyAmount,
|
|
408
|
+
toAmountDisplay,
|
|
409
|
+
amount,
|
|
410
|
+
])
|
|
389
411
|
|
|
390
412
|
// Handle source token selection from full-screen selector
|
|
391
413
|
const handleSourceTokenSelectorSelect = useCallback(
|
|
392
|
-
(token:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
decimals: token.contractInfo?.decimals || token.decimals,
|
|
396
|
-
contractInfo: {
|
|
397
|
-
decimals: token.contractInfo?.decimals || token.decimals,
|
|
398
|
-
contractAddress: token.contractAddress,
|
|
399
|
-
symbol: token.symbol,
|
|
400
|
-
name: token.name,
|
|
401
|
-
},
|
|
414
|
+
(token: Token) => {
|
|
415
|
+
if (token.contractAddress === destinationToken?.contractAddress) {
|
|
416
|
+
handleFlip()
|
|
402
417
|
}
|
|
403
418
|
|
|
404
419
|
// Only reset input fields if the token symbol is different
|
|
@@ -411,31 +426,33 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
411
426
|
setLastInputType("sell")
|
|
412
427
|
}
|
|
413
428
|
|
|
414
|
-
setOriginToken(
|
|
429
|
+
setOriginToken(token)
|
|
415
430
|
setOriginChainId(token.chainId)
|
|
416
431
|
setShowSourceTokenSelector(false)
|
|
417
432
|
|
|
418
433
|
onTrackToken?.(token)
|
|
419
434
|
logger.console.log("[trails-sdk] selected origin token", token)
|
|
420
435
|
},
|
|
421
|
-
[
|
|
436
|
+
[
|
|
437
|
+
setOriginToken,
|
|
438
|
+
onTrackToken,
|
|
439
|
+
originToken?.symbol,
|
|
440
|
+
originToken,
|
|
441
|
+
handleFlip,
|
|
442
|
+
destinationToken?.contractAddress,
|
|
443
|
+
destinationToken,
|
|
444
|
+
],
|
|
422
445
|
)
|
|
423
446
|
|
|
424
447
|
// Handle destination token selection from full-screen selector
|
|
425
448
|
const handleDestinationTokenSelectorSelect = useCallback(
|
|
426
|
-
(token:
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
decimals: token.contractInfo?.decimals || token.decimals,
|
|
430
|
-
contractInfo: {
|
|
431
|
-
decimals: token.contractInfo?.decimals || token.decimals,
|
|
432
|
-
contractAddress: token.contractAddress,
|
|
433
|
-
symbol: token.symbol,
|
|
434
|
-
name: token.name,
|
|
435
|
-
},
|
|
449
|
+
(token: Token) => {
|
|
450
|
+
if (token.contractAddress === originToken?.contractAddress) {
|
|
451
|
+
handleFlip()
|
|
436
452
|
}
|
|
437
|
-
|
|
438
|
-
|
|
453
|
+
|
|
454
|
+
setDestinationToken(token)
|
|
455
|
+
setSelectedDestToken(token)
|
|
439
456
|
|
|
440
457
|
// Update destination chain
|
|
441
458
|
const chainInfo = getChainInfo(token.chainId)
|
|
@@ -452,12 +469,18 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
452
469
|
setSelectedDestToken,
|
|
453
470
|
setSelectedDestinationChain,
|
|
454
471
|
onTrackToken,
|
|
472
|
+
originToken?.contractAddress,
|
|
473
|
+
handleFlip,
|
|
455
474
|
],
|
|
456
475
|
)
|
|
457
476
|
|
|
458
477
|
// Handle recent token selection
|
|
459
478
|
const handleRecentTokenSelect = useCallback(
|
|
460
479
|
(token: any) => {
|
|
480
|
+
if (token.contractAddress === originToken?.contractAddress) {
|
|
481
|
+
handleFlip()
|
|
482
|
+
}
|
|
483
|
+
|
|
461
484
|
if (showSourceTokenSelector) {
|
|
462
485
|
handleSourceTokenSelectorSelect(token)
|
|
463
486
|
} else if (showDestinationTokenSelector) {
|
|
@@ -469,6 +492,8 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
469
492
|
showDestinationTokenSelector,
|
|
470
493
|
handleSourceTokenSelectorSelect,
|
|
471
494
|
handleDestinationTokenSelectorSelect,
|
|
495
|
+
originToken?.contractAddress,
|
|
496
|
+
handleFlip,
|
|
472
497
|
],
|
|
473
498
|
)
|
|
474
499
|
|
|
@@ -661,7 +686,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
661
686
|
{/* Percentage Buttons */}
|
|
662
687
|
<PercentageMaxButtons
|
|
663
688
|
userBalance={balanceFormatted}
|
|
664
|
-
isNativeToken={originToken.
|
|
689
|
+
isNativeToken={originToken.isNativeToken ?? false}
|
|
665
690
|
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
666
691
|
chainId={originChainId || undefined}
|
|
667
692
|
onAmountSelect={(amount) => {
|
|
@@ -752,7 +777,13 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
752
777
|
</div>
|
|
753
778
|
|
|
754
779
|
{/* Bottom Info Row */}
|
|
755
|
-
<div
|
|
780
|
+
<div
|
|
781
|
+
className={
|
|
782
|
+
!prepareSendQuote?.destinationAmountUsdDisplay && !isLoadingQuote
|
|
783
|
+
? "flex justify-end mt-4"
|
|
784
|
+
: "mt-4 flex items-center justify-between"
|
|
785
|
+
}
|
|
786
|
+
>
|
|
756
787
|
{/* Destination Amount USD from Quote */}
|
|
757
788
|
{(prepareSendQuote?.destinationAmountUsdDisplay ||
|
|
758
789
|
(isLoadingQuote && tradeType === TradeType.EXACT_INPUT)) && (
|
|
@@ -763,16 +794,18 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
763
794
|
: prepareSendQuote?.destinationAmountUsdDisplay}
|
|
764
795
|
</div>
|
|
765
796
|
)}
|
|
797
|
+
|
|
798
|
+
{/* Dest Token Balance */}
|
|
799
|
+
{destinationToken && (
|
|
800
|
+
<div className="flex justify-end">
|
|
801
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
802
|
+
Balance:{" "}
|
|
803
|
+
{isBalanceVisible ? destinationBalanceDisplay : "0.00"}
|
|
804
|
+
</div>
|
|
805
|
+
</div>
|
|
806
|
+
)}
|
|
766
807
|
</div>
|
|
767
808
|
</div>
|
|
768
|
-
|
|
769
|
-
{/* Warning Messages - Show only one at a time */}
|
|
770
|
-
<ErrorDisplay
|
|
771
|
-
errorPrettified={quoteErrorPrettified}
|
|
772
|
-
error={quoteError}
|
|
773
|
-
severity="warning"
|
|
774
|
-
/>
|
|
775
|
-
|
|
776
809
|
{/* Exchange/Contract Warning */}
|
|
777
810
|
<RefundWarning
|
|
778
811
|
fundMethod={fundMethod}
|
|
@@ -781,34 +814,9 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
781
814
|
isSequenceWallet={isSequenceWallet}
|
|
782
815
|
/>
|
|
783
816
|
|
|
784
|
-
{prepareSendQuote?.noSufficientBalance ? (
|
|
785
|
-
<div className="px-2 py-3 rounded-lg bg-amber-500/10 border border-solid border-amber-500/30">
|
|
786
|
-
<div className="flex items-center space-x-2">
|
|
787
|
-
<svg
|
|
788
|
-
className="w-4 h-4 text-amber-500 flex-shrink-0"
|
|
789
|
-
fill="none"
|
|
790
|
-
stroke="currentColor"
|
|
791
|
-
viewBox="0 0 24 24"
|
|
792
|
-
aria-hidden="true"
|
|
793
|
-
>
|
|
794
|
-
<path
|
|
795
|
-
strokeLinecap="round"
|
|
796
|
-
strokeLinejoin="round"
|
|
797
|
-
strokeWidth={2}
|
|
798
|
-
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
799
|
-
/>
|
|
800
|
-
</svg>
|
|
801
|
-
<p className="text-sm text-amber-600 dark:text-amber-400">
|
|
802
|
-
Insufficient balance to complete this transaction. Required{" "}
|
|
803
|
-
{prepareSendQuote?.originAmountDisplay} {originToken?.symbol}
|
|
804
|
-
</p>
|
|
805
|
-
</div>
|
|
806
|
-
</div>
|
|
807
|
-
) : null}
|
|
808
|
-
|
|
809
817
|
{/* Quote Details */}
|
|
810
818
|
{prepareSendQuote && (
|
|
811
|
-
<div
|
|
819
|
+
<div>
|
|
812
820
|
<QuoteDetails
|
|
813
821
|
quote={prepareSendQuote}
|
|
814
822
|
showContent={true}
|
|
@@ -13,7 +13,6 @@ import { logger } from "../../logger.js"
|
|
|
13
13
|
import { truncateAddress } from "../../utils.js"
|
|
14
14
|
import { useCurrentScreen } from "../hooks/useCurrentScreen.js"
|
|
15
15
|
import { useBack } from "../hooks/useBack.js"
|
|
16
|
-
|
|
17
16
|
export interface WalletOption {
|
|
18
17
|
id: string
|
|
19
18
|
name: string
|
|
@@ -174,7 +173,7 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = ({
|
|
|
174
173
|
)
|
|
175
174
|
|
|
176
175
|
if (connection) {
|
|
177
|
-
|
|
176
|
+
switchAccount({
|
|
178
177
|
connector: connection.connector,
|
|
179
178
|
})
|
|
180
179
|
logger.console.log(`[trails-sdk] Switched to wallet: ${walletAddress}`)
|
|
@@ -15,6 +15,7 @@ import { Identicon } from "./Identicon.js"
|
|
|
15
15
|
import { useBack } from "../hooks/useBack.js"
|
|
16
16
|
import type { Screen } from "../hooks/useCurrentScreen.js"
|
|
17
17
|
import { useWalletConnectionContext } from "../hooks/useWalletConnectionContext.js"
|
|
18
|
+
import { useSelectedRecipient } from "../hooks/useSelectedRecipient.js"
|
|
18
19
|
|
|
19
20
|
export interface ConnectedWalletsProps {
|
|
20
21
|
onWalletSwitch?: (address: string) => void
|
|
@@ -163,7 +164,7 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
163
164
|
</span>
|
|
164
165
|
) : !onWalletSelect && !hideActiveState ? (
|
|
165
166
|
<span className="whitespace-nowrap text-xs px-2 py-1 rounded font-medium bg-gray-200 text-gray-700 dark:bg-gray-600 dark:text-gray-300 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
|
166
|
-
|
|
167
|
+
Activate
|
|
167
168
|
</span>
|
|
168
169
|
) : null}
|
|
169
170
|
{!isLoadingTotalBalanceUsd && totalBalanceUsdFormatted && (
|
|
@@ -176,7 +177,7 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
176
177
|
onClick={(e) => onDisconnect(wallet.connector, e)}
|
|
177
178
|
onMouseDown={(e) => e.stopPropagation()}
|
|
178
179
|
onMouseUp={(e) => e.stopPropagation()}
|
|
179
|
-
className="p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-600
|
|
180
|
+
className="p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer"
|
|
180
181
|
title="Disconnect wallet"
|
|
181
182
|
>
|
|
182
183
|
<X className="w-4 h-4 text-gray-500 dark:text-gray-400" />
|
|
@@ -207,6 +208,7 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
|
|
|
207
208
|
const { setConnectionContext } = useWalletConnectionContext()
|
|
208
209
|
const [error, setError] = useState<string | null>(null)
|
|
209
210
|
const [copiedAddress, setCopiedAddress] = useState<string | null>(null)
|
|
211
|
+
const { selectedRecipient, setSelectedRecipient } = useSelectedRecipient()
|
|
210
212
|
|
|
211
213
|
// Get all connected wallets with their details
|
|
212
214
|
const getConnectedWallets = () => {
|
|
@@ -253,7 +255,7 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
|
|
|
253
255
|
)
|
|
254
256
|
|
|
255
257
|
if (connection) {
|
|
256
|
-
|
|
258
|
+
switchAccount({
|
|
257
259
|
connector: connection.connector,
|
|
258
260
|
})
|
|
259
261
|
logger.console.log(`[trails-sdk] Switched to wallet: ${walletAddress}`)
|
|
@@ -280,7 +282,18 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
|
|
|
280
282
|
e.stopPropagation()
|
|
281
283
|
try {
|
|
282
284
|
setError(null)
|
|
283
|
-
|
|
285
|
+
disconnect({ connector: walletConnector })
|
|
286
|
+
const disconnectedAddress = (await walletConnector.getAccounts())[0]
|
|
287
|
+
if (selectedRecipient === disconnectedAddress) {
|
|
288
|
+
const connectedWallets = getConnectedWallets()
|
|
289
|
+
if (connectedWallets.length > 0) {
|
|
290
|
+
setSelectedRecipient(
|
|
291
|
+
connectedWallets.filter(
|
|
292
|
+
(wallet) => wallet.address !== disconnectedAddress,
|
|
293
|
+
)[0].address,
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
284
297
|
logger.console.log("[trails-sdk] Disconnected wallet")
|
|
285
298
|
} catch (error) {
|
|
286
299
|
logger.console.error("[trails-sdk] Failed to disconnect wallet:", error)
|
|
@@ -7,7 +7,7 @@ import { DebugScreensList } from "./DebugScreensList.js"
|
|
|
7
7
|
import { DebugToast } from "./DebugToast.js"
|
|
8
8
|
|
|
9
9
|
interface DebugMenuProps {
|
|
10
|
-
onScreenSelect
|
|
10
|
+
onScreenSelect?: (screen: string) => void
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const DebugMenu: React.FC<DebugMenuProps> = ({ onScreenSelect }) => {
|
|
@@ -18,7 +18,7 @@ export const DebugMenu: React.FC<DebugMenuProps> = ({ onScreenSelect }) => {
|
|
|
18
18
|
|
|
19
19
|
// Wrap onScreenSelect to close dropdown when screen is selected
|
|
20
20
|
const handleScreenSelect = (screen: string) => {
|
|
21
|
-
onScreenSelect(screen)
|
|
21
|
+
onScreenSelect?.(screen)
|
|
22
22
|
setIsOpen(false)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -3,12 +3,8 @@ import { useMemo, useEffect } from "react"
|
|
|
3
3
|
import { CheckCircle, Clock } from "lucide-react"
|
|
4
4
|
import { formatUnits, zeroAddress } from "viem"
|
|
5
5
|
import { TokenImage } from "./TokenImage.js"
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
useTokenBalances,
|
|
9
|
-
isNativeToken,
|
|
10
|
-
type TokenBalanceWithPrice,
|
|
11
|
-
} from "../../tokenBalances.js"
|
|
6
|
+
import { formatAmountDisplay, useTokenBalances } from "../../tokenBalances.js"
|
|
7
|
+
import type { Token } from "../../tokens.js"
|
|
12
8
|
import { useQueryClient } from "@tanstack/react-query"
|
|
13
9
|
|
|
14
10
|
export interface DepositTrackerProps {
|
|
@@ -51,11 +47,9 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
51
47
|
const normalizedTokenAddress = tokenAddress.toLowerCase()
|
|
52
48
|
const isNativeDeposit = normalizedTokenAddress === zeroAddress.toLowerCase()
|
|
53
49
|
|
|
54
|
-
return sortedTokens.find((token) => {
|
|
55
|
-
const tokenIsNative = isNativeToken
|
|
56
|
-
const tokenChainId =
|
|
57
|
-
? token.chainId
|
|
58
|
-
: token.contractInfo?.chainId
|
|
50
|
+
return sortedTokens.find((token: Token) => {
|
|
51
|
+
const tokenIsNative = token.isNativeToken ?? false
|
|
52
|
+
const tokenChainId = token.chainId
|
|
59
53
|
|
|
60
54
|
if (tokenChainId !== chainId) return false
|
|
61
55
|
|
|
@@ -74,17 +68,14 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
74
68
|
const allDeposits = useMemo(() => {
|
|
75
69
|
if (!sortedTokens || sortedTokens.length === 0) return []
|
|
76
70
|
|
|
77
|
-
return sortedTokens.filter((token) => {
|
|
78
|
-
const
|
|
79
|
-
const tokenChainId = tokenIsNative
|
|
80
|
-
? token.chainId
|
|
81
|
-
: token.contractInfo?.chainId
|
|
71
|
+
return sortedTokens.filter((token: Token) => {
|
|
72
|
+
const tokenChainId = token.chainId
|
|
82
73
|
|
|
83
74
|
// Only show tokens from the same chain with balance > 0
|
|
84
75
|
if (tokenChainId !== chainId) return false
|
|
85
76
|
|
|
86
77
|
try {
|
|
87
|
-
return BigInt(token.balance) > 0n
|
|
78
|
+
return BigInt(token.balance || "0") > 0n
|
|
88
79
|
} catch {
|
|
89
80
|
return false
|
|
90
81
|
}
|
|
@@ -103,12 +94,12 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
103
94
|
|
|
104
95
|
const normalizedTokenAddress = tokenAddress.toLowerCase()
|
|
105
96
|
const isNativeDeposit = normalizedTokenAddress === zeroAddress.toLowerCase()
|
|
106
|
-
const depositIsNative = isNativeToken
|
|
97
|
+
const depositIsNative = singleDeposit.isNativeToken ?? false
|
|
107
98
|
|
|
108
99
|
// Get contract address for ERC20 tokens
|
|
109
100
|
const depositTokenAddress = depositIsNative
|
|
110
101
|
? undefined
|
|
111
|
-
:
|
|
102
|
+
: singleDeposit.contractAddress?.toLowerCase()
|
|
112
103
|
|
|
113
104
|
// If both are native, don't show (it's the correct token)
|
|
114
105
|
if (isNativeDeposit && depositIsNative) return false
|
|
@@ -238,18 +229,13 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
238
229
|
Detected Deposits:
|
|
239
230
|
</p>
|
|
240
231
|
<div className="trails-border-radius-container border trails-border-primary">
|
|
241
|
-
{allDeposits.map((token, index) => {
|
|
242
|
-
const tokenIsNative = isNativeToken
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
: token.contractInfo?.decimals || 18
|
|
249
|
-
const balance = formatUnits(BigInt(token.balance), decimals)
|
|
250
|
-
const tokenChainId = tokenIsNative
|
|
251
|
-
? token.chainId
|
|
252
|
-
: token.contractInfo?.chainId
|
|
232
|
+
{allDeposits.map((token: Token, index) => {
|
|
233
|
+
const tokenIsNative = token.isNativeToken ?? false
|
|
234
|
+
const tokenChainId = token.chainId ?? chainId
|
|
235
|
+
const balance = formatUnits(
|
|
236
|
+
BigInt(token.balance || "0"),
|
|
237
|
+
token.decimals,
|
|
238
|
+
)
|
|
253
239
|
|
|
254
240
|
const tokenKey = tokenIsNative
|
|
255
241
|
? `native-${tokenChainId}`
|
|
@@ -260,8 +246,8 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
260
246
|
<div className="px-2 py-1.5 flex items-center gap-2">
|
|
261
247
|
<TokenImage
|
|
262
248
|
imageUrl={token.imageUrl}
|
|
263
|
-
symbol={symbol}
|
|
264
|
-
chainId={tokenChainId
|
|
249
|
+
symbol={token.symbol}
|
|
250
|
+
chainId={tokenChainId}
|
|
265
251
|
contractAddress={
|
|
266
252
|
tokenIsNative ? undefined : token.contractAddress
|
|
267
253
|
}
|
|
@@ -273,7 +259,7 @@ export const DepositTracker: React.FC<DepositTrackerProps> = ({
|
|
|
273
259
|
maxFractionDigits: 6,
|
|
274
260
|
minFractionDigits: 2,
|
|
275
261
|
})}{" "}
|
|
276
|
-
{symbol}
|
|
262
|
+
{token.symbol}
|
|
277
263
|
</span>
|
|
278
264
|
{token.balanceUsdFormatted && (
|
|
279
265
|
<span className="text-xs text-gray-500 dark:text-gray-400">
|
|
@@ -9,7 +9,7 @@ import { ScreenHeader } from "./ScreenHeader.js"
|
|
|
9
9
|
import { PoolDeposit } from "./PoolDeposit.js"
|
|
10
10
|
import { PoolWithdraw } from "./PoolWithdraw.js"
|
|
11
11
|
import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
12
|
-
import type {
|
|
12
|
+
import type { Token } from "../../tokens.js"
|
|
13
13
|
|
|
14
14
|
interface EarnProps {
|
|
15
15
|
onBack?: () => void
|
|
@@ -26,7 +26,7 @@ interface EarnProps {
|
|
|
26
26
|
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
27
27
|
quoteProvider?: string
|
|
28
28
|
fundMethod?: string
|
|
29
|
-
|
|
29
|
+
onNavigateToOnramp?: (
|
|
30
30
|
props: {
|
|
31
31
|
toTokenSymbol: string
|
|
32
32
|
toTokenAmount: string
|
|
@@ -34,10 +34,11 @@ interface EarnProps {
|
|
|
34
34
|
toRecipientAddress: string
|
|
35
35
|
},
|
|
36
36
|
quote?: PrepareSendQuote | null,
|
|
37
|
+
continueSend?: () => Promise<void>,
|
|
37
38
|
) => void
|
|
38
39
|
checkoutOnHandlers?: CheckoutOnHandlers
|
|
39
|
-
recentTokens?:
|
|
40
|
-
onRecentTokenSelect?: (token:
|
|
40
|
+
recentTokens?: Token[]
|
|
41
|
+
onRecentTokenSelect?: (token: Token) => void
|
|
41
42
|
onTrackToken?: (token: any) => void
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -55,7 +56,7 @@ export const Earn: React.FC<EarnProps> = ({
|
|
|
55
56
|
setWalletConfirmRetryHandler,
|
|
56
57
|
quoteProvider,
|
|
57
58
|
fundMethod,
|
|
58
|
-
|
|
59
|
+
onNavigateToOnramp,
|
|
59
60
|
checkoutOnHandlers,
|
|
60
61
|
recentTokens,
|
|
61
62
|
onRecentTokenSelect,
|
|
@@ -118,7 +119,7 @@ export const Earn: React.FC<EarnProps> = ({
|
|
|
118
119
|
setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
|
|
119
120
|
quoteProvider={quoteProvider}
|
|
120
121
|
fundMethod={fundMethod}
|
|
121
|
-
|
|
122
|
+
onNavigateToOnramp={onNavigateToOnramp}
|
|
122
123
|
checkoutOnHandlers={checkoutOnHandlers}
|
|
123
124
|
recentTokens={recentTokens}
|
|
124
125
|
onRecentTokenSelect={onRecentTokenSelect}
|
|
@@ -2,7 +2,7 @@ import { useMemo } from "react"
|
|
|
2
2
|
import type React from "react"
|
|
3
3
|
import { TokenImage } from "./TokenImage.js"
|
|
4
4
|
import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
|
|
5
|
-
import type { Token } from "
|
|
5
|
+
import type { Token } from "../../tokens.js"
|
|
6
6
|
import { normalizeAddress } from "../../utils.js"
|
|
7
7
|
import { parseUnits } from "viem"
|
|
8
8
|
import { Tooltip } from "./Tooltip.js"
|
|
@@ -45,7 +45,7 @@ export const isFeeOptionDisabled = (
|
|
|
45
45
|
const balanceInWei = BigInt(originTokenInfo.originTokenBalance ?? "0")
|
|
46
46
|
const originTokenAmountInWei = parseUnits(
|
|
47
47
|
originTokenInfo.originTokenAmount ?? "0",
|
|
48
|
-
originTokenInfo.originToken?.
|
|
48
|
+
originTokenInfo.originToken?.decimals ?? 18,
|
|
49
49
|
)
|
|
50
50
|
const feeAmountInWei = BigInt(option.amount ?? "0")
|
|
51
51
|
|
|
@@ -78,7 +78,7 @@ export const FeeOption: React.FC<FeeOptionProps> = ({
|
|
|
78
78
|
const button = (
|
|
79
79
|
<button
|
|
80
80
|
type="button"
|
|
81
|
-
className={`w-full flex items-center justify-between p-
|
|
81
|
+
className={`w-full flex items-center justify-between p-2 trails-border-radius-list-button transition-colors ${
|
|
82
82
|
isDisabled
|
|
83
83
|
? "border cursor-not-allowed opacity-50 bg-gray-100 dark:bg-gray-800 border-gray-300 dark:border-gray-600"
|
|
84
84
|
: !isClickable
|
|
@@ -95,7 +95,7 @@ export const FeeOption: React.FC<FeeOptionProps> = ({
|
|
|
95
95
|
imageUrl={option.tokenImageUrl}
|
|
96
96
|
symbol={option.tokenSymbol}
|
|
97
97
|
chainId={option.chainId || chainId}
|
|
98
|
-
size={
|
|
98
|
+
size={24}
|
|
99
99
|
/>
|
|
100
100
|
<div className="ml-2 text-left">
|
|
101
101
|
<div
|