From cab432aa139db6e6447b72347425dfbbe5441e56 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 04:45:58 -0300 Subject: [PATCH 1/7] Disable brotli --- nginx/conf.d/default.conf | 2 +- nginx/nginx.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf index b5d141b..4fdf9a1 100644 --- a/nginx/conf.d/default.conf +++ b/nginx/conf.d/default.conf @@ -118,7 +118,7 @@ server { index index.html; try_files $uri /index.html; - brotli_static on; + # brotli_static on; } #error_page 404 /404.html; diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 7364514..72d7924 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -4,7 +4,7 @@ worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; -load_module modules/ngx_http_brotli_static_module.so; +#load_module modules/ngx_http_brotli_static_module.so; events { worker_connections 1024; From 8d259dacc80bb07c2be3c32800ed0aaf8ab91318 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 04:46:43 -0300 Subject: [PATCH 2/7] Create a new type for checksummed addresses; small renames --- src/types.ts | 3 +++ src/url.ts | 13 +++++++------ src/useSourcify.ts | 46 +++++++++++++++++++++------------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/types.ts b/src/types.ts index 12763bb..66ccebe 100644 --- a/src/types.ts +++ b/src/types.ts @@ -67,6 +67,9 @@ export type ConfirmedTransactionData = { // The VOID... export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +// TODO: replace all occurrences of plain string +export type ChecksummedAddress = string; + export enum AddressContext { FROM, TO, diff --git a/src/url.ts b/src/url.ts index 647fc42..471c9d8 100644 --- a/src/url.ts +++ b/src/url.ts @@ -1,4 +1,5 @@ import { BlockTag } from "@ethersproject/abstract-provider"; +import { ChecksummedAddress } from "./types"; export const fourBytesURL = ( assetsURLPrefix: string, @@ -42,23 +43,23 @@ const resolveSourcifySource = (source: SourcifySource) => { }; export const sourcifyMetadata = ( - checksummedAddress: string, - networkId: number, + address: ChecksummedAddress, + chainId: number, source: SourcifySource ) => `${resolveSourcifySource( source - )}/contracts/full_match/${networkId}/${checksummedAddress}/metadata.json`; + )}/contracts/full_match/${chainId}/${address}/metadata.json`; export const sourcifySourceFile = ( - checksummedAddress: string, - networkId: number, + address: ChecksummedAddress, + chainId: number, filepath: string, source: SourcifySource ) => `${resolveSourcifySource( source - )}/contracts/full_match/${networkId}/${checksummedAddress}/sources/${filepath}`; + )}/contracts/full_match/${chainId}/${address}/sources/${filepath}`; export const openInRemixURL = (checksummedAddress: string, networkId: number) => `https://remix.ethereum.org/#call=source-verification//fetchAndSave//${checksummedAddress}//${networkId}`; diff --git a/src/useSourcify.ts b/src/useSourcify.ts index 0d6ea59..2b2f9c4 100644 --- a/src/useSourcify.ts +++ b/src/useSourcify.ts @@ -1,6 +1,6 @@ import { useState, useEffect, useMemo } from "react"; import { Interface } from "@ethersproject/abi"; -import { TransactionData } from "./types"; +import { ChecksummedAddress, TransactionData } from "./types"; import { sourcifyMetadata, SourcifySource, sourcifySourceFile } from "./url"; export type UserMethod = { @@ -65,24 +65,19 @@ export type Metadata = { }; }; -export const fetchSourcifyMetadata = async ( - checksummedAddress: string, +const fetchSourcifyMetadata = async ( + address: ChecksummedAddress, chainId: number, source: SourcifySource, abortController: AbortController ): Promise => { try { - const contractMetadataURL = sourcifyMetadata( - checksummedAddress, - chainId, - source - ); - const result = await fetch(contractMetadataURL, { + const metadataURL = sourcifyMetadata(address, chainId, source); + const result = await fetch(metadataURL, { signal: abortController.signal, }); if (result.ok) { - const _metadata = await result.json(); - return _metadata; + return await result.json(); } return null; @@ -93,14 +88,14 @@ export const fetchSourcifyMetadata = async ( }; export const useSourcify = ( - checksummedAddress: string | undefined, + address: ChecksummedAddress | undefined, chainId: number | undefined, source: SourcifySource ): Metadata | null | undefined => { const [rawMetadata, setRawMetadata] = useState(); useEffect(() => { - if (!checksummedAddress || chainId === undefined) { + if (!address || chainId === undefined) { return; } setRawMetadata(undefined); @@ -108,7 +103,7 @@ export const useSourcify = ( const abortController = new AbortController(); const fetchMetadata = async () => { const _metadata = await fetchSourcifyMetadata( - checksummedAddress, + address, chainId, source, abortController @@ -120,47 +115,48 @@ export const useSourcify = ( return () => { abortController.abort(); }; - }, [checksummedAddress, chainId, source]); + }, [address, chainId, source]); return rawMetadata; }; export const useMultipleMetadata = ( baseMetadatas: Record, - checksummedAddress: (string | undefined)[], + addresses: (ChecksummedAddress | undefined)[], chainId: number | undefined, source: SourcifySource -): Record => { +): Record => { const [rawMetadata, setRawMetadata] = useState< Record >({}); useEffect(() => { - if (!checksummedAddress || chainId === undefined) { + if (!addresses || chainId === undefined) { return; } setRawMetadata({}); const abortController = new AbortController(); - const fetchMetadata = async (addresses: string[]) => { + const fetchMetadata = async (dedupedAddresses: string[]) => { const promises: Promise[] = []; - for (const addr of addresses) { + for (const address of dedupedAddresses) { promises.push( - fetchSourcifyMetadata(addr, chainId, source, abortController) + fetchSourcifyMetadata(address, chainId, source, abortController) ); } const results = await Promise.all(promises); const metadatas: Record = { ...baseMetadatas }; for (let i = 0; i < results.length; i++) { - metadatas[addresses[i]] = results[i]; + metadatas[dedupedAddresses[i]] = results[i]; } setRawMetadata(metadatas); }; const deduped = new Set( - checksummedAddress.filter( - (a): a is string => a !== undefined && baseMetadatas[a] === undefined + addresses.filter( + (a): a is ChecksummedAddress => + a !== undefined && baseMetadatas[a] === undefined ) ); fetchMetadata(Array.from(deduped)); @@ -168,7 +164,7 @@ export const useMultipleMetadata = ( return () => { abortController.abort(); }; - }, [baseMetadatas, checksummedAddress, chainId, source]); + }, [baseMetadatas, addresses, chainId, source]); return rawMetadata; }; From fe8be2ee21bd1d823b4e4f166b777485b8bd16f9 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 05:00:27 -0300 Subject: [PATCH 3/7] Retrofit useMultipleMetadata into AddressTransactions page --- src/AddressTransactions.tsx | 20 +++++++++++++------- src/useSourcify.ts | 9 ++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index 19d41bb..69ebad2 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -31,7 +31,7 @@ import { useFeeToggler } from "./search/useFeeToggler"; import { SelectionContext, useSelection } from "./useSelection"; import { useMultipleETHUSDOracle } from "./usePriceOracle"; import { useAppConfigContext } from "./useAppConfig"; -import { useSourcify } from "./useSourcify"; +import { useMultipleMetadata } from "./useSourcify"; import SourcifyLogo from "./sourcify.svg"; type BlockParams = { @@ -181,12 +181,18 @@ const AddressTransactions: React.FC = () => { const [feeDisplay, feeDisplayToggler] = useFeeToggler(); const selectionCtx = useSelection(); + const addresses = useMemo(() => [checksummedAddress], [checksummedAddress]); const { sourcifySource } = useAppConfigContext(); - const rawMetadata = useSourcify( - checksummedAddress, + const metadatas = useMultipleMetadata( + undefined, + addresses, provider?.network.chainId, sourcifySource ); + const addressMetadata = + checksummedAddress !== undefined + ? metadatas[checksummedAddress] + : undefined; return ( @@ -224,18 +230,18 @@ const AddressTransactions: React.FC = () => { Contract - {rawMetadata === undefined ? ( + {addressMetadata === undefined ? ( - ) : rawMetadata === null ? ( + ) : addressMetadata === null ? ( @@ -316,7 +322,7 @@ const AddressTransactions: React.FC = () => { diff --git a/src/useSourcify.ts b/src/useSourcify.ts index 2b2f9c4..1911583 100644 --- a/src/useSourcify.ts +++ b/src/useSourcify.ts @@ -87,6 +87,7 @@ const fetchSourcifyMetadata = async ( } }; +// TODO: replace every occurrence with the multiple version one export const useSourcify = ( address: ChecksummedAddress | undefined, chainId: number | undefined, @@ -121,7 +122,7 @@ export const useSourcify = ( }; export const useMultipleMetadata = ( - baseMetadatas: Record, + baseMetadatas: Record | undefined, addresses: (ChecksummedAddress | undefined)[], chainId: number | undefined, source: SourcifySource @@ -146,7 +147,9 @@ export const useMultipleMetadata = ( } const results = await Promise.all(promises); - const metadatas: Record = { ...baseMetadatas }; + const metadatas: Record = baseMetadatas + ? { ...baseMetadatas } + : {}; for (let i = 0; i < results.length; i++) { metadatas[dedupedAddresses[i]] = results[i]; } @@ -156,7 +159,7 @@ export const useMultipleMetadata = ( const deduped = new Set( addresses.filter( (a): a is ChecksummedAddress => - a !== undefined && baseMetadatas[a] === undefined + a !== undefined && baseMetadatas?.[a] === undefined ) ); fetchMetadata(Array.from(deduped)); From dca72a13b47c39ce58bbb76aaa3f59eb408e0304 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 05:45:46 -0300 Subject: [PATCH 4/7] Add Sourcify decoration support to AddressTransactions page --- src/AddressTransactions.tsx | 17 ++++++++++++++++- src/components/DecoratedAddressLink.tsx | 15 +++++++++++++++ src/search/TransactionItem.tsx | 9 ++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index 69ebad2..a1013c8 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -32,6 +32,7 @@ import { SelectionContext, useSelection } from "./useSelection"; import { useMultipleETHUSDOracle } from "./usePriceOracle"; import { useAppConfigContext } from "./useAppConfig"; import { useMultipleMetadata } from "./useSourcify"; +import { ChecksummedAddress } from "./types"; import SourcifyLogo from "./sourcify.svg"; type BlockParams = { @@ -181,7 +182,20 @@ const AddressTransactions: React.FC = () => { const [feeDisplay, feeDisplayToggler] = useFeeToggler(); const selectionCtx = useSelection(); - const addresses = useMemo(() => [checksummedAddress], [checksummedAddress]); + const addresses = useMemo(() => { + const _addresses: ChecksummedAddress[] = []; + if (checksummedAddress) { + _addresses.push(checksummedAddress); + } + if (page) { + for (const t of page) { + if (t.to) { + _addresses.push(t.to); + } + } + } + return _addresses; + }, [checksummedAddress, page]); const { sourcifySource } = useAppConfigContext(); const metadatas = useMultipleMetadata( undefined, @@ -294,6 +308,7 @@ const AddressTransactions: React.FC = () => { selectedAddress={checksummedAddress} feeDisplay={feeDisplay} priceMap={priceMap} + metadatas={metadatas} /> ))}
diff --git a/src/components/DecoratedAddressLink.tsx b/src/components/DecoratedAddressLink.tsx index cadc77f..087da7f 100644 --- a/src/components/DecoratedAddressLink.tsx +++ b/src/components/DecoratedAddressLink.tsx @@ -8,6 +8,8 @@ import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins"; import AddressOrENSName from "./AddressOrENSName"; import { AddressContext, ZERO_ADDRESS } from "../types"; import { ResolvedAddresses } from "../api/address-resolver"; +import { Metadata } from "../useSourcify"; +import SourcifyLogo from "../sourcify.svg"; type DecoratedAddressLinkProps = { address: string; @@ -19,6 +21,7 @@ type DecoratedAddressLinkProps = { txFrom?: boolean; txTo?: boolean; resolvedAddresses?: ResolvedAddresses | undefined; + metadata?: Metadata | null | undefined; }; const DecoratedAddressLink: React.FC = ({ @@ -31,6 +34,7 @@ const DecoratedAddressLink: React.FC = ({ txFrom, txTo, resolvedAddresses, + metadata, }) => { const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS; const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS; @@ -70,6 +74,17 @@ const DecoratedAddressLink: React.FC = ({ )} + {metadata && ( + + Sourcify logo + + )} ; + metadatas?: + | Record + | undefined; }; const TransactionItem: React.FC = ({ @@ -34,6 +38,7 @@ const TransactionItem: React.FC = ({ selectedAddress, feeDisplay, priceMap, + metadatas, }) => { let direction: Direction | undefined; if (selectedAddress) { @@ -105,6 +110,7 @@ const TransactionItem: React.FC = ({ selectedAddress={selectedAddress} miner={tx.miner === tx.to} resolvedAddresses={resolvedAddresses} + metadata={metadatas?.[tx.to]} /> ) : ( @@ -114,6 +120,7 @@ const TransactionItem: React.FC = ({ selectedAddress={selectedAddress} creation resolvedAddresses={resolvedAddresses} + metadata={metadatas?.[tx.createdContractAddress!]} /> )} From 7102a746b9dc3f0e718d7d2657ad801bc89e43c5 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 05:58:28 -0300 Subject: [PATCH 5/7] 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; }; From 1794fff7f32be2ed0d12d7ddef50ef8fad3f3375 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 16:24:34 -0300 Subject: [PATCH 6/7] Add Sourcify decoration to addresses in tx details page --- src/components/TransactionAddress.tsx | 4 +++ src/transaction/Details.tsx | 35 ++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/components/TransactionAddress.tsx b/src/components/TransactionAddress.tsx index 1595ef0..28540dd 100644 --- a/src/components/TransactionAddress.tsx +++ b/src/components/TransactionAddress.tsx @@ -4,17 +4,20 @@ import DecoratedAddressLink from "./DecoratedAddressLink"; import { ResolvedAddresses } from "../api/address-resolver"; import { useSelectedTransaction } from "../useSelectedTransaction"; import { AddressContext } from "../types"; +import { Metadata } from "../useSourcify"; type TransactionAddressProps = { address: string; addressCtx?: AddressContext | undefined; resolvedAddresses: ResolvedAddresses | undefined; + metadata?: Metadata | null | undefined; }; const TransactionAddress: React.FC = ({ address, addressCtx, resolvedAddresses, + metadata, }) => { const txData = useSelectedTransaction(); // TODO: push down creation coloring logic into DecoratedAddressLink @@ -30,6 +33,7 @@ const TransactionAddress: React.FC = ({ txTo={address === txData?.to || creation} creation={creation} resolvedAddresses={resolvedAddresses} + metadata={metadata} /> ); diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index ef6a5fa..37226f7 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from "react"; +import React, { useContext, useMemo } from "react"; import { TransactionDescription, Fragment, @@ -26,15 +26,21 @@ import USDValue from "../components/USDValue"; import FormattedBalance from "../components/FormattedBalance"; import ETH2USDValue from "../components/ETH2USDValue"; import TokenTransferItem from "../TokenTransferItem"; -import { TransactionData, InternalOperation } from "../types"; +import { + TransactionData, + InternalOperation, + ChecksummedAddress, +} from "../types"; import PercentageBar from "../components/PercentageBar"; import ExternalLink from "../components/ExternalLink"; import RelativePosition from "../components/RelativePosition"; import PercentagePosition from "../components/PercentagePosition"; import InputDecoder from "./decoder/InputDecoder"; import { rawInputTo4Bytes, use4Bytes } from "../use4Bytes"; -import { DevDoc, UserDoc } from "../useSourcify"; +import { DevDoc, useMultipleMetadata, UserDoc } from "../useSourcify"; import { ResolvedAddresses } from "../api/address-resolver"; +import { RuntimeContext } from "../useRuntime"; +import { useAppConfigContext } from "../useAppConfig"; type DetailsProps = { txData: TransactionData; @@ -80,6 +86,25 @@ const Details: React.FC = ({ const userMethod = txDesc ? userDoc?.methods[txDesc.signature] : undefined; const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined; + const { provider } = useContext(RuntimeContext); + const addresses = useMemo(() => { + const _addresses: ChecksummedAddress[] = []; + if (txData.to) { + _addresses.push(txData.to); + } + if (txData.confirmedData?.createdContractAddress) { + _addresses.push(txData.confirmedData.createdContractAddress); + } + return _addresses; + }, [txData]); + const { sourcifySource } = useAppConfigContext(); + const metadatas = useMultipleMetadata( + undefined, + addresses, + provider?.network.chainId, + sourcifySource + ); + return ( @@ -155,6 +180,7 @@ const Details: React.FC = ({
@@ -167,6 +193,9 @@ const Details: React.FC = ({
From 0caf58ea29fcbaed539096d8928bb89eb9417def Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 10 Nov 2021 16:48:24 -0300 Subject: [PATCH 7/7] Add Sourcify decoration support to tx logs page --- src/search/TransactionItem.tsx | 8 +++----- src/transaction/LogEntry.tsx | 5 +++++ src/transaction/Logs.tsx | 9 ++++++--- src/useSourcify.ts | 3 +++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/search/TransactionItem.tsx b/src/search/TransactionItem.tsx index 5c8740a..446daf4 100644 --- a/src/search/TransactionItem.tsx +++ b/src/search/TransactionItem.tsx @@ -27,9 +27,7 @@ type TransactionItemProps = { selectedAddress?: string; feeDisplay: FeeDisplay; priceMap: Record; - metadatas: - | Record - | undefined; + metadatas: Record; }; const TransactionItem: React.FC = ({ @@ -110,7 +108,7 @@ const TransactionItem: React.FC = ({ selectedAddress={selectedAddress} miner={tx.miner === tx.to} resolvedAddresses={resolvedAddresses} - metadata={metadatas?.[tx.to]} + metadata={metadatas[tx.to]} /> ) : ( @@ -120,7 +118,7 @@ const TransactionItem: React.FC = ({ selectedAddress={selectedAddress} creation resolvedAddresses={resolvedAddresses} - metadata={metadatas?.[tx.createdContractAddress!]} + metadata={metadatas[tx.createdContractAddress!]} /> )} diff --git a/src/transaction/LogEntry.tsx b/src/transaction/LogEntry.tsx index de34971..109ec1e 100644 --- a/src/transaction/LogEntry.tsx +++ b/src/transaction/LogEntry.tsx @@ -9,17 +9,21 @@ import DecodedParamsTable from "./decoder/DecodedParamsTable"; import DecodedLogSignature from "./decoder/DecodedLogSignature"; import { useTopic0 } from "../useTopic0"; import { ResolvedAddresses } from "../api/address-resolver"; +import { ChecksummedAddress } from "../types"; +import { Metadata } from "../useSourcify"; type LogEntryProps = { log: Log; logDesc: LogDescription | null | undefined; resolvedAddresses: ResolvedAddresses | undefined; + metadatas: Record; }; const LogEntry: React.FC = ({ log, logDesc, resolvedAddresses, + metadatas, }) => { const rawTopic0 = log.topics[0]; const topic0 = useTopic0(rawTopic0); @@ -62,6 +66,7 @@ const LogEntry: React.FC = ({
diff --git a/src/transaction/Logs.tsx b/src/transaction/Logs.tsx index 85104f7..bbf0475 100644 --- a/src/transaction/Logs.tsx +++ b/src/transaction/Logs.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from "react"; +import React, { useContext, useMemo } from "react"; import { Interface } from "@ethersproject/abi"; import ContentFrame from "../ContentFrame"; import LogEntry from "./LogEntry"; @@ -6,6 +6,7 @@ import { TransactionData } from "../types"; import { useAppConfigContext } from "../useAppConfig"; import { Metadata, useMultipleMetadata } from "../useSourcify"; import { ResolvedAddresses } from "../api/address-resolver"; +import { RuntimeContext } from "../useRuntime"; type LogsProps = { txData: TransactionData; @@ -24,15 +25,16 @@ const Logs: React.FC = ({ txData, metadata, resolvedAddresses }) => { return md; }, [txData.to, metadata]); - const { sourcifySource } = useAppConfigContext(); const logAddresses = useMemo( () => txData.confirmedData?.logs.map((l) => l.address) ?? [], [txData] ); + const { provider } = useContext(RuntimeContext); + const { sourcifySource } = useAppConfigContext(); const metadatas = useMultipleMetadata( baseMetadatas, logAddresses, - 1, + provider?.network.chainId, sourcifySource ); const logDescs = useMemo(() => { @@ -72,6 +74,7 @@ const Logs: React.FC = ({ txData, metadata, resolvedAddresses }) => { log={l} logDesc={logDescs?.[i]} resolvedAddresses={resolvedAddresses} + metadatas={metadatas} /> ))} diff --git a/src/useSourcify.ts b/src/useSourcify.ts index 1911583..10f0c68 100644 --- a/src/useSourcify.ts +++ b/src/useSourcify.ts @@ -147,6 +147,9 @@ export const useMultipleMetadata = ( } const results = await Promise.all(promises); + if (abortController.signal.aborted) { + return; + } const metadatas: Record = baseMetadatas ? { ...baseMetadatas } : {};