Skip to content

fix: use configured rpc for ENS lookups#2392

Open
samsamtrum wants to merge 1 commit into
thirdweb-dev:developfrom
samsamtrum:fix-ens-custom-rpc
Open

fix: use configured rpc for ENS lookups#2392
samsamtrum wants to merge 1 commit into
thirdweb-dev:developfrom
samsamtrum:fix-ens-custom-rpc

Conversation

@samsamtrum
Copy link
Copy Markdown

@samsamtrum samsamtrum commented May 23, 2026

Fixes ENS lookups so the viem HTTP transport uses the RPC URL configured for the chain.

Previously getProvider created the public client with bare http(), so ENS resolution could fall back to viem's default RPC endpoint even when the chain config provided an RPC URL.

Changed:

  • pass chain.rpcUrl || chain.publicRpcUrl into http(...)
  • cache viem providers by the selected RPC URL, falling back to publicRpcUrl or chain.id when needed

Checked with:

  • npm exec --yes prettier@2.8.8 -- --check packages/core/src/provider.ts
  • static assertions that getProvider no longer uses bare http() and now passes the configured RPC URL

Closes #2356.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Walkthrough

The getProvider function is updated to cache viem PublicClient instances with improved RPC URL handling. A new getProviderCacheKey helper prioritizes chain.rpcUrl, falls back to chain.publicRpcUrl, and uses chain.id as a final fallback, ensuring clients are cached and retrieved consistently. When creating new clients, the HTTP transport is now explicitly configured with the resolved RPC URL.

Changes

Provider Caching with RPC URL Fallback

Layer / File(s) Summary
Cache key fallback and explicit HTTP transport
packages/core/src/provider.ts
New getProviderCacheKey(chain) helper computes cache keys using prioritized fallback (rpcUrl → publicRpcUrl → id). getProvider now uses this key for client instance caching and explicitly passes the resolved RPC URL to the viem HTTP transport instead of relying on default behavior.

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description lacks clarity on which checklist items from the repository template were completed, making full assessment difficult. Add explicit checklist completion status and clarify whether documentation updates, version bumps, and local testing were performed as required by the repository template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: using the configured RPC URL for ENS lookups instead of falling back to viem's default transport.
Linked Issues check ✅ Passed The code changes fully address issue #2356 by ensuring ENS lookups use configured RPC URLs with proper fallback logic and caching based on the selected RPC endpoint.
Out of Scope Changes check ✅ Passed All changes in provider.ts are directly scoped to fixing the ENS RPC configuration issue described in #2356, with no extraneous modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

getEns doesn't pick up rpcUrl from chain configuration

1 participant