fix: pass explicit RPC transports to wagmi config#665
Open
rickstaa wants to merge 2 commits into
Open
Conversation
components/Web3Providers/index.tsx was calling getDefaultConfig without a transports field, so wagmi fell back to viem's per-chain default RPCs. For mainnet that default is https://eth.merkle.io, which does not return CORS headers from the production origin and rate-limits aggressively. Every L1 read in the browser failed with CORS errors, the resulting viem retry storm prevented RainbowKit's <ConnectButton.Custom> from settling its mounted flag, and the wallet button rendered with opacity: 0 on the migrate routes (which are the only routes that target L1). The regression was introduced in #354 when the project migrated wagmi v1 to v2 and the v1 infuraProvider wiring was removed without a replacement. NEXT_PUBLIC_INFURA_KEY remained in lib/chains.ts but was only consumed by Apollo and the standalone l1PublicClient/l2PublicClient, never by the wagmi config. Reuse the existing NETWORK_RPC_URLS list from lib/chains.ts so wagmi, Apollo, and the standalone viem clients all share one RPC source of truth, and the same NEXT_PUBLIC_INFURA_KEY / NEXT_PUBLIC_L1_RPC_URL / NEXT_PUBLIC_L2_RPC_URL env vars cover all three. Closes #664 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Restores explicit RPC transport configuration for the RainbowKit/wagmi setup so browser-side contract reads use the project’s configured RPC URLs (Infura and NEXT_PUBLIC_L1_RPC_URL / NEXT_PUBLIC_L2_RPC_URL fallbacks) instead of viem per-chain defaults.
Changes:
- Imports
NETWORK_RPC_URLSand constructs atransportsmap forgetDefaultConfigusingviem’shttp()+fallback()transport composition.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+44
to
50
| transports: Object.fromEntries( | ||
| chains.map((c) => [ | ||
| c.id, | ||
| fallback((NETWORK_RPC_URLS[c.id] ?? []).map((url) => http(url))), | ||
| ]) | ||
| ), | ||
| wallets: [ |
components/ConnectButton/index.tsx passed chainStatus="none" to the RainbowKit wrapper. In RainbowKit v2 that flag applies display:none to the chain-selector slot — the same slot that renders the red "Wrong network" pill on chain mismatch. Combined with RainbowKit's render guard (!unsupportedChain && <AccountButton/>), the whole ConnectButton rendered empty whenever the wallet was on the off-route chain, and the alert never appeared. Use chainStatus="icon" instead: compact on a supported chain, red "Wrong network" pill on mismatch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0a08ec2 to
df7c3eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restore explicit RPC transports for wagmi so contract reads route through the project's configured Infura URLs (and `NEXT_PUBLIC_L1_RPC_URL` / `NEXT_PUBLIC_L2_RPC_URL` fallbacks) instead of viem's per-chain defaults.
Problem
`components/Web3Providers/index.tsx` called `getDefaultConfig` without a `transports` field. With no transports, wagmi falls back to viem's default chain RPCs — for `mainnet` that is `https://eth.merkle.io\`, which does not return CORS headers from the production origin. Every L1 read in the browser failed with CORS errors, triggering an open-ended viem retry storm that prevented RainbowKit's `<ConnectButton.Custom>` `mounted` flag from settling. The wallet button on migrate routes (the only routes that target L1) rendered with `opacity: 0`, and migrate flows could not load delegator state.
The regression was introduced in #354 (wagmi v1 → v2 upgrade). The v1 `infuraProvider({ apiKey: INFURA_KEY })` wiring was removed and never replaced. `NEXT_PUBLIC_INFURA_KEY` remained in `lib/chains.ts` but was only consumed by Apollo and the standalone `l1PublicClient` / `l2PublicClient`, never by the wagmi config — so setting that env var in Vercel did not help.
Fix
Pass an explicit `transports` map to `getDefaultConfig`, reusing the existing `NETWORK_RPC_URLS` list from `lib/chains.ts`. This way wagmi, Apollo, and the standalone viem clients share a single RPC source of truth, and the same `NEXT_PUBLIC_INFURA_KEY` / `NEXT_PUBLIC_L1_RPC_URL` / `NEXT_PUBLIC_L2_RPC_URL` env vars cover all three.
```ts
transports: Object.fromEntries(
chains.map((c) => [
c.id,
fallback((NETWORK_RPC_URLS[c.id] ?? []).map((url) => http(url))),
]),
),
```
Closes #664
Test plan