import React, { useMemo } from "react"; import { Log } from "@ethersproject/abstract-provider"; import { Fragment, Interface, LogDescription } from "@ethersproject/abi"; import { Tab } from "@headlessui/react"; import AddressHighlighter from "../components/AddressHighlighter"; import DecoratedAddressLink from "../components/DecoratedAddressLink"; import Copy from "../components/Copy"; import ModeTab from "../components/ModeTab"; import DecodedParamsTable from "./decoder/DecodedParamsTable"; import DecodedLogSignature from "./decoder/DecodedLogSignature"; import { TransactionData } from "../types"; import { useTopic0 } from "../useTopic0"; type LogEntryProps = { txData: TransactionData; log: Log; logDesc: LogDescription | null | undefined; }; const LogEntry: React.FC = ({ txData, log, logDesc }) => { const rawTopic0 = log.topics[0]; const topic0 = useTopic0(rawTopic0); const topic0LogDesc = useMemo(() => { if (!topic0?.signature) { return undefined; } const sig = topic0.signature; const logFragment = Fragment.fromString(`event ${sig}`); const intf = new Interface([logFragment]); try { return intf.parseLog(log); } catch (err) { // TODO: try other indexed/non-indexed combinations? console.error(err); return undefined; } }, [topic0, log]); const resolvedLogDesc = logDesc ?? topic0LogDesc; return (
{log.logIndex}
Address
Parameters
Decoded Raw
{resolvedLogDesc === undefined ? (
Waiting for data...
) : resolvedLogDesc === null ? (
No decoded data
) : ( <>
)}
{log.topics.map((t, i) => (
{i === 0 && "Topics"}
{i} {t}
))}
Data