Repository navigation
Show the cycle's state and history on the admin panel - #221
luchobonatti wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
426d6f0 to
e6a5fa3
Compare
There was a problem hiding this comment.
🔵 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.tsgainsreadEpochs(batched epoch ledger-entry reads),readLedgerTime, andreadEvents(pagedgetEventsover a ledger window), plus a factored-outlatestLedgerSequencehelper and named chunking constants.- New hooks
useCycleState/useCycleEventsanduseEpochHistorycompose oracle, reserve, wind-down, epoch and event reads into discriminated-union read states that degrade per section;app/src/pages/cycle.tsmaps those states to display groups, epoch rows and activity rows. CycleSurface/CycleSectionrender the groups (headline tiles + detail rows), the Epochs table and the last-7-days activity table;MetricsStripis generalized from a fixed 4-tuple with required note to a variable-lengthMetric[]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.
Summary
Part of #193
The Cycle card on
/adminshows the vault's current state and history, read-only.Changes
useCycleStatereads the open epoch, the oracle price and config, the reserve figures, the custodian balance and the wind-down stateuseEpochHistoryreads every epoch from ledger entries;readEventslists the last 7 days of vault and oracle events from RPCCycleSurfacerenders each group as headline tiles plus a detail list, then the Epochs and Recent activity tablesMetricsStripaccepts any number of metrics and an optional notereadContractgainsreadEpochsandreadEventsAcceptance criteria
Test plan
Automated tests
npm run test— 691 passing.Manual verification
/adminas the manager.Breaking changes
None.
Checklist
Screenshots
None.