Repository navigation
Pause and resume the vault, oracle and token from the console - #230
luchobonatti wants to merge 12 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🔵 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.tsaction/tile logic,EmergencySectioncomponent, and seven write hooks (pause/unpause vault & token, raise/set ripcord, clear latest) with polling read hooks. - Shared helpers extracted from
cycle.tsintopages/actions.ts;CycleActionRailgeneralized over anyRailActionand reused by both surfaces. useAdminAuthoritynow reads the oracle admin and grants the emergency surface to guardian/oracle-guardian/oracle-admin/token-admin/governance;TransactionModalgains 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`, |
97479ed to
d5f8fac
Compare

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
get_adminon the oracle), the share-token admin and vault governancepause/unpause, oracleraise_ripcord,set_ripcord,clear_latest, and share-tokenpause/unpause;connectShareTokenaccepts a signertoEmergencyActionsgates each action on its contract guard and precondition, and states what it stops and what stays openEmergencySectionrenders status tiles and the shared action rail;CycleActionRailnow takes any action shape, with shared helpers inpages/actions.tsTransactionModalgains the seven actions; a refusal names the contract that refusedAcceptance criteria
Test plan
Automated tests
npm run test— 1110 passing.Manual verification
/admin/emergencyas the guardian: "Pause the vault" and "Raise the ripcord" are ready.Breaking changes
None.
Checklist
Screenshots
None.