Skip to main content

Import

import { useSettlementEvents } from '@keystoneos/react';

Usage

function EventTimeline({ settlementId }) {
  const { events, isLoading } = useSettlementEvents(settlementId);

  if (isLoading) return <Spinner />;

  return (
    <ul>
      {events.map(event => (
        <li key={event.id}>
          <strong>{event.to_state}</strong>
          {event.from_state && <span> (from {event.from_state})</span>}
          <time>{new Date(event.created_at).toLocaleString()}</time>
          <span>{event.triggered_by}</span>
        </li>
      ))}
    </ul>
  );
}

Parameters

ParameterTypeRequiredDescription
settlementIdstring | nullYesThe settlement UUID. Pass null to skip fetching.

Return Type

interface UseSettlementEventsResult {
  events: SettlementEvent[];
  isLoading: boolean;
  error: string | null;
  refetch: () => Promise<void>;
}
PropertyTypeDescription
eventsSettlementEvent[]Array of events, ordered chronologically.
isLoadingbooleantrue during fetch.
errorstring | nullError message if fetch failed.
refetch() => Promise<void>Manually re-fetch events.

SettlementEvent

PropertyTypeDescription
idstringEvent UUID.
settlement_idstringThe settlement this event belongs to.
from_statestring | undefinedPrevious state (undefined for the initial event).
to_statestringThe state after this transition.
triggered_bystringWhat triggered the transition (e.g., "system:engine", "m2m:platform").
evidence_hashstring | undefinedSHA-256 hash of the transition evidence (on-chain).
created_atstringISO 8601 timestamp.