Gate play on Base Sepolia and offer one-click network switch - #67
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🧪 Coverage
|
heyradcode
marked this pull request as ready for review
July 25, 2026 15:06
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.
Why
A wallet on any network other than Base Sepolia left the app in a dead state
with no way out:
nullwheneveruseAccount().chainwasundefined, which is exactly the state an unsupported network puts it in. The
one control that could switch back was hidden.
useBalance({ address })targeted a chain wagmi had no transport for.
Hardhat Localsat first inCHAINS, and wagmi treatschains[0]as itsdefault, so hosted builds fell back to
http://localhost:8545for RPC readsbefore a wallet reported a usable chain.
MetaMask defaults to Ethereum Mainnet, so a new player hit all three at once.
What changed
Chain list (
constants/chains/ethereum.ts)import.meta.env.DEV.offering them let a player switch to a network where every read silently
fails.
TARGET_CHAIN_ID(fromVITE_EVM_CHAIN_ID, default 84532) andisSupportedChain(). DeclaredVITE_EVM_CHAIN_IDinvite-env.d.ts, whereit was already being read but undeclared.
Network switcher
chainId(raw, defined whenever connected) instead ofchain(only set for configured chains), so it stays visible and reads
"Wrong network".
New
NetworkGateswitchChainsendswallet_switchEthereumChain; wagmi's injected connectorretries with
wallet_addEthereumChainon MetaMask error 4902, so a player whohas never added Base Sepolia gets the add prompt from the same button.
primaryWallet.switchNetwork()when the wagmi bridgeisn't connected yet.
never see it.
Testing
pnpm --filter frontend lint:check,test, andbuildall pass(42 files / 281 tests).
Two existing test files covered the changed API and were updated; 11 tests were
failing against the old
getChainsByTypehelpers andchainmock. Added aregression test that the switcher stays visible on an unsupported chain, plus
six tests for the gate covering the Dynamic fallback and the rejection path.