From 7102a746b9dc3f0e718d7d2657ad801bc89e43c5 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 05:58:28 -0300 Subject: [PATCH] Add Sourcify decorations to BlockTransactions page --- src/block/BlockTransactionResults.tsx | 20 +++++++++++++++++++- src/search/TransactionItem.tsx | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/block/BlockTransactionResults.tsx b/src/block/BlockTransactionResults.tsx index f9cfc27..969e4a4 100644 --- a/src/block/BlockTransactionResults.tsx +++ b/src/block/BlockTransactionResults.tsx @@ -9,9 +9,11 @@ import { useFeeToggler } from "../search/useFeeToggler"; import { RuntimeContext } from "../useRuntime"; import { SelectionContext, useSelection } from "../useSelection"; import { pageCollector, useResolvedAddresses } from "../useResolvedAddresses"; -import { ProcessedTransaction } from "../types"; +import { ChecksummedAddress, ProcessedTransaction } from "../types"; import { PAGE_SIZE } from "../params"; import { useMultipleETHUSDOracle } from "../usePriceOracle"; +import { useAppConfigContext } from "../useAppConfig"; +import { useMultipleMetadata } from "../useSourcify"; type BlockTransactionResultsProps = { blockTag: BlockTag; @@ -34,6 +36,21 @@ const BlockTransactionResults: React.FC = ({ const blockTags = useMemo(() => [blockTag], [blockTag]); const priceMap = useMultipleETHUSDOracle(provider, blockTags); + const addresses = useMemo((): ChecksummedAddress[] => { + if (!page) { + return []; + } + + return page.map((t) => t.to).filter((to): to is string => to !== undefined); + }, [page]); + const { sourcifySource } = useAppConfigContext(); + const metadatas = useMultipleMetadata( + undefined, + addresses, + provider?.network.chainId, + sourcifySource + ); + return (
@@ -63,6 +80,7 @@ const BlockTransactionResults: React.FC = ({ resolvedAddresses={resolvedAddresses} feeDisplay={feeDisplay} priceMap={priceMap} + metadatas={metadatas} /> ))}
diff --git a/src/search/TransactionItem.tsx b/src/search/TransactionItem.tsx index 3393d88..5c8740a 100644 --- a/src/search/TransactionItem.tsx +++ b/src/search/TransactionItem.tsx @@ -27,7 +27,7 @@ type TransactionItemProps = { selectedAddress?: string; feeDisplay: FeeDisplay; priceMap: Record; - metadatas?: + metadatas: | Record | undefined; };