2021-09-17 22:42:19 +00:00
|
|
|
import React, { useMemo } from "react";
|
|
|
|
import { Interface } from "@ethersproject/abi";
|
2021-07-14 19:30:28 +00:00
|
|
|
import ContentFrame from "../ContentFrame";
|
2021-09-17 22:42:19 +00:00
|
|
|
import LogEntry from "./LogEntry";
|
2021-07-14 19:30:28 +00:00
|
|
|
import { TransactionData } from "../types";
|
2021-09-17 22:42:19 +00:00
|
|
|
import { Metadata } from "../useSourcify";
|
2021-07-14 19:30:28 +00:00
|
|
|
|
|
|
|
type LogsProps = {
|
|
|
|
txData: TransactionData;
|
2021-09-17 22:42:19 +00:00
|
|
|
metadata: Metadata | null | undefined;
|
2021-07-14 19:30:28 +00:00
|
|
|
};
|
|
|
|
|
2021-09-17 22:42:19 +00:00
|
|
|
const Logs: React.FC<LogsProps> = ({ txData, metadata }) => {
|
|
|
|
const logDesc = useMemo(() => {
|
|
|
|
if (!metadata || !txData) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
const abi = metadata.output.abi;
|
|
|
|
const intf = new Interface(abi as any);
|
|
|
|
return txData.confirmedData?.logs.map((l) =>
|
2021-09-18 22:42:45 +00:00
|
|
|
l.address === txData.to
|
|
|
|
? intf.parseLog({
|
|
|
|
topics: l.topics,
|
|
|
|
data: l.data,
|
|
|
|
})
|
|
|
|
: undefined
|
2021-09-17 22:42:19 +00:00
|
|
|
);
|
|
|
|
}, [metadata, txData]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ContentFrame tabs>
|
|
|
|
<div className="text-sm py-4">Transaction Receipt Event Logs</div>
|
|
|
|
{txData.confirmedData &&
|
|
|
|
txData.confirmedData.logs.map((l, i) => (
|
2021-09-18 22:38:35 +00:00
|
|
|
<LogEntry key={i} txData={txData} log={l} logDesc={logDesc?.[i]} />
|
2021-09-17 22:42:19 +00:00
|
|
|
))}
|
|
|
|
</ContentFrame>
|
|
|
|
);
|
|
|
|
};
|
2021-07-14 19:30:28 +00:00
|
|
|
|
|
|
|
export default React.memo(Logs);
|