From a5ca08a5ab1b41c02f917c59885778895c3d365c Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Tue, 8 Sep 2026 14:58:47 +0100 Subject: [PATCH 1/2] feat: default the dapp to Base instead of Polygon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/lib/config.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/config.ts b/src/lib/config.ts index af4f7fd97..06bc250e0 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -100,7 +100,23 @@ export const envConfigsFilteredByEnv: ProtocolConfig[] = getEnvConfigs(envName); export const envChainIds = envConfigsFilteredByEnv.map( (envConf) => envConf.chainId ); -export const defaultEnvConfig: ProtocolConfig = envConfigsFilteredByEnv[0]; + +// Chain the dapp starts on, per environment. getEnvConfigs() lists the Polygon +// config first, so without this the app would default to Polygon (Amoy on +// testing/staging). Chain ids are hardcoded rather than imported from +// lib/constants/chains to avoid a circular import (that module reads +// envChainIds from here). +const defaultChainIdPerEnv: Record = { + local: 31337, // Local Hardhat + testing: 84532, // Base Sepolia + staging: 84532, // Base Sepolia + production: 8453 // Base +}; + +export const defaultEnvConfig: ProtocolConfig = + envConfigsFilteredByEnv.find( + (envConf) => envConf.chainId === defaultChainIdPerEnv[envName] + ) ?? envConfigsFilteredByEnv[0]; export const defaultChainId = defaultEnvConfig.chainId; export const CONFIG = { From dfa3eca2b97eaf3fed96769a6fafece2f306d64b Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Tue, 8 Sep 2026 15:12:57 +0100 Subject: [PATCH 2/2] fix(config): fail fast when an environment has no protocol config 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 --- src/lib/config.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/config.ts b/src/lib/config.ts index 06bc250e0..63412d1da 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -97,6 +97,11 @@ function getMetaTxApiKey(envConfig: ProtocolConfig) { } export const envConfigsFilteredByEnv: ProtocolConfig[] = getEnvConfigs(envName); +if (!envConfigsFilteredByEnv.length) { + // Fail fast with context: everything below assumes at least one config, and + // without this the app would crash later on an undefined defaultEnvConfig. + throw new Error(`No protocol config is available for envName ${envName}`); +} export const envChainIds = envConfigsFilteredByEnv.map( (envConf) => envConf.chainId );