feat: default the dapp to Base instead of Polygon - #1183
Merged
Conversation
getEnvConfigs() returns the Polygon config first for every environment, so defaultEnvConfig (and the defaultChainId derived from it, used by the network connector, WalletConnect, Coinbase Wallet and the initial ConfigProvider state) resolved to Polygon — Amoy on testing/staging. Pick the config by an explicit per-environment chain id instead: Base Sepolia on testing/staging, Base on production, local Hardhat on local. Falls back to the first config if the preferred chain is not part of the environment. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The updated default selection still allows defaultEnvConfig to become undefined if getEnvConfigs(envName) returns an empty array, leading to an immediate startup crash with an unclear error.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the dapp’s startup default network selection so each environment deterministically defaults to Base (or local Hardhat), instead of implicitly defaulting to the first getEnvConfigs() entry (Polygon/Amoy).
Changes:
- Introduces an explicit per-environment default chain-id mapping (
defaultChainIdPerEnv). - Selects
defaultEnvConfigby preferred chain id with a safe fallback to the first available env config.
File summaries
| File | Description |
|---|---|
src/lib/config.ts |
Picks the default protocol config by an explicit per-environment chain id (Base/Base Sepolia/local Hardhat), with fallback behavior. |
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 dfa3eca. |
getEnvConfigs() throws for an unknown envName, but a known env with an empty config list would return []. defaultEnvConfig would then be undefined and the app would crash on defaultEnvConfig.chainId with no indication of the cause. Throw at module load with the envName instead, matching how the file already handles missing REACT_APP_* values. This also makes envConfigsFilteredByEnv[0] a sound fallback for the preferred-chain lookup. Addresses PR #1183 review comment r3958708556. Co-Authored-By: Claude Opus 5 <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
On startup the dapp defaulted to Polygon — Amoy on testing/staging — because
getEnvConfigs()lists the Polygon config first for every environment anddefaultEnvConfigwas simplyenvConfigsFilteredByEnv[0].This picks the default config by an explicit per-environment chain id instead:
It falls back to the first config if the preferred chain is not part of the environment, so the app can't fail to boot on a config list that drops Base.
Why it covers the whole startup path
defaultEnvConfigand thedefaultChainIdderived from it feed:ConfigProviderstate (and therefore the Magic provider's chain),Networkconnector'sdefaultChainId,All of them move to Base with this one change. RPC urls and
RPC_PROVIDERSentries already exist for both 84532 and 8453, andChainId_BASE_SEPOLIA/ChainId.BASEare already inSUPPORTED_CHAINS, so no other wiring was needed.Chain ids are hardcoded rather than imported from
lib/constants/chainsbecause that module readsenvChainIdsfromlib/config— importing back would create a cycle.Testing
npx tsc --noEmit— clean.eslint src/lib/config.ts— clean.@bosonprotocol/common:local-31337-0,testing-84532-0,staging-84532-0,production-8453-0.Note for reviewers
Meta-transaction config is keyed by
configId.staging-84532-0has no entry in the local.envmaps (testing-84532-0does). The deployed values come from theREACT_APP_META_TX_API_KEY_MAP/REACT_APP_META_TX_API_IDS_MAPGitHub secrets, so please check those cover Base before this reaches staging — otherwise staging loses meta-tx on the new default chain.🤖 Generated with Claude Code