/** * Every firing of one kind of event. * * The feed behind a row of the event index: which block, which accounts, what * fields. Rendered through the same `Payload` as every other decoded value, so * a pallet added next year has a working page the first time it emits. */ import { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import type { AccountEvent } from '../api/generated/AccountEvent' import { RequestFailed, fetchEventFeed } from '../api/rest' import { height as fmtHeight, when } from '../lib/format' import { href } from '../lib/routes' import { Payload } from './Payload' export function EventPanel({ chain, pallet, variant, decimals, symbol, }: { chain: string pallet: string variant: string decimals: number symbol: string }) { const [rows, setRows] = useState(null) const [error, setError] = useState(null) const [before, setBefore] = useState(null) useEffect(() => { const controller = new AbortController() setRows(null) setError(null) fetchEventFeed(chain, pallet, variant, before ?? undefined, controller.signal) .then(setRows) .catch((e: unknown) => { if (controller.signal.aborted) return setError(e instanceof RequestFailed ? e.message : 'Could not reach the observer.') }) return () => controller.abort() }, [chain, pallet, variant, before]) const oldest = rows && rows.length > 0 ? rows[rows.length - 1]!.height : null return (
Event

{pallet}::{variant}

All events
{error &&

{error}

} {!error && rows === null &&

Reading the record…

} {rows !== null && rows.length === 0 && (

This event has not fired in the indexed range. The runtime declares it and the chain has not reached for it.

)} {rows !== null && rows.length > 0 && (
{rows.map((e) => ( ))}
Every firing of {pallet}::{variant}, newest first
Block Fields When
#{fmtHeight(e.height)} {when(e.at)}
)}
) }