Skip to content

refactor(framework): use custom event handles for DID and payment channel events#3793

Merged
jolestar merged 1 commit into
mainfrom
didi_channel_event
Nov 22, 2025
Merged

refactor(framework): use custom event handles for DID and payment channel events#3793
jolestar merged 1 commit into
mainfrom
didi_channel_event

Conversation

@jolestar

Copy link
Copy Markdown
Contributor

Summary

Refactor event emission in did.move and payment_channel.move to use custom event handles, following the pattern established in payment_revenue.move. This enables efficient event retrieval by specific entity ObjectID for better indexing performance.

Changes

DID Module (did.move)

  • Keep DIDCreatedEvent using global event::emit() to allow traversing all DID creations
  • Add did_event_handle_id<T>(did_object_id: ObjectID) helper function
  • Update modification events to use event::emit_with_handle():
    • VerificationMethodAddedEvent
    • VerificationMethodRemovedEvent
    • VerificationRelationshipModifiedEvent
    • ServiceAddedEvent
    • ServiceUpdatedEvent
    • ServiceRemovedEvent

Payment Channel Module (payment_channel.move)

  • Add hub_event_handle_id<T>(hub_id: ObjectID) helper function
  • Add channel_event_handle_id<T>(channel_id: ObjectID) helper function
  • Update all events to use event::emit_with_handle():
    • Hub events: PaymentHubCreatedEvent, PaymentHubWithdrawEvent, LockedUnitConfigUpdatedEvent
    • Channel events: ChannelClaimedEvent, PaymentChannelOpenedEvent, SubChannelAuthorizedEvent, ChannelClosedEvent, ChannelCancellationInitiatedEvent, ChannelDisputeEvent, ChannelCancellationFinalizedEvent

Benefits

  1. Efficient Event Retrieval: Events can now be efficiently queried by specific DID or PaymentChannel ObjectID
  2. Consistent Pattern: Follows the same pattern as payment_revenue.move
  3. Mainnet Ready: Improves event indexing performance for production use
  4. Flexible Querying:
    • Global traversal: Use DIDCreatedEvent to find all DIDs
    • Entity-specific: Use custom handles to get all events for a specific DID or channel

Testing

  • ✅ All framework tests passed: make test-move-frameworks
  • ✅ Code follows project conventions and linting rules

Related

Follows the event refactoring pattern established in payment_revenue module for mainnet launch preparation.

…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
@vercel

vercel Bot commented Nov 21, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Nov 21, 2025 2:51pm
test-portal Ready Ready Preview Comment Nov 21, 2025 2:51pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Nov 21, 2025 2:51pm

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@jolestar jolestar requested a review from Copilot November 21, 2025 14:47
@jolestar

Copy link
Copy Markdown
Contributor Author

#3741

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DIDCreatedEvent using global event::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, PaymentHubCreatedEvent should be updated to use custom event handles, but it still uses global event::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 PaymentChannelOpenedEvent emission (channel reactivation path) is listed in the PR description as being updated to use custom event handles, but it still uses global event::emit(). This should be updated to use event::emit_with_handle() with channel_event_handle_id<PaymentChannelOpenedEvent>(channel_id) for consistency with other channel events.
            event::emit(PaymentChannelOpenedEvent {

frameworks/rooch-framework/sources/payment_channel.move:696

  • The PaymentChannelOpenedEvent emission (new channel creation path) is listed in the PR description as being updated to use custom event handles, but it still uses global event::emit(). This should be updated to use event::emit_with_handle() with channel_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 LockedUnitConfigUpdatedEvent should be updated to use custom event handles, but it still uses global event::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 {

@jolestar jolestar merged commit dbd0f14 into main Nov 22, 2025
25 checks passed
@jolestar jolestar deleted the didi_channel_event branch November 22, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants