import React, { useCallback } from "react"; import AddressDisp from "src/components/Misc/Disp/AddressDisp/AddressDisp"; import { hexAddrToZilAddr, isValidAddr } from "src/utils/Utils"; import { EventLogEntry, EventParam } from "@zilliqa-js/core/src/types"; import "./EventsTab.css"; interface IProps { events: EventLogEntry[]; } const EventsTab: React.FC = ({ events }) => { const highlightEventParams = useCallback( (params: EventParam[]): React.ReactNode => { if (params.length === 0) return null; return params .map((param, index) => ( {param.type} {param.vname} )) .reduce((acc: React.ReactNode | null, ele) => acc === null ? <>{[ele]} : <>{[acc, ", ", ele]} ); }, [] ); return ( <> {events .map((event: EventLogEntry, index: number) => ( <>
{event._eventname} {" ("} {highlightEventParams(event.params)} {")"}
{event.params.length > 0 && ( <> {event.params.map((param, index) => ( ))} )}
Variable Value
{param.vname} {typeof param.value === "object" ? (
                              {JSON.stringify(param.value, null, 2)}
                            
) : Array.isArray(param.value) ? ( param.value.toString() ) : isValidAddr(param.value.toString()) ? ( ) : ( param.value )}
)) .reduce( (acc: React.ReactNode | null, x) => acc === null ? ( x ) : ( <> {acc}
{x} ), null )} ); }; export default EventsTab;