Repository navigation
Attest the share price from the admin panel - #224
luchobonatti wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
49eb536 to
dd6b4bd
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces on-chain share-price attestation whose client-side band/cooldown/deviation checks must stay in sync with the nav-oracle contract, and it refactors the shared per-signer writer cache used by other transaction flows, so human sign-off is warranted despite strong test coverage.
0 open findings
What changed in this PR
This PR implements the oracle attester's "Attest price" action on the /admin Cycle surface (part of #193). It lets the attester type a share price, see it validated client-side against the oracle's band, cooldown, and allowed-move limits before signing, and records it on-chain via the nav-oracle's attest. The resulting state and refusal reasons are surfaced in the shared TransactionModal.
Changes:
- New
useAttesthook submitsattestthroughuseContractTransaction;connectNavOraclenow accepts a signer and a reusable genericwriterfactory backsnavOracleWriter/asyncVaultWriter. toAttestActionadds a typed-price field plus band/cooldown/allowed-move conditions (with allowed-range details), a ripcord note, and a resulting-state outcome; the Cycle surface renders a screen-reader-labelled decimal field and nullable ("—") conditions.TransactionModalgains anattestflow mapping oracle errors (3002–3005) to sentences;CycleSectionwires input, submission, modal, and clears the field once confirmed.
| File | Description |
|---|---|
| app/src/pages/cycle.ts | Adds AttestAction/ActionField types and toAttestAction with band/cooldown/move condition checks |
| app/src/pages/cycle.test.ts | Tests for the attest action, conditions, caps, and edge cases |
| app/src/hooks/useAttest.ts | New hook calling the oracle's attest, computing expiry from the wall clock + freshness |
| app/src/hooks/useAttest.test.ts | Covers status transitions, simulation refusals, decline, in-flight guard, cache invalidation |
| app/src/config/clients.ts | Refactors per-signer writer caching into a generic writer; adds navOracleWriter |
| app/src/components/vault/TransactionModal.tsx | Adds the attest modal variant and oracle error-to-sentence mapping |
| app/src/components/vault/TransactionModal.test.tsx | Tests the attest modal states and error messaging |
| app/src/components/admin/CycleSurface.tsx | Renders the input field, nullable-condition dash/detail, and action note |
| app/src/components/admin/CycleSurface.test.tsx | Tests field rendering, open conditions, details, and notes |
| app/src/components/admin/CycleSurface.module.css | Styles for the field, invalid state, note, and screen-reader-only label |
| app/src/components/admin/CycleSection.tsx | Wires attest submission, input state, modal flow, and field clearing on confirm |
| app/src/components/admin/CycleSection.test.tsx | Integration tests for the attester flow and price clearing |
| app-lib/contracts.ts | connectNavOracle now accepts an optional signer |
| app-lib/contracts.test.ts | Tests read vs signer-carrying oracle clients |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dd6b4bd to
fa9b92e
Compare
Summary
Part of #193
The oracle attester records a share price from the Cycle card on
/admin.Changes
useAttestcalls the oracle'sattestthroughuseContractTransaction;connectNavOracleaccepts a signer andnavOracleWriteris addedtoAttestActionchecks the typed price against the band, the cooldown and the allowed move, and shows the allowed range when a check failsTransactionModalgains theattestaction with the oracle's errors mapped to sentencesAcceptance criteria
Test plan
Automated tests
npm run test— 828 passing.Manual verification
/adminas the attester and type a price within 10% of the last one: every condition reads Met and the button is enabled.Breaking changes
None.
Checklist
Screenshots
None.