Skip to content

[#205] Shared RPC client with fallback transport#64

Merged
realproject7 merged 1 commit intomainfrom
task/205-rpc-client
Mar 14, 2026
Merged

[#205] Shared RPC client with fallback transport#64
realproject7 merged 1 commit intomainfrom
task/205-rpc-client

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Create lib/rpc.ts with shared public client for Base/Base Sepolia
  • Chain selected via NEXT_PUBLIC_CHAIN_ID (default: 84532 / Base Sepolia)
  • Fallback transport: tries NEXT_PUBLIC_RPC_URL first, falls back to chain default
  • Update lib/viem.ts to re-export from lib/rpc.ts for backward compatibility
  • Aligned with wagmi config (same env vars, same chain selection)

Test plan

  • tsc --noEmit passes
  • eslint passes
  • Existing imports from lib/viem still work
  • New code can import from lib/rpc directly

Fixes #205

🤖 Generated with Claude Code

- Create lib/rpc.ts: public client using NEXT_PUBLIC_CHAIN_ID to select
  Base or Base Sepolia, with fallback from NEXT_PUBLIC_RPC_URL to default RPC
- Update lib/viem.ts to re-export from lib/rpc.ts for backward compatibility
- Aligned with wagmi config (same env vars, same chain selection logic)

Fixes #205

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

T2b Review: APPROVED

Clean RPC client setup. Findings:

  1. Chain selectionNEXT_PUBLIC_CHAIN_ID with default 84532 (Base Sepolia). Consistent with wagmi config's approach from PR #58.
  2. Fallback transport — custom RPC with fallback to default public RPC when NEXT_PUBLIC_RPC_URL is set; plain http() otherwise. Good resilience pattern.
  3. Backward compatlib/viem.ts re-exports from lib/rpc.ts so existing imports don't break. Clean migration path.
  4. Singleton — module-level client instantiation ensures a single shared instance.
  5. CI green.

No issues found.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

This PR adds the shared RPC client foundation requested for P3-5 and keeps existing lib/viem imports working through a clean compatibility re-export. The repository check is passing.

Findings

  • None.

Decision

Approving because the new lib/rpc.ts aligns with the existing chain-selection env vars used by wagmi, preserves backward compatibility for current callers, and stays narrowly scoped to the requested RPC client foundation.

@realproject7 realproject7 merged commit 16bb954 into main Mar 14, 2026
1 check passed
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.

2 participants