Skip to content

Commit

Permalink
Use decodeTransactionData in useFetchBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
portdeveloper committed Jul 13, 2023
1 parent 50ec5fe commit 020f0ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 020f0ae

Please sign in to comment.