From 12303f83121c20fb5f7bbda34cd3de85d8242b80 Mon Sep 17 00:00:00 2001 From: port <108868128+portdeveloper@users.noreply.github.com> Date: Thu, 13 Jul 2023 19:24:39 +0300 Subject: [PATCH] [txHash].tsx page UI improvements (#414) --- .../hooks/scaffold-eth/useFetchBlocks.ts | 7 ++++++ .../blockexplorer/transaction/[txHash].tsx | 22 ++++++++++--------- .../nextjs/utils/scaffold-eth/decodeTxData.ts | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts b/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts index b61c7c8c8..c927d6a32 100644 --- a/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts +++ b/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts @@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react"; import { Block, Transaction, TransactionReceipt } from "viem"; import { usePublicClient } from "wagmi"; import { hardhat } from "wagmi/chains"; +import { decodeTransactionData } from "~~/utils/scaffold-eth"; const BLOCKS_PER_PAGE = 20; @@ -41,6 +42,10 @@ export const useFetchBlocks = () => { }); const fetchedBlocks = await Promise.all(blocksWithTransactions); + fetchedBlocks.forEach(block => { + block.transactions.forEach(tx => decodeTransactionData(tx as Transaction)); + }); + const txReceipts = await Promise.all( fetchedBlocks.flatMap(block => block.transactions.map(async tx => { @@ -74,6 +79,8 @@ export const useFetchBlocks = () => { if (currentPage === 0) { setBlocks(prevBlocks => [newBlock, ...prevBlocks.slice(0, BLOCKS_PER_PAGE - 1)]); + newBlock.transactions.forEach(tx => decodeTransactionData(tx as Transaction)); + const receipts = await Promise.all( newBlock.transactions.map(async tx => { try { diff --git a/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx b/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx index 168af64c0..de12dbff2 100644 --- a/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx +++ b/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx @@ -42,7 +42,7 @@ const TransactionPage: NextPage = () => { Back {transaction ? ( -
+

Transaction Details

{" "} @@ -94,14 +94,16 @@ const TransactionPage: NextPage = () => { Function called: @@ -115,7 +117,7 @@ const TransactionPage: NextPage = () => { Data:
- {functionCalled === "0x" ? ( - "This transaction did not call any function." - ) : ( - <> - {getFunctionDetails(transaction)} - {functionCalled} - - )} +
+ {functionCalled === "0x" ? ( + "This transaction did not call any function." + ) : ( + <> + {getFunctionDetails(transaction)} + {functionCalled} + + )} +
-