Repository navigation
Deploy and fund the reserve from the admin panel - #225
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
e4fbab9 to
bca5d01
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It adds five write hooks that move real on-chain value plus a new admin surface, so despite strong tests and verified contract-error mappings it warrants final human review.
1 open finding
What changed in this PR
This PR extends the /admin Cycle surface (part of #193) so the treasury can deploy reserve assets to the custodian and any Cycle role can fund the reserve, directly from the Cycle card. It adds the two write hooks, the action-model logic that gates each button on live contract state, and the modal flows that map contract errors to human-readable refusals. It builds on the existing useContractTransaction/TransactionModal/CycleSurface infrastructure and the generated clients, moving real on-chain value (classic-asset transfers into the vault and out to the custodian).
Changes:
- New
useDeployToCustodiananduseFundhooks call the vault viauseContractTransaction;fundadditionally refreshes the funder's deposit balance. toCycleActions/toDeployAction/toFundActionincycle.tsgate deploy (wind-down, custodian set, free reserve) and fund (wallet balance), each with a "Use max", conditions, and pre-sign resulting reserve state.TransactionModalgainsdeploy/fundactions with vault error codes mapped; a token refusal on fund points the funder at their wallet balance/trustline.
| File | Description |
|---|---|
app/src/pages/cycle.ts |
Core action/condition/outcome model + deploy/fund builders and reserve display rows. |
app/src/hooks/useDeployToCustodian.ts |
New treasury hook wrapping deploy_to_custodian via useContractTransaction. |
app/src/hooks/useFund.ts |
New fund hook; refreshes funder deposit balance on confirm. |
app/src/hooks/useCloseEpoch.ts / useFulfillEpoch.ts / useAttest.ts |
Cycle write hooks reused by the surface. |
app/src/hooks/useCycleState.ts |
Composes cycle state (reserve, oracle, wind-down) incl. custodian balance read; defines cycleWriteKeys. |
app/src/hooks/useContractTransaction.ts |
Adds extraKeys invalidation parameter. |
app/src/components/vault/TransactionModal.tsx |
Adds deploy/fund (+ close/fulfill/attest) flows with contract-error messages. |
app/src/components/admin/CycleSurface.tsx / CycleSection.tsx |
UI wiring: amount fields, conditions, resulting state, buttons per group. |
app/src/components/vault/MetricsStrip.tsx (+ .module.css) |
Widened to Metric[] with optional note; grid flow tweak. |
app-lib/readContract.ts |
New readEpochs, readLedgerTime, readEvents + ChainEvent types. |
app-lib/contracts.ts |
connectNavOracle gains optional signer for the write client. |
*.test.ts(x) |
Comprehensive tests for all new hooks, logic, reads, and modal flows. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return useContractTransaction<Amount, bigint, Record<never, never>>( | ||
| call, | ||
| toConfirmed, | ||
| cycleWriteKeys, |
f6e02cc to
20eb16d
Compare
20eb16d to
3e1e229
Compare
3e1e229 to
4b61382
Compare
4b61382 to
4faf7d7
Compare

Summary
Part of #193
The treasury deploys reserve to the custodian, and any Cycle role funds the reserve, from the Cycle card on
/admin.Changes
useDeployToCustodiananduseFundcall the vault throughuseContractTransaction; fund refreshes the funder's balancetoCycleActionschecks deploy against wind-down, the custodian and the free reserve, and fund against the wallet balanceTransactionModalgains thedeployandfundactions with the vault's errors mapped; a token refusal on fund names the walletAcceptance criteria
Test plan
Automated tests
npm run test— 906 passing.Manual verification
/adminas the treasury: the Reserve group shows Deploy to custodian and Fund the reserve.Breaking changes
None.
Checklist
Screenshots
None.