Skip to content

fix: accept readonly arrays in LogTopic type#4455

Open
nikicat wants to merge 1 commit intowevm:mainfrom
nikicat:fix/readonly-log-topic-upstream
Open

fix: accept readonly arrays in LogTopic type#4455
nikicat wants to merge 1 commit intowevm:mainfrom
nikicat:fix/readonly-log-topic-upstream

Conversation

@nikicat
Copy link
Copy Markdown

@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

⚠️ No Changeset found

Latest commit: 729e91c

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

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

1 participant