Skip to content

feat: restrict the network selector to Ethereum/Base and their testnets - #1185

Merged
levalleux-ludo merged 2 commits into
mainfrom
restrict-network-selector-chains
Sep 14, 2026
Merged

levalleux-ludo merged 2 commits into
mainfrom
restrict-network-selector-chains

Conversation

@levalleux-ludo

Copy link
Copy Markdown
Member

What

The network selector currently offers every chain the SDK supports for the
environment — Ethereum, Base, Polygon, Arbitrum and Optimism on production, and
their Sepolia/Amoy counterparts on testing/staging. This restricts it to:

Environment Chains offered
production Ethereum (1), Base (8453)
staging Sepolia (11155111), Base Sepolia (84532)
testing Sepolia (11155111), Base Sepolia (84532)
local Local Hardhat (31337), unchanged

How

getEnvConfigs() is the single source the whole dapp derives its chain list
from, so the filter is applied once at envConfigsFilteredByEnv in
src/lib/config.ts. That covers everything downstream:

  • the network selector dropdown (NETWORK_SELECTOR_CHAINS)
  • the "Connect to …" tooltip in the wallet status
  • envChainIdsisSupportedChain() in lib/constants/chains.ts
  • GQL_ENV_CHAINS for the subgraph queries
  • getConfigsByChainId() / useSelectChain / useSyncChainQuery

Chain ids are hardcoded in the map (as the existing defaultChainIdPerEnv map
already does) to avoid a circular import with lib/constants/chains, which
reads envChainIds from lib/config.

The selector sorts by getChainPriority, so the resulting order is Ethereum
then Base on production, Sepolia then Base Sepolia on testing/staging.

Defaults are unaffected: the dapp still starts on Base / Base Sepolia.

Checks

  • npx tsc --noEmit — clean
  • eslint + prettier --check on the changed file — clean
  • unit tests — 44 passed, 3 suites
  • verified the filtered output per environment against the SDK configs:
    local       all: 31337                               => local-31337-0
    testing     all: 84532,11155111,80002,11155420,421614 => testing-84532-0, testing-11155111-0
    staging     all: 84532,11155111,80002,11155420,421614 => staging-84532-0, staging-11155111-0
    production  all: 8453,1,137,10,42161                  => production-8453-0, production-1-0
    

Note

Lens is Polygon-only (availableOnNetwork: [80001, 137]), so dropping Polygon
means the Lens integration is no longer reachable from the dapp. Flagging it in
case that is not intended.

🤖 Generated with Claude Code

getEnvConfigs() returns every chain the SDK supports for an environment, and
the whole dapp derives its chain list from it: the network selector, the
"connect to" tooltip in the wallet status, isSupportedChain() and the
subgraph chain list. Filter it once in lib/config so the selector offers only
Ethereum and Base on production, and Sepolia and Base Sepolia on
testing/staging. Local keeps its single Hardhat chain.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 14, 2026 08:10
@levalleux-ludo
levalleux-ludo requested a review from a team as a code owner September 14, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

An invalid (but truthy) REACT_APP_ENV_NAME value can cause a runtime crash at import time due to supportedChainIds being undefined and .includes(...) being called on it.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR restricts the dapp’s network selector (and all downstream chain-derived behavior) to only Ethereum/Base and their testnets by filtering the SDK-provided environment configs in a single place (envConfigsFilteredByEnv).

Changes:

  • Added an environment-scoped allowlist of supported chain IDs and filtered getEnvConfigs(envName) accordingly.
  • Improved the “no protocol config available” error to include the filtered chain IDs.
  • Clarified the default-chain comment to reflect that the default is explicitly pinned rather than relying on config ordering.
File summaries
File Description
src/lib/config.ts Adds per-environment supported chain allowlist and filters env configs to restrict selectable/usable networks.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/config.ts Outdated
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

Preview deployment

View URL
dApp https://d09f9761.interface-a9d.pages.dev/#/dapp
DR Center https://d09f9761.interface-a9d.pages.dev/#/dr_center

Built from 9668a65.

envName is an unchecked `as EnvironmentType` cast of an env var, so an
unexpected value made supportedChainIdsPerEnv[envName] undefined. In practice
getEnvConfigs() is evaluated before the .filter() callback and throws first, so
the app did fail fast — but on the SDK's internal ordering rather than on
anything this module guarantees. Check the lookup explicitly and throw a
message that names the accepted values.

Addresses PR #1185 review comment r4003308542.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@levalleux-ludo
levalleux-ludo merged commit 1a5c45e into main Sep 14, 2026
5 checks passed
@levalleux-ludo
levalleux-ludo deleted the restrict-network-selector-chains branch September 14, 2026 08:38
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