Skip to content

fix: pass explicit RPC transports to wagmi config#665

Open
rickstaa wants to merge 2 commits into
mainfrom
fix/wagmi-rpc-transports
Open

fix: pass explicit RPC transports to wagmi config#665
rickstaa wants to merge 2 commits into
mainfrom
fix/wagmi-rpc-transports

Conversation

@rickstaa
Copy link
Copy Markdown
Member

@rickstaa rickstaa commented May 7, 2026

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

  • `pnpm typecheck` passes
  • `pnpm lint` passes
  • `pnpm format:check` passes
  • CI green
  • On the Vercel preview, `/migrate/orchestrator`, `/migrate/delegator`, `/migrate/broadcaster` no longer flood the console with `eth.merkle.io` CORS errors
  • Wallet button is visible and clickable in the header on migrate routes
  • L1 contract reads (e.g. `useL1DelegatorData`) successfully populate state

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>
Copilot AI review requested due to automatic review settings May 7, 2026 19:09
@rickstaa rickstaa requested a review from ECWireless as a code owner May 7, 2026 19:09
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

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

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment May 12, 2026 8:45am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_URLS and constructs a transports map for getDefaultConfig using viem’s http() + 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Triage

Development

Successfully merging this pull request may close these issues.

bug: wagmi config missing transports causes migrate pages to use viem default RPC (eth.merkle.io)

2 participants