-
Notifications
You must be signed in to change notification settings - Fork 0
feat: private event utilities #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/update-sd-dependency-match-lock-viem
Are you sure you want to change the base?
feat: private event utilities #4
Conversation
There was a problem hiding this comment.
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 introduces utilities for handling private events in the EntryPoint contract and consolidates event ABI definitions into reusable modules. The changes enable decoding private event payloads and reconstructing them as standard event logs with proper topics.
Key Changes:
- Consolidated event ABI definitions (
UserOperationEvent,AccountDeployed,SignatureAggregatorChanged) intopackages/executor/src/utils/abi-events/for reuse - Added
PrivateEventABI and utilities to decode/unwrap private events - Implemented topic extraction from decoded event parameters
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/executor/src/utils/abi-events/index.ts |
Central export for all event ABI definitions |
packages/executor/src/utils/abi-events/UserOperationEvent.ts |
UserOperationEvent ABI definition with event hash |
packages/executor/src/utils/abi-events/SignatureAggregatorChanged.ts |
SignatureAggregatorChanged ABI definition |
packages/executor/src/utils/abi-events/PrivateEvent.ts |
PrivateEvent ABI definition for wrapped events |
packages/executor/src/utils/abi-events/AccountDeployed.ts |
AccountDeployed ABI definition with event hash |
packages/executor/src/utils/extractEventAbiTopics.ts |
Utility to extract and encode event topics from payload |
packages/executor/src/utils/unwrapPrivateEvent.ts |
Utility to decode private events into standard logs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // @ts-expect-error - dynamically extracted indexedValues cannot be proven to match generic tuple type | ||
| const topics = encodeEventTopics({ | ||
| abi: [abi], | ||
| args: indexedValues | ||
| }) |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @ts-expect-error directive suppresses type checking without validation. Consider using @ts-ignore with a more specific explanation, or better yet, add runtime validation to ensure indexedValues matches the expected structure before encoding.
Copilot uses AI. Check for mistakes.
| return { | ||
| ...ev, | ||
| eventName: abi.name, | ||
| args: decoded.args, | ||
| topics, | ||
| } as unknown as Log<bigint, number, false, ABI> | ||
| } |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double type assertion (as unknown as) bypasses type safety. Consider restructuring the return type or adding runtime validation to ensure the shape matches Log<bigint, number, false, ABI> before returning.
| return { | |
| ...ev, | |
| eventName: abi.name, | |
| args: decoded.args, | |
| topics, | |
| } as unknown as Log<bigint, number, false, ABI> | |
| } | |
| // Runtime validation: ensure decoded.args is an object and matches ABI inputs | |
| if ( | |
| typeof decoded.args !== 'object' || | |
| decoded.args === null | |
| ) { | |
| throw new Error('Decoded args is not an object'); | |
| } | |
| // Optionally, check that all ABI inputs are present in decoded.args | |
| if ( | |
| !abi.inputs.every(input => input.name in (decoded.args as object)) | |
| ) { | |
| throw new Error('Decoded args does not match ABI inputs'); | |
| } | |
| return { | |
| ...ev, | |
| eventName: abi.name, | |
| args: decoded.args, | |
| topics, | |
| }; |
Copilot uses AI. Check for mistakes.
Description
This PR introduces utilities for handling private events and consolidates event ABI definitions into common utilities for better code reuse.
Key Changes:
UserOperationEvent,AccountDeployed,SignatureAggregatorChanged) into common utilities atpackages/executor/src/utils/abi-events/for reuse across the codebasePrivateEventABI definition for decoding private events emitted by the EntryPoint contractextractEventAbiTopics()utility that reconstructs event topics from decoded parameters, enabling proper event filtering and matchingunwrapPrivateEvent()utility that decodes private event payloads and reconstructs them as standard event logs with proper topics and argsImplementation Details:
getPrivateLogsis not available in viem, these utilities provide an approach for decoding private event payloads and unwrapping them into the standard event log formatAbiEventTopicsCountMismatchError) for debugging topic extraction issuesTypes of changes
What types of changes does your code introduce?
Put an
xin the boxes that applyFurther comments (optional)
extractEventAbiTopicsutility uses type-level recursion to build proper fixed-length topic arrays from event ABIs