Description
Contract events in events.rs are emitted with ad-hoc topics, making indexing fragile. Introduce a single EventSchemaRegistry that names each event, lists its topic tuple, and pins a schema_version for OracleResultEvent and DisputeCreatedEvent first.
Requirements and Context
- Centralize topic construction in
events.rs::EventSchemaRegistry
- Each emit site reads
(name_symbol, schema_version) from the registry instead of inline literals
- Document the registry in
contracts/predictify-hybrid/src/events.rs rustdoc and surface a public read function for clients
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feat/event-schema-registry
- Implement changes
contracts/predictify-hybrid/src/events.rs
contracts/predictify-hybrid/src/resolution.rs (OracleResultEvent emit site)
contracts/predictify-hybrid/src/disputes.rs (DisputeCreatedEvent emit site)
- Test and commit
cargo test -p predictify-hybrid events -- --nocapture
- Cover edge cases: registry lookup miss, schema-version mismatch
- Include test output and notes in the PR
Example commit message
feat: centralize event schema registry for oracle and dispute events
Acceptance Criteria
Guidelines
- Use
symbol_short! only inside the registry, never at emit sites
- Minimum 95% coverage of changed branches
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
Contract events in
events.rsare emitted with ad-hoc topics, making indexing fragile. Introduce a singleEventSchemaRegistrythat names each event, lists its topic tuple, and pins aschema_versionforOracleResultEventandDisputeCreatedEventfirst.Requirements and Context
events.rs::EventSchemaRegistry(name_symbol, schema_version)from the registry instead of inline literalscontracts/predictify-hybrid/src/events.rsrustdoc and surface a public read function for clientsSuggested Execution
contracts/predictify-hybrid/src/events.rscontracts/predictify-hybrid/src/resolution.rs(OracleResultEvent emit site)contracts/predictify-hybrid/src/disputes.rs(DisputeCreatedEvent emit site)cargo test -p predictify-hybrid events -- --nocaptureExample commit message
Acceptance Criteria
EventSchemaRegistrycovers OracleResultEvent and DisputeCreatedEventsymbol_short!literalsunwrap()in emit pathsGuidelines
symbol_short!only inside the registry, never at emit sites