Skip to content

feat: default the dapp to Base instead of Polygon - #1183

Merged
levalleux-ludo merged 2 commits into
mainfrom
feat/default-chain-base
Sep 8, 2026
Merged

feat: default the dapp to Base instead of Polygon#1183
levalleux-ludo merged 2 commits into
mainfrom
feat/default-chain-base

Conversation

@levalleux-ludo

Copy link
Copy Markdown
Member

What

On startup the dapp defaulted to Polygon — Amoy on testing/staging — because getEnvConfigs() lists the Polygon config first for every environment and defaultEnvConfig was simply envConfigsFilteredByEnv[0].

This picks the default config by an explicit per-environment chain id instead:

env default chain
local 31337 (local Hardhat)
testing 84532 (Base Sepolia)
staging 84532 (Base Sepolia)
production 8453 (Base)

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

defaultEnvConfig and the defaultChainId derived from it feed:

  • the initial ConfigProvider state (and therefore the Magic provider's chain),
  • the Network connector's defaultChainId,
  • WalletConnect v2's default chain,
  • the Coinbase Wallet connector's RPC url.

All of them move to Base with this one change. RPC urls and RPC_PROVIDERS entries already exist for both 84532 and 8453, and ChainId_BASE_SEPOLIA / ChainId.BASE are already in SUPPORTED_CHAINS, so no other wiring was needed.

Chain ids are hardcoded rather than imported from lib/constants/chains because that module reads envChainIds from lib/config — importing back would create a cycle.

Testing

  • npx tsc --noEmit — clean.
  • eslint src/lib/config.ts — clean.
  • Resolved the config for each env against the installed @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-0 has no entry in the local .env maps (testing-84532-0 does). The deployed values come from the REACT_APP_META_TX_API_KEY_MAP / REACT_APP_META_TX_API_IDS_MAP GitHub 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

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>
Copilot AI lite review requested due to automatic review settings September 8, 2026 14:00
@levalleux-ludo
levalleux-ludo requested a review from a team as a code owner September 8, 2026 14:00

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

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 defaultEnvConfig by 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.

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

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Preview deployment

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

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>
@levalleux-ludo
levalleux-ludo merged commit f15f6cb into main Sep 8, 2026
4 checks passed
@levalleux-ludo
levalleux-ludo deleted the feat/default-chain-base branch September 8, 2026 14:15
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