Skip to content

feat: add event utility functions for filtering events#839

Open
bimakw wants to merge 1 commit intoNethermindEth:mainfrom
bimakw:feature/event-utility-765
Open

feat: add event utility functions for filtering events#839
bimakw wants to merge 1 commit intoNethermindEth:mainfrom
bimakw:feature/event-utility-765

Conversation

@bimakw
Copy link
Copy Markdown

@bimakw bimakw commented Jan 7, 2026

Summary

Adds utility functions to filter events from []rpc.Event slices and a helper method on TransactionReceiptWithBlockInfo.

Changes

  • utils/events.go: New file with:
    • EventWith(events []rpc.Event, eventKey string) *rpc.Event - Returns first matching event
    • EventsWithKey(events []rpc.Event, eventKey string) []rpc.Event - Returns all matching events
  • rpc/types_transaction_receipt.go: Added method:
    • (r *TransactionReceiptWithBlockInfo) EventWith(eventKey string) *Event
  • utils/events_test.go: Unit tests for utility functions
  • rpc/types_transaction_receipt_test.go: Unit tests for receipt method

Usage

// Using utility function
myEvent := utils.EventWith(eventSlice, "event_key")

// Using receipt method
myEvent := txReceipt.EventWith("event_key")

Test Plan

  • All existing tests pass (make mock-test)
  • New unit tests added for all functions

Closes #765

- Add utils.EventWith() to find first event by selector name
- Add utils.EventsWithKey() to find all events by selector name
- Add EventWith() method to TransactionReceiptWithBlockInfo type
- Add comprehensive unit tests for all new functions

Closes NethermindEth#765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Utility for read events, and helper method in rpc.TransactionReceiptWithBlockInfo using it

1 participant