Skip to content

Show the cycle's state and history on the admin panel - #221

Open
luchobonatti wants to merge 2 commits into
mainfrom
feat/193-cycle-surface
Open

luchobonatti wants to merge 2 commits into
mainfrom
feat/193-cycle-surface

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Part of #193

The Cycle card on /admin shows the vault's current state and history, read-only.

Changes

  • useCycleState reads the open epoch, the oracle price and config, the reserve figures, the custodian balance and the wind-down state
  • useEpochHistory reads every epoch from ledger entries; readEvents lists the last 7 days of vault and oracle events from RPC
  • CycleSurface renders each group as headline tiles plus a detail list, then the Epochs and Recent activity tables
  • MetricsStrip accepts any number of metrics and an optional note
  • readContract gains readEpochs and readEvents

Acceptance criteria

  • Manager, treasury and attester see the Cycle card with the current epoch, price, reserve and wind-down state
  • Every epoch is listed with its status, totals and settlement price
  • Recent events are listed newest first and labelled as the last 7 days
  • Unreadable reads degrade per section without hiding the rest

Test plan

Automated tests

npm run test — 691 passing.

Manual verification

  1. On a local network with two priced epochs, open /admin as the manager.
  2. The Cycle card shows epoch 3 open, share price with its freshness, free reserve and custodian balance, no wind-down.
  3. The Epochs table lists epochs 3, 2, 1; Recent activity lists the sealed, attested, priced, requested and claimed events.

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

@luchobonatti
luchobonatti requested a review from hpmaxi October 9, 2026 00:01
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Oct 9, 2026 4:05pm UTC

Request Review

@luchobonatti
luchobonatti added this pull request to stack #223 October 9, 2026 00:34
@luchobonatti luchobonatti self-assigned this Oct 9, 2026
@luchobonatti
luchobonatti marked this pull request as ready for review October 9, 2026 13:36
Copilot AI balanced review requested due to automatic review settings October 9, 2026 13:36
Base automatically changed from feat/219-signer-detection to main October 9, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a large feature spanning shared app-lib RPC primitives and UI, whose runtime correctness depends on live Soroban RPC responses and on-chain contractevent names that cannot be executed or fully verified in this environment, warranting human review.

0 open findings

What changed in this PR

This PR adds a read-only Cycle card to the /admin panel (part of #193), giving the manager, treasury and attester authorities visibility into the vault's current state and history without an off-chain indexer. It introduces new app-lib RPC primitives, two React Query hooks, pure transform functions, and a presentational surface, all backed by comprehensive unit tests.

Changes:

  • app-lib/readContract.ts gains readEpochs (batched epoch ledger-entry reads), readLedgerTime, and readEvents (paged getEvents over a ledger window), plus a factored-out latestLedgerSequence helper and named chunking constants.
  • New hooks useCycleState/useCycleEvents and useEpochHistory compose oracle, reserve, wind-down, epoch and event reads into discriminated-union read states that degrade per section; app/src/pages/cycle.ts maps those states to display groups, epoch rows and activity rows.
  • CycleSurface/CycleSection render the groups (headline tiles + detail rows), the Epochs table and the last-7-days activity table; MetricsStrip is generalized from a fixed 4-tuple with required note to a variable-length Metric[] with optional note, and the Cycle card spans full width.
File Description
app-lib/​readContract.ts Adds readEpochs, readLedgerTime, readEvents; extracts latestLedgerSequence; names ledger-entry/event paging constants
app-lib/​readContract.test.ts Tests for the three new reads (paging, chunking, archived/unreadable, decoding)
app/​src/​hooks/​useEpochHistory.ts (+test) Reads every epoch 1..current, classifies present/absent/unreadable, newest-first
app/​src/​hooks/​useCycleState.ts (+test) Composes oracle/reserve/wind-down/epoch/custodian reads and cycle events into read states
app/​src/​pages/​cycle.ts (+test) Pure transforms: formatters, cycle groups, epoch list, activity describers
app/​src/​components/​admin/​CycleSurface.tsx (+css/​test) Renders groups, Epochs table and Recent-activity table with loading/empty/unreadable states
app/​src/​components/​admin/​CycleSection.tsx Wires the hooks to CycleSurface
app/​src/​pages/​AdminPanel.tsx (+css/​test) Mounts CycleSection in a full-width Cycle card
app/​src/​components/​vault/​MetricsStrip.tsx (+css/​test) Generalizes to Metric[] with optional note; auto-flow grid layout

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch was successfully deployed

1 active deployment
Preview — 21e1063d Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants