fix(abi): handle anonymous events in encodeEventTopics#4463
Closed
Zelys-DFKH wants to merge 2 commits intowevm:mainfrom
Closed
fix(abi): handle anonymous events in encodeEventTopics#4463Zelys-DFKH wants to merge 2 commits intowevm:mainfrom
Zelys-DFKH wants to merge 2 commits intowevm:mainfrom
Conversation
|
@Zelys-DFKH is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 19bd5f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4461
Root cause
encodeEventTopicsinsrc/utils/abi/encodeEventTopics.tscomputes the event signature and prepends it as topic[0] unconditionally. Anonymous events do not include the signature as a topic — the EVM skips it entirely, giving anonymous events four indexed slots instead of three. BecauseabiItem.anonymouswas never checked,encodeEventTopicswas producing incorrect topics for any anonymous event.Fix
Move the signature computation inside a guard and only prepend it for non-anonymous events:
```ts
if (abiItem.anonymous) return topics
const definition = formatAbiItem(abiItem)
const signature = toEventSelector(definition as EventDefinition)
return [signature, ...topics]
```
The return type is loosened from
[Hex, ...(Hex | Hex[] | null)[]]to(Hex | Hex[] | null)[]since anonymous events with no args return an empty array.Tests
Added three unit tests covering anonymous events: no args (returns
[]), partial args, and all args.Notes