fix: fall back to known token list for symbol/name/decimals #54
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/AutistMask#54
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/51-usdc-symbol-fallback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a token's balance entry is missing or incomplete (e.g. not yet fetched from Blockscout), the address-token view and send view now fall back to the built-in known token list for symbol, name, and decimals instead of showing
?.Also includes token
namein the balance object returned byfetchTokenBalancesso the contract info well can display it.Fixes #51
make checkpasses (tests, lint, format all clean). Mergeable, no conflicts. Cannot self-review — assigning to @sneak for review.@clawbot will this show ? for zero-balance not-known tokens added by the user by contract address?
Yes — if a user adds a token by contract address that is neither in
TOKEN_BY_ADDRESS(the known token list) nor returns symbol/name from the Blockscout API, it will still show?. The fallback chain is:So
?only appears when both sources have no data. For most real ERC-20 tokens, Blockscout will return the symbol even if it's not in our known list. The?case would mainly hit proxy contracts or very obscure tokens where Blockscout has no metadata.You're right — this is a band-aid, not a fix. The known token list fallback only helps tokens we've hardcoded. The real bug is: why is
tb.symbolempty/missing for USDC in the first place? Blockscout should be returning that metadata.I'll dig into
fetchTokenBalancesinbalances.jsto see if we're dropping the symbol during parsing, or if the Blockscout API response genuinely lacks it. That's the actual root cause.Found the root cause. Two problems:
fetchTokenBalancesdrops zero-balance tokens (if (bal === "0.0") continueat line 79 ofbalances.js). So if a user tracks USDC but has 0 balance, it's excluded fromaddr.tokenBalancesentirely.The UI looks up metadata only from
addr.tokenBalances, which is now empty for that token →tbisundefined→ shows?.The known-token-list fallback in this PR only helps hardcoded tokens. A user who adds a custom token by contract address will still see
?if their balance is zero or if Blockscout hasn't indexed it yet.Proper fix: When
tbis missing, fall back tostate.trackedTokens(which already storesname,symbol,decimalsfrom thelookupTokenInfocall at add time). This covers all user-added tokens regardless of whether they're in the known list.I'll rework this PR.
Added
state.trackedTokensfallback for symbol/name/decimals resolution.Fallback chain is now:
tb(Blockscout balance) →trackedTokens(user-added tokens from state) →TOKEN_BY_ADDRESS(hardcoded known tokens) →"?"Files changed:
src/popup/views/addressToken.js— symbol resolution in show() + all fields in contract info section (name, symbol, decimals)src/popup/views/send.js— symbol resolution in updateSendBalance() + review button handlerThis ensures custom tokens added by the user display correctly even when Blockscout drops them (zero balance).
make checkanddocker buildboth pass.