Skip to content

Commit

Permalink
show the original tx in case the searched hash is an sc call
Browse files Browse the repository at this point in the history
  • Loading branch information
radumojic committed Jul 17, 2024
1 parent 8797c7c commit bf6d519
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/pages/TransactionDetails/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,29 @@ export const TransactionDetails = () => {
const [dataReady, setDataReady] = useState<boolean | undefined>();

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);
}
Expand Down

0 comments on commit bf6d519

Please sign in to comment.