Skip to content

feat: support anonymous events in encodeEventTopics#4554

Closed
tenderdeve wants to merge 1 commit into
wevm:mainfrom
tenderdeve:fix/anonymous-event-topics
Closed

feat: support anonymous events in encodeEventTopics#4554
tenderdeve wants to merge 1 commit into
wevm:mainfrom
tenderdeve:fix/anonymous-event-topics

Conversation

@tenderdeve
Copy link
Copy Markdown

Summary

  • encodeEventTopics() unconditionally prepended the event signature hash as the first topic, but anonymous Solidity events (anonymous: true) should have no signature topic
  • Fix: Check abiItem.anonymous and skip toEventSelector() + signature prepend for anonymous events
  • Return type: Made generic over anonymous boolean — anonymous events return (Hex | Hex[] | null)[], non-anonymous keep [Hex, ...(Hex | Hex[] | null)[]]. Default is false so all existing callers are unaffected.
  • Downstream callers (getLogs, watchEvent, watchContractEvent, createEventFilter) need no changes

Files:

  • src/utils/abi/encodeEventTopics.ts — runtime check + return type
  • src/utils/abi/encodeEventTopics.test.ts — 4 new test cases

Fixes #4461

Test plan

  • Anonymous event with no args → returns []
  • Anonymous event with indexed args → encoded topics without signature
  • Non-anonymous events → unchanged behavior
  • Existing test suite passes

Anonymous Solidity events have no signature topic, but
encodeEventTopics unconditionally prepended one. Skip the
signature hash for events with anonymous: true in the ABI
and adjust the return type to reflect the difference.

Includes tests for anonymous events with and without args.

Fixes wevm#4461
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

@tenderdeve is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

⚠️ No Changeset found

Latest commit: 512570f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jxom jxom closed this Apr 30, 2026
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.

encodeEventTopics() (and watchLogs()) do not handle anonymous events

2 participants