Events are defined but not integrated with the contract's core operations. The contract emits DocumentRegistered and DocumentRevoked events but lacks a structured event sourcing system and comprehensive audit trail. We need to create an event store mechanism that tracks all state changes, including document verification attempts, authorization failures, and status changes. This requires enhanced event types for all contract interactions and a persistent event log accessible by contract methods.
Affected Files:
src/lib.rs (all contract methods need event emission)
src/event.rs (new event types and event store logic)
src/cache.rs (event caching/retrieval)
Acceptance Criteria:
- Define additional event types:
DocumentVerified, DocumentAuthorizationFailed, DocumentOwnerChanged
- Add event sequence tracking to ensure correct ordering
- Implement
emit_event() helper function in contract that records events to persistent storage
- Add
get_document_history() method to retrieve all events for a document
- Track actor (issuer/owner) and timestamp for all events
- All state-changing operations must emit corresponding events
- Add tests verifying event emission and retrieval for all contract operations
- Document event schema for off-chain consumers
Impact:
- Full audit trail for regulatory compliance
- Better debugging and forensics capabilities
- Foundation for future replay and event sourcing features
Events are defined but not integrated with the contract's core operations. The contract emits
DocumentRegisteredandDocumentRevokedevents but lacks a structured event sourcing system and comprehensive audit trail. We need to create an event store mechanism that tracks all state changes, including document verification attempts, authorization failures, and status changes. This requires enhanced event types for all contract interactions and a persistent event log accessible by contract methods.Affected Files:
src/lib.rs(all contract methods need event emission)src/event.rs(new event types and event store logic)src/cache.rs(event caching/retrieval)Acceptance Criteria:
DocumentVerified,DocumentAuthorizationFailed,DocumentOwnerChangedemit_event()helper function in contract that records events to persistent storageget_document_history()method to retrieve all events for a documentImpact: