Skip to content

fix: match non-indexed string and bytes filters in parseEventLogs - #5257

Closed
mortezashojaei wants to merge 5 commits into
wevm:mainfrom
mortezashojaei:fix/parse-event-logs-nonindexed-args
Closed

mortezashojaei wants to merge 5 commits into
wevm:mainfrom
mortezashojaei:fix/parse-event-logs-nonindexed-args

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

parseEventLogs has hashed every string and bytes filter since args was added in #2533. That followed the topic rule: an indexed dynamic value is stored as keccak256 of its contents. A non-indexed value is ABI-decoded back to the original string or hex, so the filter compared the hash with "hello" or 0x1234 and dropped the log.

#5238 fixed the indexed case where a hex-looking string was hashed as raw bytes instead of UTF-8. Hashing stayed unconditional, so non-indexed arguments still never matched. getLogs and getContractEvents pass args through this helper and dropped the same logs.

The hash now runs only when the parameter is indexed.

Test plan

  • Non-indexed string "hello" matches; "goodbye" does not
  • Non-indexed bytes 0x1234 matches; 0x5678 does not
  • Positional unnamed args and an empty string match
  • Indexed bytes still matches by topic hash
  • Existing indexed string tests still pass

The args filter has hashed every string and bytes value since it was added, which only matches indexed parameters.
@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf15025

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

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

@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

jxom commented Oct 22, 2026

Copy link
Copy Markdown
Member

Thanks! The fix looks right. I confirmed the new non-indexed tests fail on main and pass on this branch. A couple of things before merge:

  1. Typecheck fails in src/utils/abi/parseEventLogs.test.ts at L620, L650 and L719 (TS2322). The topics from encodeEventTopics don't match decodeEventLog's topics param. The decodeEventLog sanity checks can be dropped, since the parseEventLogs assertions already cover this. Alternatively, pass topics: log.topics.
  2. Non-indexed bytes matching is case-sensitive. { data: '0xABCD' } doesn't match a decoded 0xabcd, while the indexed path does because hashing normalizes case. Consider comparing lowercased hex for non-indexed bytes, and add a test for it.
  3. Nit: the repo prefers toMatchInlineSnapshot() over toHaveLength/toBe for these assertions.

Generated by Claude Code

These calls fail typecheck, and the parseEventLogs assertions already cover the behavior.
Decoded bytes are lowercase, so a mixed-case filter never compared equal.
Cover mixed-case bytes filters with the inline snapshots used for stable results.
The inline pattern duplicated the existing bytes type check.
@mortezashojaei

Copy link
Copy Markdown
Contributor Author

Thanks! The fix looks right. I confirmed the new non-indexed tests fail on main and pass on this branch. A couple of things before merge:

  1. Typecheck fails in src/utils/abi/parseEventLogs.test.ts at L620, L650 and L719 (TS2322). The topics from encodeEventTopics don't match decodeEventLog's topics param. The decodeEventLog sanity checks can be dropped, since the parseEventLogs assertions already cover this. Alternatively, pass topics: log.topics.
  2. Non-indexed bytes matching is case-sensitive. { data: '0xABCD' } doesn't match a decoded 0xabcd, while the indexed path does because hashing normalizes case. Consider comparing lowercased hex for non-indexed bytes, and add a test for it.
  3. Nit: the repo prefers toMatchInlineSnapshot() over toHaveLength/toBe for these assertions.

Generated by Claude Code

Thanks for the review.

  1. Dropped the decodeEventLog checks. They were only sanity checks, and they failed typecheck.

  2. Non-indexed bytes filters now ignore hex case, so 0xABCD matches a decoded 0xabcd. Added a test for that. string stays case-sensitive.

  3. Those assertions now use toMatchInlineSnapshot().

Also covered bytes1 through bytes32. Those were not in the comment, but they have the same gap: they decode to lowercase hex and were compared with ===, so a mixed-case filter missed there too. Added a bytes32 test for it.

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.

2 participants