Skip to content

Close and fulfill epochs from the admin panel - #222

Merged
luchobonatti merged 3 commits into
mainfrom
feat/193-cycle-actions
Oct 13, 2026
Merged

luchobonatti merged 3 commits into
mainfrom
feat/193-cycle-actions

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Part of #193

The Cycle card on /admin closes the open epoch and fulfills the sealed one.

Changes

  • useCloseEpoch and useFulfillEpoch call the vault through useContractTransaction, which now takes extra query keys to refresh after a write
  • toCycleActions derives each action's conditions and its resulting state from the cycle state; a multisig authority sees the action as unavailable
  • The Epoch group ends with one block per action: conditions, resulting state, button
  • TransactionModal gains the close-epoch and fulfill-epoch actions with the vault's errors mapped to sentences

Acceptance criteria

  • Close epoch is shown to the manager only; fulfill epoch to every Cycle role
  • Each button is enabled only when every listed condition is met
  • The resulting state is shown before signing
  • Contract refusals name the reason in the modal

Test plan

Automated tests

npm run test — 774 passing.

Manual verification

  1. On a local network, open /admin as the manager: Close epoch is enabled, Fulfill epoch lists its unmet conditions.
  2. Close the epoch and attest a price; as treasury, Fulfill epoch shows every condition met and "Prices epoch N at and settles its requests."

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:30
@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 13, 2026 12:08pm UTC

Request Review

@luchobonatti
luchobonatti added this pull request to stack #223 October 9, 2026 00:34
@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
@luchobonatti luchobonatti self-assigned this Oct 9, 2026
@luchobonatti
luchobonatti force-pushed the feat/193-cycle-actions branch from cb25554 to 5b965c2 Compare 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 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/useFulfillEpoch hooks call the vault and invalidate cycleWriteKeys; useContractTransaction gains an extraKeys parameter.
  • toCycleActions computes per-action conditions, outcome, and multisig unavailability; the Epoch group renders condition/outcome/button blocks via CycleActions.
  • TransactionModal gains close-epoch/fulfill-epoch flows 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.

Base automatically changed from feat/193-cycle-surface to main October 13, 2026 12:08
@luchobonatti
luchobonatti force-pushed the feat/193-cycle-actions branch from f40861e to 70988a2 Compare October 13, 2026 12:08
@luchobonatti
luchobonatti merged commit d44bb7c into main Oct 13, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 70988a2f Deployed Oct 13, 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