Skip to content

fix: accept readonly arrays in LogTopic type#4455

Merged
jxom merged 2 commits intowevm:mainfrom
nikicat:fix/readonly-log-topic-upstream
Apr 21, 2026
Merged

fix: accept readonly arrays in LogTopic type#4455
jxom merged 2 commits intowevm:mainfrom
nikicat:fix/readonly-log-topic-upstream

Conversation

@nikicat
Copy link
Copy Markdown
Contributor

@nikicat nikicat commented Apr 3, 2026

Summary

LogTopic is changed from Hex | Hex[] | null to Hex | readonly Hex[] | null. Since readonly T[] is a supertype of T[], this accepts both mutable and readonly arrays.

LogTopicType conditional is updated correspondingly: it now matches readonly Hex[] (which includes Hex[]) and produces readonly primitiveType[].

Motivation

TypeScript's readonly T[] is not assignable to T[]. Users who define topic arrays with as const or receive them from functions returning readonly arrays get type errors when passing them to getLogs, createEventFilter, watchEvent, etc.

Log topic filters are read-only by nature — they're passed to JSON-RPC calls and never mutated — so accepting readonly arrays is both correct and expected.

This is a non-breaking change: all existing mutable-array code continues to work since T[] is assignable to readonly T[].

Related discussions

Test plan

  • All 51 type test files pass (343 tests, no type errors)

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 3, 2026

@nikicat 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 3, 2026

🦋 Changeset detected

Latest commit: eb2eec6

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

LogTopic now includes `readonly Hex[]` so that `as const` and readonly
arrays are assignable to topic filters without type errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nikicat nikicat force-pushed the fix/readonly-log-topic-upstream branch from 40034a0 to 729e91c Compare April 3, 2026 14:52
@nikicat
Copy link
Copy Markdown
Contributor Author

nikicat commented Apr 19, 2026

Friendly ping — this has been open for about two weeks without a review. No rush, just want to make sure it hasn't slipped through. Happy to rebase or adjust anything if needed. Thanks!

@jxom jxom merged commit c0c09a6 into wevm:main Apr 21, 2026
1 check failed
@github-actions github-actions Bot mentioned this pull request Apr 21, 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.

2 participants