Description
Operations today must call a dozen getters (get_total_invoice_count, get_treasury, get_fee_bps, is_paused, get_pending_emergency_withdraw, ...) to assemble a health view. Add get_protocol_health(env) -> ProtocolHealth returning a single struct with version, init flag, paused flag, emergency status, treasury, fee bps, counts, and currency count. This becomes the canonical heartbeat for off-chain dashboards.
Requirements and context
- Secure: read-only, no auth required.
- Tested: every field populated correctly across protocol states.
- Documented:
docs/protocol-health.md.
- Reference:
src/lib.rs, src/admin.rs, src/pause.rs, src/emergency.rs.
Suggested execution
git checkout -b feature/protocol-health-endpoint
- Add
src/health.rs defining ProtocolHealth.
- Wire
get_protocol_health in src/lib.rs.
- Tests:
src/test_protocol_health.rs.
- Docs:
docs/protocol-health.md.
- Rust doc
/// NatSpec-style comments on each field.
- Validate that no PII or per-user fields leak.
Test and commit
Run cargo test test_protocol_health. Cover edge cases: uninitialized, paused, mid-emergency-withdraw. Include note that this endpoint is purely advisory.
Example commit message
feat(admin): add get_protocol_health runtime introspection endpoint
Guidelines
- Minimum 95% test coverage
- Clear documentation in
docs/protocol-health.md
- Timeframe: 96 hours
Description
Operations today must call a dozen getters (
get_total_invoice_count,get_treasury,get_fee_bps,is_paused,get_pending_emergency_withdraw, ...) to assemble a health view. Addget_protocol_health(env) -> ProtocolHealthreturning a single struct with version, init flag, paused flag, emergency status, treasury, fee bps, counts, and currency count. This becomes the canonical heartbeat for off-chain dashboards.Requirements and context
docs/protocol-health.md.src/lib.rs,src/admin.rs,src/pause.rs,src/emergency.rs.Suggested execution
git checkout -b feature/protocol-health-endpointsrc/health.rsdefiningProtocolHealth.get_protocol_healthinsrc/lib.rs.src/test_protocol_health.rs.docs/protocol-health.md.///NatSpec-style comments on each field.Test and commit
Run
cargo test test_protocol_health. Cover edge cases: uninitialized, paused, mid-emergency-withdraw. Include note that this endpoint is purely advisory.Example commit message
feat(admin): add get_protocol_health runtime introspection endpointGuidelines
docs/protocol-health.md