Repository navigation
Close and fulfill epochs from the admin panel - #222
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cb25554 to
5b965c2
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies the shared useContractTransaction hook that underpins every write flow and adds authorization-gated operator actions on a financial contract, so a human should confirm the blast radius and gating before approval.
0 open findings
What changed in this PR
This PR adds the "Close epoch" and "Fulfill epoch" operator actions to the Cycle card on /admin, advancing issue #193. It derives each action's conditions, resulting state, and availability from the read-only cycle state, wires the two new contract-write hooks through useContractTransaction (extended to refresh extra query keys after a write), and surfaces progress/refusals via TransactionModal.
Changes:
- New
useCloseEpoch/useFulfillEpochhooks call the vault and invalidatecycleWriteKeys;useContractTransactiongains anextraKeysparameter. toCycleActionscomputes per-action conditions, outcome, and multisig unavailability; the Epoch group renders condition/outcome/button blocks viaCycleActions.TransactionModalgainsclose-epoch/fulfill-epochflows with contract errors mapped to sentences and an operator-oriented follow-up message.
| File | Description |
|---|---|
| app/src/pages/cycle.ts | Adds toCycleActions and helpers deriving close/fulfill conditions, outcomes, and availability. |
| app/src/pages/cycle.test.ts | Tests the new action-derivation logic across conditions and roles. |
| app/src/pages/AdminPanel.tsx | Passes the Cycle surface's grants to CycleSection. |
| app/src/pages/AdminPanel.test.tsx | Verifies grants are forwarded to the Cycle card. |
| app/src/hooks/useCloseEpoch.ts | New hook calling close_epoch, refreshing cycle caches. |
| app/src/hooks/useCloseEpoch.test.ts | Covers status flow, refusal, decline, and cache invalidation. |
| app/src/hooks/useFulfillEpoch.ts | New hook calling fulfill_epoch, returning the settled share price. |
| app/src/hooks/useFulfillEpoch.test.ts | Covers status flow, refusal, decline, and cache invalidation. |
| app/src/hooks/useCycleState.ts | Exports cycle query-key constants and cycleWriteKeys. |
| app/src/hooks/useContractTransaction.ts | Adds optional extraKeys invalidated on confirmation. |
| app/src/hooks/useContractTransaction.test.ts | Tests extra-key invalidation and default behavior. |
| app/src/components/vault/TransactionModal.tsx | Adds close/fulfill modal flows and error-to-sentence mappings. |
| app/src/components/vault/TransactionModal.test.tsx | Tests the new modal copy and error rendering. |
| app/src/components/admin/CycleSurface.tsx | Adds CycleActions and a per-group actions slot. |
| app/src/components/admin/CycleSurface.test.tsx | Tests the action area rendering and interactions. |
| app/src/components/admin/CycleSurface.module.css | Styling for the action blocks and unmet conditions. |
| app/src/components/admin/CycleSection.tsx | Wires actions, hooks, and the modal into the section. |
| app/src/components/admin/CycleSection.test.tsx | End-to-end coverage of the section's action/modal wiring. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5b965c2 to
f40861e
Compare
f40861e to
70988a2
Compare
Summary
Part of #193
The Cycle card on
/admincloses the open epoch and fulfills the sealed one.Changes
useCloseEpochanduseFulfillEpochcall the vault throughuseContractTransaction, which now takes extra query keys to refresh after a writetoCycleActionsderives each action's conditions and its resulting state from the cycle state; a multisig authority sees the action as unavailableTransactionModalgains theclose-epochandfulfill-epochactions with the vault's errors mapped to sentencesAcceptance criteria
Test plan
Automated tests
npm run test— 774 passing.Manual verification
/adminas the manager: Close epoch is enabled, Fulfill epoch lists its unmet conditions.Breaking changes
None.
Checklist
Screenshots
None.