diff --git a/src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx b/src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx index 4cf58b0357b..fe439d99001 100644 --- a/src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx +++ b/src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx @@ -10,6 +10,7 @@ import { useActionCenterContext } from '@/components/Layout/Header/ActionCenter/ import { GenericTransactionNotification } from '@/components/Layout/Header/ActionCenter/components/Notifications/GenericTransactionNotification' import { getConfig } from '@/config' import { SECOND_CLASS_CHAINS } from '@/constants/chains' +import { getChainAdapterManager } from '@/context/PluginProvider/chainAdapterSingleton' import { getHyperEvmTransactionStatus } from '@/lib/utils/hyperevm' import { getMonadTransactionStatus } from '@/lib/utils/monad' import { getPlasmaTransactionStatus } from '@/lib/utils/plasma' @@ -20,6 +21,7 @@ import { selectPendingWalletSendActions } from '@/state/slices/actionSlice/selec import { ActionStatus } from '@/state/slices/actionSlice/types' import { portfolioApi } from '@/state/slices/portfolioSlice/portfolioSlice' import { selectTxs } from '@/state/slices/selectors' +import { txHistory } from '@/state/slices/txHistorySlice/txHistorySlice' import { serializeTxIndex } from '@/state/slices/txHistorySlice/utils' import { useAppDispatch, useAppSelector } from '@/state/store' @@ -158,6 +160,23 @@ export const useSendActionSubscriber = () => { } if (isConfirmed) { + // Parse and upsert Tx for second-class chains + try { + const adapter = getChainAdapterManager().get(chainId) + if (adapter?.parseTx) { + const parsedTx = await adapter.parseTx(txHash, accountAddress) + dispatch( + txHistory.actions.onMessage({ + message: parsedTx, + accountId, + }), + ) + } + } catch (error) { + // Silent fail - Tx just won't show in history + console.error('Failed to parse and upsert Tx:', error) + } + completeAction(action) const intervalId = pollingIntervalsRef.current.get(pollingKey) @@ -185,7 +204,7 @@ export const useSendActionSubscriber = () => { completeAction(action) }) - }, [txs, pendingSendActions, completeAction]) + }, [txs, pendingSendActions, completeAction, dispatch]) useEffect(() => { const intervals = pollingIntervalsRef.current diff --git a/src/hooks/useActionCenterSubscribers/useSwapActionSubscriber.tsx b/src/hooks/useActionCenterSubscribers/useSwapActionSubscriber.tsx index 91e732b3302..dfcca3b63e3 100644 --- a/src/hooks/useActionCenterSubscribers/useSwapActionSubscriber.tsx +++ b/src/hooks/useActionCenterSubscribers/useSwapActionSubscriber.tsx @@ -27,6 +27,7 @@ import { useActionCenterContext } from '@/components/Layout/Header/ActionCenter/ import { SwapNotification } from '@/components/Layout/Header/ActionCenter/components/Notifications/SwapNotification' import { getConfig } from '@/config' import { SECOND_CLASS_CHAINS } from '@/constants/chains' +import { getChainAdapterManager } from '@/context/PluginProvider/chainAdapterSingleton' import { queryClient } from '@/context/QueryClientProvider/queryClient' import { useFeatureFlag } from '@/hooks/useFeatureFlag/useFeatureFlag' import { getTxLink } from '@/lib/getTxLink' @@ -42,6 +43,7 @@ import { portfolioApi } from '@/state/slices/portfolioSlice/portfolioSlice' import { swapSlice } from '@/state/slices/swapSlice/swapSlice' import { selectConfirmedTradeExecution } from '@/state/slices/tradeQuoteSlice/selectors' import { tradeQuoteSlice } from '@/state/slices/tradeQuoteSlice/tradeQuoteSlice' +import { txHistory } from '@/state/slices/txHistorySlice/txHistorySlice' import { store, useAppDispatch, useAppSelector } from '@/state/store' const swapStatusToActionStatus = { @@ -273,11 +275,53 @@ export const useSwapActionSubscriber = () => { }), ) - const { getAccount } = portfolioApi.endpoints - + // Parse and upsert Txs for second-class chains const sellChainId = fromAccountId(swap.sellAccountId).chainId const isSellSecondClassChain = SECOND_CLASS_CHAINS.includes(sellChainId as KnownChainIds) + if (isSellSecondClassChain && swap.sellTxHash) { + try { + const adapter = getChainAdapterManager().get(sellChainId) + const { account: sellAddress } = fromAccountId(swap.sellAccountId) + if (adapter?.parseTx) { + const parsedSellTx = await adapter.parseTx(swap.sellTxHash, sellAddress) + dispatch( + txHistory.actions.onMessage({ + message: parsedSellTx, + accountId: swap.sellAccountId, + }), + ) + } + } catch (error) { + console.error('Failed to parse and upsert sell Tx:', error) + } + } + + if (buyTxHash && swap.buyAccountId) { + const buyChainId = fromAccountId(swap.buyAccountId).chainId + const isBuySecondClassChain = SECOND_CLASS_CHAINS.includes(buyChainId as KnownChainIds) + + if (isBuySecondClassChain) { + try { + const adapter = getChainAdapterManager().get(buyChainId) + const { account: buyAddress } = fromAccountId(swap.buyAccountId) + if (adapter?.parseTx) { + const parsedBuyTx = await adapter.parseTx(buyTxHash, buyAddress) + dispatch( + txHistory.actions.onMessage({ + message: parsedBuyTx, + accountId: swap.buyAccountId, + }), + ) + } + } catch (error) { + console.error('Failed to parse and upsert buy Tx:', error) + } + } + } + + const { getAccount } = portfolioApi.endpoints + if (isSellSecondClassChain) { dispatch( getAccount.initiate(