Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -185,7 +204,7 @@ export const useSendActionSubscriber = () => {

completeAction(action)
})
}, [txs, pendingSendActions, completeAction])
}, [txs, pendingSendActions, completeAction, dispatch])

useEffect(() => {
const intervals = pollingIntervalsRef.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 = {
Expand Down Expand Up @@ -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(
Expand Down