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 kept per network. trackedTokens stays the active network's list, so its readers are unchanged, and the background's switch goes through the same function. The two add-token screens offer their common-token picks, which are mainnet contracts, on Ethereum Mainnet only. After a switch in Settings, Back finds the screens beneath as a reopened popup does: it renders the one it lands on for the new network, and the stack is cut at the first screen that cannot be rendered from saved state. Model: opus-5-5
This commit is contained in:
@@ -97,6 +97,7 @@ const {
|
||||
normalizePersisted,
|
||||
} = require("../src/shared/persistedState");
|
||||
const { stateProblem } = require("../src/shared/stateSchema");
|
||||
const { isKnownNetworkId } = require("../src/shared/networks");
|
||||
const { RESTORABLE_VIEWS } = require("../src/shared/restorableViews");
|
||||
const {
|
||||
bootPopup,
|
||||
@@ -193,6 +194,29 @@ const CONTRACT = [
|
||||
floorOnly: [[1, 2], [null], [{}], [[TOKEN_ADDRESS]]],
|
||||
holds: (v) => everyEntry(v, (t) => isRecord(t) && isText(t.address)),
|
||||
},
|
||||
{
|
||||
field: "networkTrackedTokens",
|
||||
kind: KIND.ENTRIES,
|
||||
hostile: [42, "notarecord", { sepolia: "notalist" }],
|
||||
floorOnly: [
|
||||
[1, 2],
|
||||
{ sepolia: [1, 2] },
|
||||
{ mainnet: [null, {}, [TOKEN_ADDRESS]] },
|
||||
{ notanetwork: [{ address: TOKEN_ADDRESS }] },
|
||||
JSON.parse('{"__proto__":[{"address":"0xabc"}]}'),
|
||||
],
|
||||
// Each list is put straight back onto trackedTokens by
|
||||
// applyChainSwitchFields() when its network becomes the active one, so
|
||||
// it is floored the same way; a key that names no network is dropped.
|
||||
holds: (v) =>
|
||||
isRecord(v) &&
|
||||
Object.getPrototypeOf(v) === Object.prototype &&
|
||||
Object.keys(v).every(
|
||||
(id) =>
|
||||
isKnownNetworkId(id) &&
|
||||
everyEntry(v[id], (t) => isRecord(t) && isText(t.address)),
|
||||
),
|
||||
},
|
||||
{
|
||||
field: "allowedSites",
|
||||
kind: KIND.ENTRIES,
|
||||
|
||||
Reference in New Issue
Block a user