import React, { useMemo } from "react"; import { Log } from "@ethersproject/abstract-provider"; import { Fragment, Interface, LogDescription } from "@ethersproject/abi"; import { Tab } from "@headlessui/react"; import TransactionAddress from "../components/TransactionAddress"; import Copy from "../components/Copy"; import ModeTab from "../components/ModeTab"; import DecodedParamsTable from "./decoder/DecodedParamsTable"; import DecodedLogSignature from "./decoder/DecodedLogSignature"; import { useTopic0 } from "../useTopic0"; import { ResolvedAddresses } from "../api/address-resolver"; type LogEntryProps = { log: Log; logDesc: LogDescription | null | undefined; resolvedAddresses: ResolvedAddresses | undefined; }; const LogEntry: React.FC = ({ log, logDesc, resolvedAddresses, }) => { const rawTopic0 = log.topics[0]; const topic0 = useTopic0(rawTopic0); const topic0LogDesc = useMemo(() => { if (!topic0) { return topic0; } if (!topic0.signatures) { return undefined; } const sigs = topic0.signatures; for (const sig of sigs) { const logFragment = Fragment.fromString(`event ${sig}`); const intf = new Interface([logFragment]); try { return intf.parseLog(log); } catch (err) { // Ignore on purpose; try to match other sigs } } return undefined; }, [topic0, log]); const resolvedLogDesc = logDesc ?? topic0LogDesc; return (
{log.logIndex}
Address
Parameters
Decoded Raw
{resolvedLogDesc === undefined ? (
Waiting for data...
) : resolvedLogDesc === null ? (
Can't decode data
) : ( <>
)}
{log.topics.map((t, i) => (
{i === 0 && "Topics"}
{i} {t}
))}
Data