refactor(framework): use custom event handles for DID and payment channel events#3793
Conversation
…nnel events - Add custom event handle support for DID modification events - Keep DIDCreatedEvent using global emit for traversing all DIDs - Use did_event_handle_id for modification events (add/remove VM, services, etc.) - Add custom event handle support for payment channel events - Use hub_event_handle_id for PaymentHub related events - Use channel_event_handle_id for PaymentChannel related events - Benefits: - Enable efficient event retrieval by specific DID or channel ObjectID - Follow the same pattern as payment_revenue.move - Improve event indexing performance for mainnet launch - All framework tests passed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR refactors event emission in the did.move and payment_channel.move modules to use custom event handles for entity-specific events, following the pattern from payment_revenue.move. This improves event indexing performance by enabling efficient queries by specific DID or payment channel ObjectID.
Key Changes:
- Added helper functions to derive per-entity event handles in both modules
- Updated modification events to use
event::emit_with_handle()for entity-scoped queries - Kept
DIDCreatedEventusing globalevent::emit()for global traversal capability
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frameworks/rooch-framework/sources/did.move | Added did_event_handle_id() helper; refactored 6 modification events to use custom handles |
| frameworks/rooch-framework/sources/payment_channel.move | Added hub_event_handle_id() and channel_event_handle_id() helpers; refactored 7 channel/hub events to use custom handles |
Comments suppressed due to low confidence (4)
frameworks/rooch-framework/sources/payment_channel.move:305
- According to the PR description,
PaymentHubCreatedEventshould be updated to use custom event handles, but it still uses globalevent::emit(). The payment_revenue.move module (which this PR claims to follow) uses custom handles for ALL events including creation events. Either update this event to use custom handles or clarify in the PR description why hub creation events should remain global while channel events use custom handles.
event::emit(PaymentHubCreatedEvent {
frameworks/rooch-framework/sources/payment_channel.move:661
- The
PaymentChannelOpenedEventemission (channel reactivation path) is listed in the PR description as being updated to use custom event handles, but it still uses globalevent::emit(). This should be updated to useevent::emit_with_handle()withchannel_event_handle_id<PaymentChannelOpenedEvent>(channel_id)for consistency with other channel events.
event::emit(PaymentChannelOpenedEvent {
frameworks/rooch-framework/sources/payment_channel.move:696
- The
PaymentChannelOpenedEventemission (new channel creation path) is listed in the PR description as being updated to use custom event handles, but it still uses globalevent::emit(). This should be updated to useevent::emit_with_handle()withchannel_event_handle_id<PaymentChannelOpenedEvent>(channel_id)for consistency with other channel events.
event::emit(PaymentChannelOpenedEvent {
frameworks/rooch-framework/sources/payment_channel.move:1552
- The PR description claims
LockedUnitConfigUpdatedEventshould be updated to use custom event handles, but it still uses globalevent::emit(). If this is a global config event that doesn't belong to a specific hub, it should remain global and be removed from the PR description's list of updated events. If it should use custom handles, it needs the ObjectID of the relevant entity to emit with a custom handle.
event::emit(LockedUnitConfigUpdatedEvent {
Summary
Refactor event emission in
did.moveandpayment_channel.moveto use custom event handles, following the pattern established inpayment_revenue.move. This enables efficient event retrieval by specific entity ObjectID for better indexing performance.Changes
DID Module (
did.move)DIDCreatedEventusing globalevent::emit()to allow traversing all DID creationsdid_event_handle_id<T>(did_object_id: ObjectID)helper functionevent::emit_with_handle():VerificationMethodAddedEventVerificationMethodRemovedEventVerificationRelationshipModifiedEventServiceAddedEventServiceUpdatedEventServiceRemovedEventPayment Channel Module (
payment_channel.move)hub_event_handle_id<T>(hub_id: ObjectID)helper functionchannel_event_handle_id<T>(channel_id: ObjectID)helper functionevent::emit_with_handle():PaymentHubCreatedEvent,PaymentHubWithdrawEvent,LockedUnitConfigUpdatedEventChannelClaimedEvent,PaymentChannelOpenedEvent,SubChannelAuthorizedEvent,ChannelClosedEvent,ChannelCancellationInitiatedEvent,ChannelDisputeEvent,ChannelCancellationFinalizedEventBenefits
payment_revenue.moveDIDCreatedEventto find all DIDsTesting
make test-move-frameworksRelated
Follows the event refactoring pattern established in payment_revenue module for mainnet launch preparation.