From bf6d519440fb0e431503c50e4d2a0c6c54d09eff Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Wed, 17 Jul 2024 15:49:30 +0300 Subject: [PATCH] show the original tx in case the searched hash is an sc call --- .../TransactionDetails/TransactionDetails.tsx | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pages/TransactionDetails/TransactionDetails.tsx b/src/pages/TransactionDetails/TransactionDetails.tsx index fc0943c0a..401e4a3f1 100644 --- a/src/pages/TransactionDetails/TransactionDetails.tsx +++ b/src/pages/TransactionDetails/TransactionDetails.tsx @@ -24,25 +24,29 @@ export const TransactionDetails = () => { const [dataReady, setDataReady] = useState(); const fetchTransaction = async () => { - if (transactionId) { + if (transactionId && isHash(transactionId)) { const { data, success } = await getTransaction(transactionId); - if (!success && !data && isHash(transactionId)) { + let originalTxHash = data?.originalTxHash; + + if (!success && !data) { const { data: scData, success: scSuccess } = await getScResult( transactionId ); - if (scData?.originalTxHash && scData.hash && scSuccess) { - const options = { - pathname: networkRoute( - urlBuilder.transactionDetails(scData.originalTxHash) - ), - hash: scData.hash - }; - navigate(options, { replace: true }); - - return; + if (scSuccess) { + originalTxHash = scData?.originalTxHash; } } + if (originalTxHash) { + const options = { + pathname: networkRoute(urlBuilder.transactionDetails(originalTxHash)), + hash: transactionId + }; + navigate(options, { replace: true }); + + return; + } + setTransaction(data); setDataReady(success); }