Skip to content

Conversation

@zeluisping
Copy link

Description

This PR introduces utilities for handling private events and consolidates event ABI definitions into common utilities for better code reuse.

Key Changes:

  • Event ABI Definitions: Moved event ABIs (UserOperationEvent, AccountDeployed, SignatureAggregatorChanged) into common utilities at packages/executor/src/utils/abi-events/ for reuse across the codebase
  • Private Event ABI: Added PrivateEvent ABI definition for decoding private events emitted by the EntryPoint contract
  • Event Topic Extraction: Implemented extractEventAbiTopics() utility that reconstructs event topics from decoded parameters, enabling proper event filtering and matching
  • Private Event Unwrapping: Created unwrapPrivateEvent() utility that decodes private event payloads and reconstructs them as standard event logs with proper topics and args

Implementation Details:

  • Since getPrivateLogs is not available in viem, these utilities provide an approach for decoding private event payloads and unwrapping them into the standard event log format
  • Custom error handling (AbiEventTopicsCountMismatchError) for debugging topic extraction issues
  • Maintains backward compatibility - support for public versions of events is preserved

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Further comments (optional)

  • The extractEventAbiTopics utility uses type-level recursion to build proper fixed-length topic arrays from event ABIs
  • Event ABIs were refactored into common utilities to avoid duplication and enable reuse across different services

@zeluisping zeluisping requested a review from seromenho October 21, 2025 11:30
@zeluisping zeluisping self-assigned this Oct 21, 2025
@zeluisping zeluisping added the enhancement New feature or request label Oct 21, 2025
@seromenho seromenho requested a review from Copilot October 22, 2025 14:19
Copy link

Copilot AI left a 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) into packages/executor/src/utils/abi-events/ for reuse
  • Added PrivateEvent ABI 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.

Comment on lines +89 to +93
// @ts-expect-error - dynamically extracted indexedValues cannot be proven to match generic tuple type
const topics = encodeEventTopics({
abi: [abi],
args: indexedValues
})
Copy link

Copilot AI Oct 22, 2025

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.

Comment on lines +45 to +51
return {
...ev,
eventName: abi.name,
args: decoded.args,
topics,
} as unknown as Log<bigint, number, false, ABI>
}
Copy link

Copilot AI Oct 22, 2025

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.

Suggested change
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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant