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
|
@@ -7,7 +7,8 @@ import { zeroAddress } from "viem"
|
|
|
7
7
|
import { useWidgetProps } from "./useWidgetProps.js"
|
|
8
8
|
import { useTargetAmount } from "./useTargetAmount.js"
|
|
9
9
|
import { useTokenBalances } from "../../tokenBalances.js"
|
|
10
|
-
import type {
|
|
10
|
+
import type { Token } from "../../tokens.js"
|
|
11
|
+
import { isNativeToken } from "../../utils.js"
|
|
11
12
|
import { useIndexerGatewayClient } from "../../indexerClient.js"
|
|
12
13
|
import { useSupportedTokens } from "../../tokens.js"
|
|
13
14
|
import { getChainInfo } from "../../chains.js"
|
|
@@ -42,67 +43,43 @@ const MINIMUM_BALANCE_USD_FOR_PRIORITIZATION = 1 // $1
|
|
|
42
43
|
* @returns defaultDestinationToken - Matching token on different chain (null if toToken/toChainId set)
|
|
43
44
|
* @returns isLoading - Whether token data is still loading
|
|
44
45
|
*/
|
|
45
|
-
export interface DefaultToken {
|
|
46
|
-
id: number
|
|
47
|
-
name: string
|
|
48
|
-
symbol: string
|
|
49
|
-
balance: string
|
|
50
|
-
imageUrl: string
|
|
51
|
-
chainId: number
|
|
52
|
-
contractAddress: string
|
|
53
|
-
balanceUsdFormatted: string
|
|
54
|
-
tokenPriceUsd: number
|
|
55
|
-
decimals: number // Top-level decimals for compatibility
|
|
56
|
-
contractInfo?: {
|
|
57
|
-
decimals: number
|
|
58
|
-
symbol: string
|
|
59
|
-
name: string
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
46
|
export interface UseDefaultTokenSelectionReturn {
|
|
64
|
-
defaultOriginToken:
|
|
65
|
-
defaultDestinationToken:
|
|
47
|
+
defaultOriginToken: Token | null
|
|
48
|
+
defaultDestinationToken: Token | null
|
|
66
49
|
isLoading: boolean
|
|
67
50
|
}
|
|
68
51
|
|
|
69
|
-
function getToken24hVolume(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return Number(
|
|
74
|
-
price.price24hVol?.value ||
|
|
75
|
-
price.volume24h ||
|
|
76
|
-
price.volume_24h ||
|
|
77
|
-
price.vol24h ||
|
|
78
|
-
price.dailyVolume ||
|
|
79
|
-
0,
|
|
80
|
-
)
|
|
52
|
+
function getToken24hVolume(_token: Token): number {
|
|
53
|
+
// Note: price24hVol is not in Token, so we return 0
|
|
54
|
+
// This can be added to Token later if needed
|
|
55
|
+
return 0
|
|
81
56
|
}
|
|
82
57
|
|
|
83
58
|
function tokenMatches(
|
|
84
|
-
token:
|
|
59
|
+
token: Token,
|
|
85
60
|
targetSymbolOrAddress: string,
|
|
86
61
|
targetChainId?: number,
|
|
87
62
|
): boolean {
|
|
88
|
-
const
|
|
89
|
-
|
|
63
|
+
const tokenChainId = token.chainId || 0
|
|
64
|
+
const tokenIsNative = token.isNativeToken ?? false
|
|
65
|
+
const contractAddress = token.contractAddress
|
|
66
|
+
const symbol = token.symbol
|
|
90
67
|
|
|
91
68
|
// Check chain match first
|
|
92
|
-
const chainMatches = !targetChainId ||
|
|
69
|
+
const chainMatches = !targetChainId || tokenChainId === targetChainId
|
|
93
70
|
if (!chainMatches) return false
|
|
94
71
|
|
|
95
72
|
// Check if target is an address (starts with 0x and is longer than 5 chars)
|
|
96
73
|
const isTargetAddress =
|
|
97
74
|
targetSymbolOrAddress.startsWith("0x") && targetSymbolOrAddress.length > 5
|
|
98
75
|
|
|
99
|
-
if (
|
|
100
|
-
const chainInfo = getChainInfo(
|
|
76
|
+
if (tokenIsNative) {
|
|
77
|
+
const chainInfo = getChainInfo(tokenChainId)
|
|
101
78
|
const nativeSymbol = chainInfo?.nativeCurrency.symbol || "ETH"
|
|
102
79
|
|
|
103
80
|
// For native tokens, check if target is zero address or matches symbol
|
|
104
81
|
if (isTargetAddress) {
|
|
105
|
-
return targetSymbolOrAddress
|
|
82
|
+
return isNativeToken(targetSymbolOrAddress)
|
|
106
83
|
}
|
|
107
84
|
|
|
108
85
|
return nativeSymbol.toUpperCase() === targetSymbolOrAddress.toUpperCase()
|
|
@@ -111,15 +88,11 @@ function tokenMatches(
|
|
|
111
88
|
// For non-native tokens, check both address and symbol
|
|
112
89
|
if (isTargetAddress) {
|
|
113
90
|
return (
|
|
114
|
-
|
|
115
|
-
targetSymbolOrAddress.toLowerCase()
|
|
91
|
+
contractAddress?.toLowerCase() === targetSymbolOrAddress.toLowerCase()
|
|
116
92
|
)
|
|
117
93
|
}
|
|
118
94
|
|
|
119
|
-
return (
|
|
120
|
-
token.contractInfo?.symbol.toUpperCase() ===
|
|
121
|
-
targetSymbolOrAddress.toUpperCase()
|
|
122
|
-
)
|
|
95
|
+
return symbol?.toUpperCase() === targetSymbolOrAddress.toUpperCase()
|
|
123
96
|
}
|
|
124
97
|
|
|
125
98
|
function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
@@ -150,72 +123,52 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
150
123
|
// Only compute destination defaults if toToken and toChainId are NOT set
|
|
151
124
|
const shouldComputeDestination = !toToken && !toChainId
|
|
152
125
|
|
|
153
|
-
// Helper to
|
|
154
|
-
const
|
|
155
|
-
token
|
|
156
|
-
|
|
157
|
-
const isNative =
|
|
158
|
-
!("contractAddress" in token) || token.contractAddress === zeroAddress
|
|
159
|
-
const chainInfo = getChainInfo(token.chainId)
|
|
126
|
+
// Helper to ensure Token has required properties set
|
|
127
|
+
const ensureToken = (token: Token): Token | null => {
|
|
128
|
+
const isNative = token.isNativeToken ?? false
|
|
129
|
+
const chainInfo = getChainInfo(token.chainId || 0)
|
|
160
130
|
|
|
161
131
|
if (isNative) {
|
|
162
|
-
// Native tokens -
|
|
163
|
-
const
|
|
164
|
-
const imageUrl = tokenWithInfo.logoURI || tokenWithInfo.imageUrl || ""
|
|
165
|
-
const decimals = 18
|
|
132
|
+
// Native tokens - ensure chain info is set
|
|
133
|
+
const decimals = chainInfo?.nativeCurrency.decimals ?? 18
|
|
166
134
|
|
|
167
135
|
return {
|
|
168
|
-
|
|
169
|
-
name: chainInfo?.nativeCurrency.name || "Native Token",
|
|
170
|
-
symbol: chainInfo?.nativeCurrency.symbol || "ETH",
|
|
171
|
-
balance: token.balance,
|
|
172
|
-
imageUrl,
|
|
173
|
-
chainId: token.chainId,
|
|
136
|
+
...token,
|
|
137
|
+
name: token.name || chainInfo?.nativeCurrency.name || "Native Token",
|
|
138
|
+
symbol: token.symbol || chainInfo?.nativeCurrency.symbol || "ETH",
|
|
139
|
+
balance: token.balance ?? "0",
|
|
140
|
+
imageUrl: token.imageUrl || "",
|
|
141
|
+
chainId: token.chainId ?? 0,
|
|
174
142
|
contractAddress: zeroAddress,
|
|
175
143
|
balanceUsdFormatted: token.balanceUsdFormatted ?? "0",
|
|
176
|
-
|
|
177
|
-
decimals,
|
|
178
|
-
|
|
179
|
-
decimals,
|
|
180
|
-
symbol: chainInfo?.nativeCurrency.symbol || "ETH",
|
|
181
|
-
name: chainInfo?.nativeCurrency.name || "Native Token",
|
|
182
|
-
},
|
|
144
|
+
priceUsd: token.priceUsd ?? 0,
|
|
145
|
+
decimals,
|
|
146
|
+
isNativeToken: true,
|
|
183
147
|
}
|
|
184
148
|
} else {
|
|
185
|
-
// Non-native tokens -
|
|
186
|
-
|
|
187
|
-
const imageUrl =
|
|
188
|
-
tokenWithInfo.contractInfo?.logoURI || tokenWithInfo.imageUrl || ""
|
|
189
|
-
const decimals = token.contractInfo?.decimals
|
|
190
|
-
if (!decimals) {
|
|
149
|
+
// Non-native tokens - ensure required properties are set
|
|
150
|
+
if (!token.decimals) {
|
|
191
151
|
logger.console.warn("[trails-sdk] Missing decimals for token:", {
|
|
192
|
-
|
|
152
|
+
symbol: token.symbol,
|
|
193
153
|
chainId: token.chainId,
|
|
194
154
|
})
|
|
195
155
|
return null // Return null instead of throwing
|
|
196
156
|
}
|
|
197
157
|
|
|
198
158
|
return {
|
|
199
|
-
|
|
200
|
-
name: token.
|
|
201
|
-
symbol: token.
|
|
202
|
-
balance: token.balance,
|
|
203
|
-
imageUrl,
|
|
204
|
-
chainId: token.chainId,
|
|
205
|
-
contractAddress: token.contractAddress,
|
|
159
|
+
...token,
|
|
160
|
+
name: token.name ?? "Unknown Token",
|
|
161
|
+
symbol: token.symbol ?? "???",
|
|
162
|
+
balance: token.balance ?? "0",
|
|
163
|
+
imageUrl: token.imageUrl || "",
|
|
164
|
+
chainId: token.chainId ?? 0,
|
|
206
165
|
balanceUsdFormatted: token.balanceUsdFormatted ?? "0",
|
|
207
|
-
|
|
208
|
-
decimals, // Top-level decimals
|
|
209
|
-
contractInfo: {
|
|
210
|
-
decimals,
|
|
211
|
-
symbol: token.contractInfo?.symbol ?? "???",
|
|
212
|
-
name: token.contractInfo?.name ?? "Unknown Token",
|
|
213
|
-
},
|
|
166
|
+
priceUsd: token.priceUsd ?? 0,
|
|
214
167
|
}
|
|
215
168
|
}
|
|
216
169
|
}
|
|
217
170
|
|
|
218
|
-
// Filter tokens with balance > 0
|
|
171
|
+
// Filter tokens with balance > 0 (sortedTokens is already Token[])
|
|
219
172
|
const tokensWithBalance = sortedTokens.filter((token) => {
|
|
220
173
|
const balanceUsd = token.balanceUsd ?? 0
|
|
221
174
|
return balanceUsd > 0
|
|
@@ -233,7 +186,7 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
233
186
|
|
|
234
187
|
// Helper to sort tokens by balance USD and volume
|
|
235
188
|
const sortTokensByBalanceAndVolume = (
|
|
236
|
-
tokens:
|
|
189
|
+
tokens: Token[],
|
|
237
190
|
targetAmount?: number,
|
|
238
191
|
) => {
|
|
239
192
|
const sortedTokens = [...tokens].sort((a, b) => {
|
|
@@ -256,16 +209,14 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
256
209
|
const effectiveTargetAmount =
|
|
257
210
|
targetAmount ?? MINIMUM_BALANCE_USD_FOR_PRIORITIZATION
|
|
258
211
|
|
|
259
|
-
const prioritizedTokens:
|
|
260
|
-
const remainingTokens:
|
|
212
|
+
const prioritizedTokens: Token[] = []
|
|
213
|
+
const remainingTokens: Token[] = []
|
|
261
214
|
|
|
262
215
|
// Separate tokens into prioritized and remaining
|
|
263
216
|
for (const token of sortedTokens) {
|
|
264
217
|
const balanceUsd = token.balanceUsd ?? 0
|
|
265
|
-
const isNative =
|
|
266
|
-
|
|
267
|
-
const isUSDC =
|
|
268
|
-
!isNative && token.contractInfo?.symbol?.toUpperCase() === "USDC"
|
|
218
|
+
const isNative = token.isNativeToken ?? false
|
|
219
|
+
const isUSDC = !isNative && token.symbol?.toUpperCase() === "USDC"
|
|
269
220
|
|
|
270
221
|
if ((isUSDC || isNative) && balanceUsd >= effectiveTargetAmount) {
|
|
271
222
|
prioritizedTokens.push(token)
|
|
@@ -276,14 +227,10 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
276
227
|
|
|
277
228
|
// Sort prioritized tokens: USDC first, then native tokens
|
|
278
229
|
prioritizedTokens.sort((a, b) => {
|
|
279
|
-
const aIsNative =
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
const aIsUSDC =
|
|
284
|
-
!aIsNative && a.contractInfo?.symbol?.toUpperCase() === "USDC"
|
|
285
|
-
const bIsUSDC =
|
|
286
|
-
!bIsNative && b.contractInfo?.symbol?.toUpperCase() === "USDC"
|
|
230
|
+
const aIsNative = a.isNativeToken ?? false
|
|
231
|
+
const bIsNative = b.isNativeToken ?? false
|
|
232
|
+
const aIsUSDC = !aIsNative && a.symbol?.toUpperCase() === "USDC"
|
|
233
|
+
const bIsUSDC = !bIsNative && b.symbol?.toUpperCase() === "USDC"
|
|
287
234
|
|
|
288
235
|
// USDC comes first
|
|
289
236
|
if (aIsUSDC && !bIsUSDC) return -1
|
|
@@ -304,7 +251,7 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
304
251
|
}
|
|
305
252
|
|
|
306
253
|
// Find the best origin token using intelligent selection
|
|
307
|
-
let bestOriginToken:
|
|
254
|
+
let bestOriginToken: Token | null = null
|
|
308
255
|
|
|
309
256
|
// When toToken and toChainId are specified (user wants specific destination)
|
|
310
257
|
if (toToken && toChainId) {
|
|
@@ -412,7 +359,7 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
412
359
|
}
|
|
413
360
|
}
|
|
414
361
|
|
|
415
|
-
const originToken =
|
|
362
|
+
const originToken = ensureToken(bestOriginToken)
|
|
416
363
|
|
|
417
364
|
if (!originToken) {
|
|
418
365
|
return {
|
|
@@ -422,7 +369,7 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
422
369
|
}
|
|
423
370
|
|
|
424
371
|
// Compute destination token only when toToken and toChainId are not provided
|
|
425
|
-
let destinationToken:
|
|
372
|
+
let destinationToken: Token | null = null
|
|
426
373
|
|
|
427
374
|
if (shouldComputeDestination) {
|
|
428
375
|
// Determine destination chain: Base if origin is not Base, Arbitrum if origin is Base
|
|
@@ -431,22 +378,22 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
431
378
|
|
|
432
379
|
// Find USDC on destination chain first
|
|
433
380
|
const usdcOnDestChain = supportedTokens.find(
|
|
434
|
-
(token:
|
|
381
|
+
(token: Token) =>
|
|
435
382
|
token.chainId === defaultDestChainId && token.symbol === "USDC",
|
|
436
383
|
)
|
|
437
384
|
|
|
438
|
-
let destToken:
|
|
385
|
+
let destToken: Token | null = null
|
|
439
386
|
|
|
440
387
|
if (usdcOnDestChain) {
|
|
441
388
|
destToken = usdcOnDestChain
|
|
442
389
|
} else {
|
|
443
390
|
// Fallback: Find matching token on destination chain
|
|
444
391
|
const destChainTokens = supportedTokens.filter(
|
|
445
|
-
(token:
|
|
392
|
+
(token: Token) => token.chainId === defaultDestChainId,
|
|
446
393
|
)
|
|
447
394
|
|
|
448
395
|
// Try to find same symbol on destination chain first
|
|
449
|
-
const sameSymbolOnDestChain = destChainTokens.find((token:
|
|
396
|
+
const sameSymbolOnDestChain = destChainTokens.find((token: Token) => {
|
|
450
397
|
return token.symbol.toUpperCase() === originToken.symbol.toUpperCase()
|
|
451
398
|
})
|
|
452
399
|
|
|
@@ -455,40 +402,49 @@ function useDefaultTokenSelectionInternal(): UseDefaultTokenSelectionReturn {
|
|
|
455
402
|
} else {
|
|
456
403
|
// Fallback: ETH on destination chain > first available token on destination chain
|
|
457
404
|
destToken =
|
|
458
|
-
destChainTokens.find((token:
|
|
459
|
-
destChainTokens[0]
|
|
405
|
+
destChainTokens.find((token: Token) => token.symbol === "ETH") ||
|
|
406
|
+
destChainTokens[0] ||
|
|
407
|
+
null
|
|
460
408
|
}
|
|
461
409
|
}
|
|
462
410
|
|
|
463
|
-
|
|
464
|
-
if (!decimals) {
|
|
465
|
-
logger.console.warn(
|
|
466
|
-
"[trails-sdk] Missing decimals for destination token, skipping:",
|
|
467
|
-
{
|
|
468
|
-
token: destToken,
|
|
469
|
-
},
|
|
470
|
-
)
|
|
411
|
+
if (!destToken) {
|
|
471
412
|
destinationToken = null
|
|
472
413
|
} else {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
414
|
+
const decimals = destToken.decimals
|
|
415
|
+
if (!decimals) {
|
|
416
|
+
logger.console.warn(
|
|
417
|
+
"[trails-sdk] Missing decimals for destination token, skipping:",
|
|
418
|
+
{
|
|
419
|
+
token: destToken,
|
|
420
|
+
},
|
|
421
|
+
)
|
|
422
|
+
destinationToken = null
|
|
423
|
+
} else {
|
|
424
|
+
// Try to find this token in user's balances to get the actual balance
|
|
425
|
+
const matchingUserToken = sortedTokens.find((t) => {
|
|
426
|
+
if (t.chainId !== destToken.chainId) return false
|
|
427
|
+
|
|
428
|
+
const isDestNative = destToken.isNativeToken ?? false
|
|
429
|
+
const isUserNative = t.isNativeToken ?? false
|
|
430
|
+
|
|
431
|
+
if (isDestNative && isUserNative) return true
|
|
432
|
+
if (isDestNative || isUserNative) return false
|
|
433
|
+
|
|
434
|
+
return (
|
|
435
|
+
t.contractAddress?.toLowerCase() ===
|
|
436
|
+
destToken.contractAddress?.toLowerCase()
|
|
437
|
+
)
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
destinationToken = {
|
|
441
|
+
...destToken,
|
|
442
|
+
balance: matchingUserToken?.balance ?? "0",
|
|
443
|
+
balanceUsdFormatted: matchingUserToken?.balanceUsdFormatted ?? "0",
|
|
444
|
+
priceUsd: matchingUserToken?.priceUsd ?? 0,
|
|
445
|
+
decimals,
|
|
446
|
+
}
|
|
447
|
+
}
|
|
492
448
|
}
|
|
493
449
|
}
|
|
494
450
|
|
|
@@ -6,20 +6,7 @@ import React, {
|
|
|
6
6
|
} from "react"
|
|
7
7
|
|
|
8
8
|
// Define the Token interface (matching the existing one in widget.tsx)
|
|
9
|
-
|
|
10
|
-
id: number
|
|
11
|
-
name: string
|
|
12
|
-
symbol: string
|
|
13
|
-
balance: string
|
|
14
|
-
imageUrl: string
|
|
15
|
-
chainId: number
|
|
16
|
-
contractAddress: string
|
|
17
|
-
contractInfo?: {
|
|
18
|
-
decimals: number
|
|
19
|
-
symbol: string
|
|
20
|
-
name: string
|
|
21
|
-
}
|
|
22
|
-
}
|
|
9
|
+
import type { Token } from "../../tokens.js"
|
|
23
10
|
|
|
24
11
|
interface DestinationSelectedTokenContextType {
|
|
25
12
|
selectedToken: Token | null
|
|
@@ -27,7 +27,7 @@ export const EarnPoolProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export function useEarnPool(): EarnPoolContextType {
|
|
31
31
|
const context = useContext(EarnPoolContext)
|
|
32
32
|
if (context === undefined) {
|
|
33
33
|
throw new Error("useEarnPool must be used within an EarnPoolProvider")
|
|
@@ -10,9 +10,9 @@ import { logger } from "../../logger.js"
|
|
|
10
10
|
import { useTrails } from "../providers/TrailsProvider.js"
|
|
11
11
|
import { commonTokenImages } from "../../tokens.js"
|
|
12
12
|
import { getTrailsClient } from "../../trailsClient.js"
|
|
13
|
-
import type { IntentSummary } from "@
|
|
13
|
+
import type { IntentSummary } from "@0xtrails/api"
|
|
14
14
|
import {
|
|
15
|
-
|
|
15
|
+
decodeTokenSweeperEvents,
|
|
16
16
|
decodeGuestModuleEvents,
|
|
17
17
|
} from "../../decoders.js"
|
|
18
18
|
import { getChainRpcClient } from "../../chains.js"
|
|
@@ -110,6 +110,7 @@ async function getTokenInfoForTransaction(
|
|
|
110
110
|
tokenAddress: string,
|
|
111
111
|
chainId: number,
|
|
112
112
|
supportedTokens: Awaited<ReturnType<typeof getSupportedTokens>>,
|
|
113
|
+
trailsConfig: ReturnType<typeof useTrails>,
|
|
113
114
|
): Promise<
|
|
114
115
|
| {
|
|
115
116
|
symbol: string
|
|
@@ -132,8 +133,8 @@ async function getTokenInfoForTransaction(
|
|
|
132
133
|
symbol: nativeToken.symbol,
|
|
133
134
|
name: nativeToken.name,
|
|
134
135
|
decimals: nativeToken.decimals,
|
|
135
|
-
imageUrl: nativeToken.imageUrl,
|
|
136
|
-
chainId: nativeToken.chainId,
|
|
136
|
+
imageUrl: nativeToken.imageUrl || "",
|
|
137
|
+
chainId: nativeToken.chainId || chainId,
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -159,21 +160,24 @@ async function getTokenInfoForTransaction(
|
|
|
159
160
|
symbol: supportedToken.symbol,
|
|
160
161
|
name: supportedToken.name,
|
|
161
162
|
decimals: supportedToken.decimals,
|
|
162
|
-
imageUrl: supportedToken.imageUrl,
|
|
163
|
-
chainId: supportedToken.chainId,
|
|
163
|
+
imageUrl: supportedToken.imageUrl || "",
|
|
164
|
+
chainId: supportedToken.chainId || chainId,
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
// Fallback to on-chain lookup
|
|
168
169
|
try {
|
|
169
|
-
const tokenInfo = await getTokenInfo(chainId, tokenAddress
|
|
170
|
+
const tokenInfo = await getTokenInfo(chainId, tokenAddress, {
|
|
171
|
+
trailsApiKey: trailsConfig.trailsApiKey,
|
|
172
|
+
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
173
|
+
})
|
|
170
174
|
if (tokenInfo) {
|
|
171
175
|
return {
|
|
172
176
|
symbol: tokenInfo.symbol,
|
|
173
177
|
name: tokenInfo.name,
|
|
174
178
|
decimals: tokenInfo.decimals,
|
|
175
|
-
imageUrl: tokenInfo.imageUrl,
|
|
176
|
-
chainId: tokenInfo.chainId,
|
|
179
|
+
imageUrl: tokenInfo.imageUrl || "",
|
|
180
|
+
chainId: tokenInfo.chainId || chainId,
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
} catch (error) {
|
|
@@ -450,7 +454,7 @@ async function decodeTransactionEvents(
|
|
|
450
454
|
})
|
|
451
455
|
|
|
452
456
|
// Decode Trails Token Sweeper events (refunds)
|
|
453
|
-
const sweeperEvents =
|
|
457
|
+
const sweeperEvents = decodeTokenSweeperEvents(receipt)
|
|
454
458
|
const hasRefund = sweeperEvents.some(
|
|
455
459
|
(event) => event.type === "Refund" || event.type === "RefundAndSweep",
|
|
456
460
|
)
|
|
@@ -586,6 +590,7 @@ async function enrichTransaction(
|
|
|
586
590
|
transaction.originTokenAddress,
|
|
587
591
|
transaction.originChainId,
|
|
588
592
|
supportedTokens,
|
|
593
|
+
trailsConfig,
|
|
589
594
|
)
|
|
590
595
|
: undefined
|
|
591
596
|
|
|
@@ -595,6 +600,7 @@ async function enrichTransaction(
|
|
|
595
600
|
transaction.destinationTokenAddress,
|
|
596
601
|
transaction.destinationChainId,
|
|
597
602
|
supportedTokens,
|
|
603
|
+
trailsConfig,
|
|
598
604
|
)
|
|
599
605
|
: undefined
|
|
600
606
|
|
|
@@ -797,7 +803,10 @@ export function useIntentTransactionHistory({
|
|
|
797
803
|
apiResult.intents || []
|
|
798
804
|
).map(mapIntentSummaryToTransaction)
|
|
799
805
|
|
|
800
|
-
const supportedTokens = await getSupportedTokens(
|
|
806
|
+
const supportedTokens = await getSupportedTokens({
|
|
807
|
+
trailsApiKey: trailsConfig.trailsApiKey,
|
|
808
|
+
trailsApiUrl: trailsConfig.trailsApiUrl,
|
|
809
|
+
})
|
|
801
810
|
|
|
802
811
|
const enrichedTransactions = await Promise.all(
|
|
803
812
|
mappedTransactions.map(async (transaction) =>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState, useEffect } from "react"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to detect if the browser is on iOS or Android mobile
|
|
5
|
+
*/
|
|
6
|
+
export function useIsMobile(): boolean {
|
|
7
|
+
const [isMobile, setIsMobile] = useState(false)
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const checkMobile = () => {
|
|
11
|
+
if (typeof window === "undefined") {
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const userAgent =
|
|
16
|
+
window.navigator.userAgent ||
|
|
17
|
+
window.navigator.vendor ||
|
|
18
|
+
(window as unknown as { opera?: string }).opera
|
|
19
|
+
|
|
20
|
+
if (!userAgent) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Check for iOS
|
|
25
|
+
const isIOS =
|
|
26
|
+
/iPad|iPhone|iPod/.test(userAgent) &&
|
|
27
|
+
!(window as unknown as { MSStream?: unknown }).MSStream
|
|
28
|
+
|
|
29
|
+
// Check for Android
|
|
30
|
+
const isAndroid = /android/i.test(userAgent)
|
|
31
|
+
|
|
32
|
+
// Also check screen width as a fallback
|
|
33
|
+
const isSmallScreen = window.innerWidth <= 768
|
|
34
|
+
|
|
35
|
+
return isIOS || isAndroid || isSmallScreen
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setIsMobile(checkMobile())
|
|
39
|
+
|
|
40
|
+
// Listen for resize events to handle orientation changes
|
|
41
|
+
const handleResize = () => {
|
|
42
|
+
setIsMobile(checkMobile())
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
window.addEventListener("resize", handleResize)
|
|
46
|
+
return () => window.removeEventListener("resize", handleResize)
|
|
47
|
+
}, [])
|
|
48
|
+
|
|
49
|
+
return isMobile
|
|
50
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext } from "react"
|
|
2
|
-
|
|
3
|
-
export type Mode = "pay" | "fund" | "earn" | "swap" | "receive"
|
|
2
|
+
import type { Mode } from "../../mode.js"
|
|
4
3
|
|
|
5
4
|
export interface ModeConfig {
|
|
6
5
|
mode?: Mode
|
|
@@ -10,7 +9,7 @@ const ModeContext = createContext<ModeConfig | null>(null)
|
|
|
10
9
|
|
|
11
10
|
export const ModeProvider = ModeContext.Provider
|
|
12
11
|
|
|
13
|
-
export
|
|
12
|
+
export function useMode(): ModeConfig {
|
|
14
13
|
const context = useContext(ModeContext)
|
|
15
14
|
return context || {}
|
|
16
15
|
}
|
|
@@ -6,20 +6,7 @@ import React, {
|
|
|
6
6
|
} from "react"
|
|
7
7
|
|
|
8
8
|
// Define the Token interface (matching the existing one in widget.tsx)
|
|
9
|
-
|
|
10
|
-
id: number
|
|
11
|
-
name: string
|
|
12
|
-
symbol: string
|
|
13
|
-
balance: string
|
|
14
|
-
imageUrl: string
|
|
15
|
-
chainId: number
|
|
16
|
-
contractAddress: string
|
|
17
|
-
contractInfo?: {
|
|
18
|
-
decimals: number
|
|
19
|
-
symbol: string
|
|
20
|
-
name: string
|
|
21
|
-
}
|
|
22
|
-
}
|
|
9
|
+
import type { Token } from "../../tokens.js"
|
|
23
10
|
|
|
24
11
|
interface OriginSelectedTokenContextType {
|
|
25
12
|
selectedToken: Token | null
|
|
@@ -58,7 +45,7 @@ export const OriginSelectedTokenProvider: React.FC<
|
|
|
58
45
|
)
|
|
59
46
|
}
|
|
60
47
|
|
|
61
|
-
export
|
|
48
|
+
export function useOriginSelectedToken(): OriginSelectedTokenContextType {
|
|
62
49
|
const context = useContext(OriginSelectedTokenContext)
|
|
63
50
|
|
|
64
51
|
if (context === undefined) {
|