Skip to content

Pause and resume the vault, oracle and token from the console - #230

Open
luchobonatti wants to merge 12 commits into
mainfrom
feat/195-emergency-surface
Open

luchobonatti wants to merge 12 commits into
mainfrom
feat/195-emergency-surface

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Closes #195

The Emergency tab shows the vault, share-token and oracle pause state, and offers every pause and ripcord action the contracts permit to the connected wallet.

Changes

  • The emergency surface is granted to the vault guardian, the oracle guardian, the oracle admin (read with get_admin on the oracle), the share-token admin and vault governance
  • Hooks for vault pause/unpause, oracle raise_ripcord, set_ripcord, clear_latest, and share-token pause/unpause; connectShareToken accepts a signer
  • toEmergencyActions gates each action on its contract guard and precondition, and states what it stops and what stays open
  • EmergencySection renders status tiles and the shared action rail; CycleActionRail now takes any action shape, with shared helpers in pages/actions.ts
  • TransactionModal gains the seven actions; a refusal names the contract that refused
  • The page title reads "Operations Console" with the wallet's current roles under it

Acceptance criteria

  • Vault pause and share-token pause each say what they block and what stays open
  • Unpause, ripcord reset and share-token pause/unpause are offered only to the authorities the contracts require
  • Current vault pause, token pause and ripcord state shown first

Test plan

Automated tests

npm run test — 1110 passing.

Manual verification

  1. On a local network, open /admin/emergency as the guardian: "Pause the vault" and "Raise the ripcord" are ready.
  2. Open it as governance (also oracle admin and share-token admin locally): six actions, with unpause, lower and clear showing their unmet precondition.

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 review from hpmaxi and a balanced review from Copilot October 13, 2026 19:20
@vercel

vercel Bot commented Oct 13, 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 14, 2026 6:29pm UTC

Request Review

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 implements operations-critical emergency pause/ripcord controls whose authorization mapping spans three contracts, warranting final human review despite thorough tests.

1 open finding
What changed in this PR

This PR adds an Emergency (now "Operations Console") admin surface that surfaces the live pause state of the vault, share token and oracle, and offers every pause/unpause/ripcord action that the contracts permit to the connected wallet. It extends the existing admin authority model to recognize the oracle admin (via get_admin) and to grant the emergency surface to the relevant authorities, refactors the cycle action-rail/helpers into a reusable shape, and wires seven new contract-write hooks into a shared transaction modal. I verified the role gating against the Soroban contracts (vault pause = guardian, unpause = admin/governance; share-token pause/unpause = admin; raise_ripcord = guardian, set_ripcord/clear_latest = admin) and the error-code copy (1000/1001/2000/3008) — all are correct.

Changes:

  • New emergency surface: emergency.ts action/tile logic, EmergencySection component, and seven write hooks (pause/unpause vault & token, raise/set ripcord, clear latest) with polling read hooks.
  • Shared helpers extracted from cycle.ts into pages/actions.ts; CycleActionRail generalized over any RailAction and reused by both surfaces.
  • useAdminAuthority now reads the oracle admin and grants the emergency surface to guardian/oracle-guardian/oracle-admin/token-admin/governance; TransactionModal gains emergency copy that names the refusing contract.
File Description
app/​src/​pages/​emergency.ts Core logic mapping roles/state to gated emergency actions and status tiles.
app/​src/​pages/​emergency.test.ts Tests for action gating, preconditions, tones and tiles.
app/​src/​pages/​actions.ts Shared RailAction/Condition types and grant helpers extracted from cycle.
app/​src/​pages/​actions.test.ts Tests for the extracted helpers.
app/​src/​pages/​cycle.ts Re-uses extracted helpers; ActionBase now derives from RailAction.
app/​src/​pages/​cycle.test.ts Removes tests now covered by actions.test.ts.
app/​src/​pages/​AdminPanel.tsx Title-cases roles, adds describeRoles, dispatches surfaces via SurfaceBody, renames heading.
app/​src/​pages/​AdminPanel.test.tsx Tests for emergency surface rendering and new copy.
app/​src/​hooks/​usePauseVault/​useUnpauseVault/​usePauseToken/​useUnpauseToken.ts Vault/token pause-unpause write hooks + tests.
app/​src/​hooks/​useRaiseRipcord/​useSetRipcord/​useClearLatest.ts Oracle ripcord write hooks + tests.
app/​src/​hooks/​useOracleState.ts New oracle status read hook with polling + write-key set.
app/​src/​hooks/​useVaultPaused.ts /​ useTokenPaused.ts Shared pause classification, exported keys, optional polling.
app/​src/​hooks/​useAdminAuthority.ts Reads oracle admin via get_admin; grants emergency surface.
app/​src/​config/​clients.ts /​ app-lib/​contracts.ts shareTokenWriter and signer-aware connectShareToken.
app/​src/​components/​admin/​EmergencySection.tsx (+css/​test) Renders tiles + action rail and drives the transaction modal.
app/​src/​components/​admin/​CycleActionRail.tsx (+css/​test) Generalized rail supporting a scope and danger tone.
app/​src/​components/​vault/​TransactionModal.tsx (+test) Adds the seven emergency flows and contract-named refusal copy.

🧠 Review effort: Balanced


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

case "contract-error":
return {
heading: "The vault refused this request",
heading: `The ${refuser} refused this request`,
Base automatically changed from feat/227-admin-surface-tabs to main October 14, 2026 18:29

This branch was successfully deployed

1 active deployment
Preview — d5f8facf Deployed Oct 14, 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.

Emergency surface: pauses and the ripcord

3 participants