Skip to content

fix(suite): handle missing transaction in TxDetailModal #19078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2025
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 @@ -8,7 +8,9 @@ import {
} from '@suite-common/wallet-core';
import { WalletAccountTransactionWithRequiredRbfParams } from '@suite-common/wallet-types';
import { findChainedTransactions, getAccountKey, isPending } from '@suite-common/wallet-utils';
import { Modal } from '@trezor/components';

import { Translation } from 'src/components/suite';
import { useSelector } from 'src/hooks/suite';
import { Account, WalletAccountTransaction } from 'src/types/wallet';
import { getInstantStakeType } from 'src/utils/suite/ethereumStaking';
Expand Down Expand Up @@ -45,26 +47,27 @@ export const TxDetailModal = ({
const accountKey = getAccountKey(descriptor, symbol, deviceState);
const originalTx = useSelector(state =>
selectTransactionByAccountKeyAndTxid(state, accountKey, txid),
) as WalletAccountTransaction;
);

// Filter out internal transfers that are instant staking transactions
const filteredInternalTransfers = useMemo(
() =>
originalTx.internalTransfers.filter(t => {
const stakeType = getInstantStakeType(t, descriptor, symbol);

return stakeType !== 'stake';
}),
[originalTx.internalTransfers, descriptor, symbol],
);
const filteredInternalTransfers = useMemo(() => {
if (!originalTx) return [];

return originalTx.internalTransfers.filter(t => {
const stakeType = getInstantStakeType(t, descriptor, symbol);

return stakeType !== 'stake';
});
}, [originalTx, descriptor, symbol]);

const tx = useMemo(() => {
if (!originalTx) return null;

const tx = useMemo(
() => ({
return {
...originalTx,
internalTransfers: filteredInternalTransfers,
}),
[originalTx, filteredInternalTransfers],
);
};
}, [originalTx, filteredInternalTransfers]);

const account = useSelector(state => selectAccountByKey(state, accountKey)) as Account;
const network = getNetwork(account.symbol);
Expand All @@ -76,6 +79,7 @@ export const TxDetailModal = ({
// TODO: replace this part will be refactored after blockbook implementation:
// https://github.com/trezor/blockbook/issues/555
const chainedTxs = useMemo(() => {
if (!tx) return;
if (!isPending(tx)) return;

return findChainedTransactions(tx.descriptor, tx.txid, transactions);
Expand All @@ -101,6 +105,14 @@ export const TxDetailModal = ({
setTab(undefined);
};

if (tx === null) {
return (
<Modal onCancel={onCancel} heading={<Translation id="TR_TRANSACTION_DETAILS" />}>
<Translation id="TR_TRANSACTION_NOT_FOUND" />
</Modal>
);
}

const canReplaceTransaction =
hasRbfParams(tx) &&
networkFeatures?.includes('rbf') &&
Expand Down
4 changes: 4 additions & 0 deletions packages/suite/src/support/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3351,6 +3351,10 @@ export default defineMessages({
defaultMessage: 'Details',
id: 'TR_TRANSACTION_DETAILS',
},
TR_TRANSACTION_NOT_FOUND: {
defaultMessage: 'Transaction not found. Please try again later.',
id: 'TR_TRANSACTION_NOT_FOUND',
},
TR_TOKEN_ID_COLON: {
defaultMessage: 'Token ID:',
id: 'TR_TOKEN_ID_COLON',
Expand Down
Loading