Skip to content

[SDK] Fix: resolveL2Name cache key ignores the resolver chain - #9088

Open
creativityventures wants to merge 3 commits into
thirdweb-dev:mainfrom
creativityventures:patch-1
Open

creativityventures wants to merge 3 commits into
thirdweb-dev:mainfrom
creativityventures:patch-1

Conversation

@creativityventures

@creativityventures creativityventures commented Dec 2, 2026 •

Copy link
Copy Markdown

resolveL2Name (packages/thirdweb/src/extensions/ens/resolve-l2-name.ts) built its cache key as ens:name:${resolverChain}:${address}. resolverChain is a Chain object, so the key was ens:name:[object Object]:0x… for every chain and resolver. Resolving the same address on Base and then on Base Sepolia (or any other L2 resolver) within the 1 minute cache window returned the first chain's name, e.g. a mainnet Basename on Base Sepolia.

The key now uses the chain id and the resolver address. A changeset (thirdweb: patch) is included.

Notes for the reviewer

resolveName and resolveAddress already use resolverChain?.id in their keys; this aligns resolveL2Name with them.

How to test

New resolve-l2-name-cache.test.ts (the resolver name read is mocked): it resolves the same address on Base and Base Sepolia and expects two different names. It fails on main ("expected 'mainnet.base.eth' to be 'testnet.basetest.eth'") and passes with the fix. biome check passes on the changed files, and tsc -p tsconfig.build.json reports no error in extensions/ens (I only had the thirdweb package installed, so errors from other workspace packages were expected). Not run: the full test suite.

This change was written with help from an AI assistant (Claude Code) and reviewed before submitting.

🤖 Generated with Claude Code

https://claude.ai/code/session_014cRzwuyJe8BGwXowsQ3kpw

Summary by CodeRabbit

  • Bug Fixes
    • Fixed name resolution caching across Base and Base Sepolia, preventing a result from one network from being returned for the other.

resolveL2Name built its cache key as `ens:name:${resolverChain}:${address}`.
`resolverChain` is an object, so the key became
`ens:name:[object Object]:0x...` for every chain and resolver. Resolving
the same address on Base and then on Base Sepolia (or any other L2
resolver) within the 1 minute cache window returned the first chain's
name.

The key now uses the chain id and the resolver address.

Tested: new resolve-l2-name-cache.test.ts (resolver read mocked) fails
on main ("expected 'mainnet.base.eth' to be 'testnet.basetest.eth'")
and passes with the fix.

Co-authored-by: Claude <noreply@anthropic.com>

Signed-off-by: creativityventures.eth <creativityventures.official@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>

Signed-off-by: creativityventures.eth <creativityventures.official@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>

Signed-off-by: creativityventures.eth <creativityventures.official@gmail.com>
@creativityventures
creativityventures requested review from a team as code owners December 2, 2026 19:28
@changeset-bot

changeset-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f11e2bb

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

This PR includes changesets to release 3 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp 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 Dec 2, 2026

Copy link
Copy Markdown

@creativityventures is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added packages SDK Involves changes to the thirdweb SDK labels Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

resolveL2Name now includes the resolver chain ID and resolver address in its cache key. A test checks resolution on Base and Base Sepolia. A changeset declares a patch release.

Changes

L2 name cache

Layer / File(s) Summary
Cache key and cross-chain validation
packages/thirdweb/src/extensions/ens/resolve-l2-name.ts, packages/thirdweb/src/extensions/ens/resolve-l2-name-cache.test.ts, .changeset/l2-name-cache-key.md
The cache key now includes the resolver chain ID and resolver address. The test resolves the same address on Base and Base Sepolia, checks for distinct names, and expects two resolver reads. The changeset declares a patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: 0xfirekeeper

Merge Risk: Minimal · up to f11e2

This fixes a bug where a name resolved on one L2 chain could be returned for another for up to a minute. The change is small and covered by a regression test, with no public API change. It looks ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the resolveL2Name cache key ignored the resolver chain, and the fix is a SDK fix. It follows the repository format of a [SDK] prefix with a Fix label. It is specific a…
Description check Passed The description covers the problem, the fix, the reviewer notes, and how to test. It uses the repository headings for notes and testing. It omits the Linear issue tag line from the template, and it do…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the resolveL2Name cache key ignored the resolver chain, and the fix is a SDK fix. It follows the repository format of a [SDK] prefix with a Fix label. It is specific and concise.

Full details: Description check

Explanation

The description covers the problem, the fix, the reviewer notes, and how to test. It uses the repository headings for notes and testing. It omits the Linear issue tag line from the template, and it does not state the title format's Linear reference. The core content is complete, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f07aa00-fe61-4609-b151-1a602c7df340
Commits

Reviewing files that changed from the base of the PR and between 0619d88 and f11e2bb.

Files selected for processing: 3

  • .changeset/l2-name-cache-key.md
  • packages/thirdweb/src/extensions/ens/resolve-l2-name-cache.test.ts
  • packages/thirdweb/src/extensions/ens/resolve-l2-name.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant