fix: tracked tokens are kept per network, and bundled picks are offered on mainnet only (closes #523)
A network switch now puts the outgoing network's tracked tokens away in a new persisted field, networkTrackedTokens, and brings back the incoming network's list, or an empty one, the way endpoints are already kept per network. trackedTokens stays the active network's list, so its readers are unchanged, and the background's switch keeps the lists too because it goes through the same function. The two add-token screens show their common-token picks, which come from the bundled list of mainnet contracts, on Ethereum Mainnet only; adding by contract address works on every network. Settings redraws its tracked-token list after a switch. Model: opus-5-5
This commit is contained in:
@@ -38,6 +38,16 @@ function applyChainSwitchFields(s, newNetworkId) {
|
||||
blockscoutUrl: s.blockscoutUrl,
|
||||
};
|
||||
const remembered = s.networkEndpoints[net.id] || {};
|
||||
|
||||
// Tracked tokens are kept per network the same way, because a contract
|
||||
// address names a token on one network only. s.trackedTokens stays the
|
||||
// active network's list, so nothing that reads it changes: the outgoing
|
||||
// list is put away under its network, and the incoming network's list, or
|
||||
// an empty one, takes its place.
|
||||
if (!s.networkTrackedTokens) s.networkTrackedTokens = {};
|
||||
s.networkTrackedTokens[s.networkId] = s.trackedTokens;
|
||||
s.trackedTokens = s.networkTrackedTokens[net.id] || [];
|
||||
|
||||
s.networkId = net.id;
|
||||
s.rpcUrl = remembered.rpcUrl || net.defaultRpcUrl;
|
||||
s.blockscoutUrl = remembered.blockscoutUrl || net.defaultBlockscoutUrl;
|
||||
|
||||
Reference in New Issue
Block a user