fix: suppress USD display on testnet networks #142

Merged
sneak merged 1 commits from fix/issue-139-testnet-usd-display into main 2026-03-01 20:31:45 +01:00

1 Commits

Author SHA1 Message Date
clawbot
c37ffcc864 fix: consolidate chain-switching into onChainSwitch()
All checks were successful
check / check (push) Successful in 13s
Introduces src/shared/chainSwitch.js with a single onChainSwitch()
function that handles every state change required when switching
networks:

- Updates networkId, rpcUrl, blockscoutUrl from network config
- Clears price caches (testnet tokens are worthless)
- Resets lastBalanceRefresh to force immediate refresh
- Clears per-address balances and token balances
- Clears tokenHolderCache and fraudContracts (chain-specific)
- Persists state

Both callers (settings UI dropdown, background
wallet_switchEthereumChain) now go through this single code path.
Adding a new chain (e.g. ETC) requires only a new entry in
networks.js with no per-caller wiring.

Also adds defense-in-depth testnet checks in prices.js (getPrice,
getAddressValueUsd, etc.) and fixes a hardcoded etherscan.io link
in addressToken.js to use the network-aware explorer URL.

Closes #139
2026-03-01 11:24:16 -08:00