Skip to content

Attest the share price from the admin panel - #224

Open
luchobonatti wants to merge 3 commits into
feat/193-cycle-actionsfrom
feat/193-attest
Open

luchobonatti wants to merge 3 commits into
feat/193-cycle-actionsfrom
feat/193-attest

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Part of #193

The oracle attester records a share price from the Cycle card on /admin.

Changes

  • useAttest calls the oracle's attest through useContractTransaction; connectNavOracle accepts a signer and navOracleWriter is added
  • toAttestAction checks the typed price against the band, the cooldown and the allowed move, and shows the allowed range when a check fails
  • The Price group ends with the price field, the conditions, the resulting state and the button; a raised ripcord is noted, since attesting does not lift it
  • TransactionModal gains the attest action with the oracle's errors mapped to sentences
  • The expiry is computed at signing; the price field clears once the attestation confirms

Acceptance criteria

  • Only the oracle attester sees the action
  • The button is enabled only when the typed price passes the band, the cooldown and the allowed move
  • The resulting state is shown before signing
  • Oracle refusals name the reason in the modal

Test plan

Automated tests

npm run test — 828 passing.

Manual verification

  1. On a local network, open /admin as the attester and type a price within 10% of the last one: every condition reads Met and the button is enabled.
  2. Type a price 25% higher: "Within the allowed move" shows the allowed ceiling and the button is disabled.

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 13:14
@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 9, 2026 4:05pm UTC

Request Review

@luchobonatti luchobonatti self-assigned this Oct 9, 2026
@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 added this pull request to stack #223 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 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 useAttest hook submits attest through useContractTransaction; connectNavOracle now accepts a signer and a reusable generic writer factory backs navOracleWriter/asyncVaultWriter.
  • toAttestAction adds 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.
  • TransactionModal gains an attest flow mapping oracle errors (3002–3005) to sentences; CycleSection wires 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.

This branch was successfully deployed

1 active deployment
Preview — fa9b92ea Deployed Oct 9, 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