Skip to content

fix: purge delisted networks from aggregate token cache and refresh stale wallet config OK-58112#12533

Open
weatherstar wants to merge 4 commits into
xfrom
fix/aggregate-token-stale-network-cache
Open

fix: purge delisted networks from aggregate token cache and refresh stale wallet config OK-58112#12533
weatherstar wants to merge 4 commits into
xfrom
fix/aggregate-token-stale-network-cache

Conversation

@weatherstar

@weatherstar weatherstar commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

OK-58112


Problem

With All Networks enabled, opening an aggregate token's details page (e.g. USDT) and then the "Contract Address" popover shows blank rows — only the copy/explorer buttons render, with no network icon or name.

Root cause

  • /wallet/v1/wallet/config responses are persisted into simpleDb.aggregateToken.allAggregateTokenMap. On app versions before chore: remove 21 low-usage built-in EVM networks #10373 (removed 21 low-usage built-in EVM networks, 2026-02), networks like Gnosis (evm--100), B² (evm--223), Polygon zkEVM (evm--1101) and zkLink Nova (evm--810180) were LISTED presets, so USDT entries on them were cached.
  • After upgrading, those networks no longer exist in the bundle, so getNetworkSafe resolves to undefined → empty network name and a null NetworkAvatar, while the address-driven buttons still render → blank rows.
  • The cache never heals: syncWalletConfig was only triggered when aggregateTokenConfigMap was completely missing, so existing users never re-synced and the stale map survived indefinitely (server-side cleanup alone cannot fix affected users either).

Changes

Symptom fixes (render-side tolerance):

  • TokenDetails: skip aggregate tokens whose network cannot be resolved when building the contract-address list.
  • ServiceToken.getAllAggregateTokenInfo: filter cached aggregate tokens against the current bundled LISTED preset networks, healing all consumers of this accessor (receive flow, universal search, home token list).

Root fix (cache refresh):

  • Record configSyncMeta (appVersion + syncedAt) on every successful syncWalletConfig.
  • New ServiceSetting.syncWalletConfigIfNeeded: re-syncs when the config was never synced, the app version changed (bundled preset network list may differ), or the cache is older than 24h; concurrent calls are deduped.
  • TokenListBlock fires it in the background on all-networks refresh, so the full-replace sync (merge=false) purges delisted networks from the persisted maps.

Verification

  • Live prod /wallet/v1/wallet/config still returns 10 networkIds absent from current presets (4 of them removed by chore: remove 21 low-usage built-in EVM networks #10373 carry USDT — matching the 4 blank rows in the report).
  • New unit tests: ServiceToken.getAllAggregateTokenInfo filtering and ServiceSetting.syncWalletConfigIfNeeded decision matrix (9 tests, all passing).
  • yarn agent:check --profile commit passes.

🤖 Generated with Claude Code

@weatherstar weatherstar changed the title fix: purge delisted networks from aggregate token cache and refresh stale wallet config fix: purge delisted networks from aggregate token cache and refresh stale wallet config OK-58112 Jul 17, 2026
Comment thread packages/kit/src/views/AssetDetails/pages/TokenDetails/index.tsx
- resolve a single surviving member as the current token so detail
  requests, contract copy and explorer links use its real network
  instead of the aggregate descriptor (mock networkId aggregate--0)
- render an unavailable empty state and hide header actions when the
  filtered aggregate group has no valid member left
- keep aggregate tokens on the loading spinner until the group is
  resolved so the descriptor never reaches the single-token fallback
@weatherstar
weatherstar requested a review from originalix July 17, 2026 06:18
// Skip networks this build no longer bundles: a stale
// aggregate-token cache persisted by an older app version may
// still reference delisted networks.
if (tokenNetwork) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当旧聚合缓存引用的网络已从当前构建的 presetNetworks 移除,但它仍以 LISTED 状态存在于 serverNetwork 或 customNetwork 缓存时,getNetworkSafe() 仍会从合并后的网络注册表返回该网络。

因此这里不会执行注释所说的“当前构建不再 bundled 就跳过”,该成员仍会进入合约列表和详情页,PR 要修复的 stale-network 路径仍可复现。

请复用 getAllAggregateTokenInfo()getListedNetworkMap() 过滤结果,或在此显式按 getListedNetworkMap() 判断,不要用 getNetworkSafe() 作为 bundled preset membership check。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants