Skip to content

fix: preserve leading zeros in ENS EVM address fallback - #5442

Merged
jxom merged 5 commits into
mainfrom
fix/ens-evm-address-leading-zeros
Nov 8, 2026
Merged

jxom merged 5 commits into
mainfrom
fix/ens-evm-address-leading-zeros

Conversation

@jxom

@jxom jxom commented Nov 8, 2026

Copy link
Copy Markdown
Member

Supersedes #5436 by @mortezashojaei. This keeps their commits and adds one commit that extends the fix to EVM chain coin types.

getEnsAddress has a fallback for offchain resolvers that answer addr(bytes32,uint256) with an address instead of dynamic bytes. The fallback trimmed leading zeros and then required 20 bytes. As a result, it rejected valid addresses that start with zero bytes, and it threw for the zero address instead of returning null.

#5436 restored the zeros for coinType: 60n. This PR applies the same padding to ENSIP-11 EVM chain coin types (0x80000000n through 0xffffffffn, including the ENSIP-19 default). Those coin types also use 20-byte addresses: without leading zeros they already resolved, but with leading zeros they still threw. Other coin types decode as before.

Responses are padded only when they are 20 or 32 bytes long and trim to fewer than 20 bytes. This means a single 32-byte word below 2^160 now resolves to an address for these coin types instead of throwing.

Tests cover 60n, both ends of the EVM range, and toCoinType(10), each with ABI-encoded and raw responses. Non-EVM coin types just outside the range (501n, 0x7fffffffn, 0x100000000n) keep their existing errors.

@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
viem Error Error Nov 8, 2026 6:31pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6f6e0be

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

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T18:28:56.646806Z 6f6e0be 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.

@jxom
jxom merged commit a960ce1 into main Nov 8, 2026
39 of 40 checks passed
@jxom
jxom deleted the fix/ens-evm-address-leading-zeros branch November 8, 2026 18:28
@github-actions github-actions Bot mentioned this pull request Nov 8, 2026

This branch had an error being deployed

1 failed deployment
Preview — 6f6e0be0 Deployed Nov 8, 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.

3 participants