Skip to content

fix: support anonymous events in AbiEvent.decode and encode - #565

Merged
jxom merged 1 commit into
0.xfrom
jxom/anonymous-event-logs-0.x
Nov 2, 2026
Merged

jxom merged 1 commit into
0.xfrom
jxom/anonymous-event-logs-0.x

Conversation

@jxom

@jxom jxom commented Nov 2, 2026

Copy link
Copy Markdown
Member

Backport to 0.x of the anonymous-event support that main got in v1 (#231). Related: #564 and wevm/viem#5375.

Anonymous events have no selector topic. On 0.x:

  • decode read topics[0] as the selector, so it threw SelectorTopicMismatchError for every anonymous log.
  • encode prepended a selector that an anonymous log never carries.

Now, for anonymous events, decode reads every topic as an indexed input, and encode returns the indexed topics alone, as on main. Normal events are unchanged.

const message = AbiEvent.from({
  anonymous: true,
  inputs: [
    { indexed: false, name: 'note', type: 'string' },
    { indexed: true, name: 'from', type: 'address' },
  ],
  name: 'Message',
  type: 'event',
})

AbiEvent.encode(message, { from }) // { topics: [fromTopic] }, no selector
AbiEvent.decode(message, { data, topics: [fromTopic] }) // { from, note }

Type change: encode.ReturnType['topics'] widens from [selector, ...topics] to also allow topics without a selector, matching main. Code that reads topics[0] as a guaranteed selector now sees a possibly-undefined value under noUncheckedIndexedAccess.

0.x has no extractLogs or decodeLog, so the opt-in matching from #564 doesn't apply here. 0.x also has no fuzz setup (no fast-check), so this PR adds deterministic tests only: anonymous decode with and without indexed inputs, a missing topic, encode, and an encode → decode round trip.

Validation: the AbiEvent unit tests pass except the 2 network tests, which need anvil (not available locally). tsc --noEmit and Biome pass.


Generated by Claude Code

Anonymous events have no selector topic. `decode` threw
`SelectorTopicMismatchError` for every anonymous log, because it read
`topics[0]` as the selector, and `encode` prepended a selector that an
anonymous log never carries. `decode` now reads every topic as an indexed
input for anonymous events, and `encode` returns the indexed topics alone,
as on `main`. `encode.ReturnType` widens to allow topics without a selector.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D3nmWga38V3yjkJET3UZeh
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ox Ready Ready Preview Nov 2, 2026 2:32am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T02:25:09.922946Z 711401e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-565 dist-tag, which follows this pull request until it closes.

pnpm add ox@pr-565
pnpm add [email protected]

@jxom
jxom merged commit 20457a6 into 0.x Nov 2, 2026
14 checks passed
@jxom
jxom deleted the jxom/anonymous-event-logs-0.x branch November 2, 2026 02:47
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
gakonst added a commit to tempoxyz/accounts that referenced this pull request Nov 3, 2026
Updates `ox` from 0.14.59 to 0.14.62 (`legacy-v0`, published
2026-11-03T04:23:31Z). The catalog, the override and the package's own
dependency range all change. The range goes from `~0.14.59` to
`~0.14.62`, so this adds a patch changeset. Follows #943, which updated
Viem.

## What 0.14.62 brings

- wevm/ox#571 backports #569 and #570:
- `Hex.assert`, `Value`, `TypedData`, `Siwe.isUri` and ABI overload
resolution reuse module-level regular expressions instead of building
new ones on every call.
- `AbiItem.getSignatureHash` and `AbiItem.getSelector` cache signature
hashes in a bounded cache that `Caches.clear` resets. So do the selector
lookups in `AbiItem.fromAbi`, `AbiFunction.decodeData`,
`AbiEvent.decodeLog` and `AbiEvent.extractLogs`.
- wevm/ox#565: `AbiEvent.decode` and `AbiEvent.encode` handle anonymous
events.

The range also picks up 0.14.60 and 0.14.61. The `eth_fillTransaction`
result `tx` is now typed as a `OneOf` union. `AbiItem.fromAbi` throws
`AmbiguityError` for overloads it can't tell apart.
`AbiParameters.decode` checks integer ranges and address padding.
Envelope `assert` rejects a tip above a zero `maxFeePerGas`. `TypedData`
validates types more strictly. `KeyAuthorization` `isAdmin` is
deprecated for TIP-1137. None of these needed changes here, and every
suite passes unchanged.

## Lockfile

As in #943, the lockfile is edited directly, because a full resolution
adds a real `[email protected]` peer. Only the `ox` entries change: the
version, the integrity, and the specifiers set by the override. `ox`
0.14.62 has the same dependencies as 0.14.59. It isn't a peer of any
package, so no hashed peer suffix includes it. `ox` is excluded from
`minimumReleaseAge`.

## Validation

- `pnpm install --frozen-lockfile` from empty `node_modules`: passed.
- `pnpm check:types`: passed.
- `pnpm check`: 0 errors; the 5 warnings are already on `main`.
- `pnpm build`: passed.
- `pnpm test --project lib/pure --reporter=dot`: 50 files, 889 tests
passed.
- `VITE_NODE_ENV=localnet VITE_NODE_TAG=latest pnpm test --project
lib/localnet --reporter=dot --maxWorkers=4` against
`ghcr.io/tempoxyz/tempo:latest` in OrbStack: 10 files, 658 tests passed.

This branch was successfully deployed

1 active deployment
Preview — 711401ea Deployed Nov 2, 2026 by vercel[bot]
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