8
8
} from '@suite-common/wallet-core' ;
9
9
import { WalletAccountTransactionWithRequiredRbfParams } from '@suite-common/wallet-types' ;
10
10
import { findChainedTransactions , getAccountKey , isPending } from '@suite-common/wallet-utils' ;
11
+ import { Modal } from '@trezor/components' ;
11
12
13
+ import { Translation } from 'src/components/suite' ;
12
14
import { useSelector } from 'src/hooks/suite' ;
13
15
import { Account , WalletAccountTransaction } from 'src/types/wallet' ;
14
16
import { getInstantStakeType } from 'src/utils/suite/ethereumStaking' ;
@@ -45,26 +47,27 @@ export const TxDetailModal = ({
45
47
const accountKey = getAccountKey ( descriptor , symbol , deviceState ) ;
46
48
const originalTx = useSelector ( state =>
47
49
selectTransactionByAccountKeyAndTxid ( state , accountKey , txid ) ,
48
- ) as WalletAccountTransaction ;
50
+ ) ;
49
51
50
52
// Filter out internal transfers that are instant staking transactions
51
- const filteredInternalTransfers = useMemo (
52
- ( ) =>
53
- originalTx . internalTransfers . filter ( t => {
54
- const stakeType = getInstantStakeType ( t , descriptor , symbol ) ;
55
-
56
- return stakeType !== 'stake' ;
57
- } ) ,
58
- [ originalTx . internalTransfers , descriptor , symbol ] ,
59
- ) ;
53
+ const filteredInternalTransfers = useMemo ( ( ) => {
54
+ if ( ! originalTx ) return [ ] ;
55
+
56
+ return originalTx . internalTransfers . filter ( t => {
57
+ const stakeType = getInstantStakeType ( t , descriptor , symbol ) ;
58
+
59
+ return stakeType !== 'stake' ;
60
+ } ) ;
61
+ } , [ originalTx , descriptor , symbol ] ) ;
62
+
63
+ const tx = useMemo ( ( ) => {
64
+ if ( ! originalTx ) return null ;
60
65
61
- const tx = useMemo (
62
- ( ) => ( {
66
+ return {
63
67
...originalTx ,
64
68
internalTransfers : filteredInternalTransfers ,
65
- } ) ,
66
- [ originalTx , filteredInternalTransfers ] ,
67
- ) ;
69
+ } ;
70
+ } , [ originalTx , filteredInternalTransfers ] ) ;
68
71
69
72
const account = useSelector ( state => selectAccountByKey ( state , accountKey ) ) as Account ;
70
73
const network = getNetwork ( account . symbol ) ;
@@ -76,6 +79,7 @@ export const TxDetailModal = ({
76
79
// TODO: replace this part will be refactored after blockbook implementation:
77
80
// https://github.com/trezor/blockbook/issues/555
78
81
const chainedTxs = useMemo ( ( ) => {
82
+ if ( ! tx ) return ;
79
83
if ( ! isPending ( tx ) ) return ;
80
84
81
85
return findChainedTransactions ( tx . descriptor , tx . txid , transactions ) ;
@@ -101,6 +105,14 @@ export const TxDetailModal = ({
101
105
setTab ( undefined ) ;
102
106
} ;
103
107
108
+ if ( tx === null ) {
109
+ return (
110
+ < Modal onCancel = { onCancel } heading = { < Translation id = "TR_TRANSACTION_DETAILS" /> } >
111
+ < Translation id = "TR_TRANSACTION_NOT_FOUND" />
112
+ </ Modal >
113
+ ) ;
114
+ }
115
+
104
116
const canReplaceTransaction =
105
117
hasRbfParams ( tx ) &&
106
118
networkFeatures ?. includes ( 'rbf' ) &&
0 commit comments