feat: restrict the network selector to Ethereum/Base and their testnets - #1185
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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.
Preview deployment
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>
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.
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:
productionstagingtestinglocalHow
getEnvConfigs()is the single source the whole dapp derives its chain listfrom, so the filter is applied once at
envConfigsFilteredByEnvinsrc/lib/config.ts. That covers everything downstream:
NETWORK_SELECTOR_CHAINS)envChainIds→isSupportedChain()inlib/constants/chains.tsGQL_ENV_CHAINSfor the subgraph queriesgetConfigsByChainId()/useSelectChain/useSyncChainQueryChain ids are hardcoded in the map (as the existing
defaultChainIdPerEnvmapalready does) to avoid a circular import with
lib/constants/chains, whichreads
envChainIdsfromlib/config.The selector sorts by
getChainPriority, so the resulting order is Ethereumthen 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— cleaneslint+prettier --checkon the changed file — cleanNote
Lens is Polygon-only (
availableOnNetwork: [80001, 137]), so dropping Polygonmeans the Lens integration is no longer reachable from the dapp. Flagging it in
case that is not intended.
🤖 Generated with Claude Code