fix: the bundled token list names tokens on Ethereum Mainnet only (closes #632)
bundledToken(address, chainId) in tokenList.js answers only for Ethereum Mainnet's chain id. Every reader of TOKEN_BY_ADDRESS now goes through it, with the chain id of the transaction, balance or history entry it draws. The token sources the screens build carry that chain id. The Uniswap decoder sets the transaction's chain id on them. fetchTokenBalances() takes the chain id of the network it asks about. isSpoofedSymbol() takes the chain id of the token's network. It checks the bundled list's symbols only on Ethereum Mainnet. The native asset's labels stay reserved on every network. Twenty existing tests and four shared test helpers read the bundled list without naming a network. Each now names Ethereum Mainnet. Model: opus-5-5
This commit is contained in:
@@ -314,14 +314,17 @@ function nativeCurrency() {
|
||||
// The wallets' balances hold what Blockscout reported for each token. So the
|
||||
// wallets are returned only while "Use Blockscout" is on.
|
||||
function tokenSourcesByChainId(chainId) {
|
||||
const net = chainId ? networkByChainId(chainId) : currentNetwork();
|
||||
const chainIdOrActive = chainId || currentNetwork().chainId;
|
||||
const net = networkByChainId(chainIdOrActive);
|
||||
if (net && net.id === state.networkId) {
|
||||
return {
|
||||
chainId: chainIdOrActive,
|
||||
trackedTokens: state.trackedTokens,
|
||||
wallets: state.useBlockscout ? state.wallets : [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
chainId: chainIdOrActive,
|
||||
trackedTokens: (net && state.networkTrackedTokens[net.id]) || [],
|
||||
wallets: [],
|
||||
};
|
||||
@@ -352,7 +355,7 @@ function blockscoutOffTokenNoteHtml(token, chainId) {
|
||||
|
||||
// The symbol shown for a token line, from these sources in order:
|
||||
//
|
||||
// - the bundled list
|
||||
// - the bundled list, for a token on Ethereum Mainnet
|
||||
// - the tokens the user tracks
|
||||
// - the explorer's report, while "Use Blockscout" is on
|
||||
//
|
||||
@@ -459,7 +462,11 @@ function balanceLinesForAddress(addr, trackedTokens, showZero) {
|
||||
if (seen.has(t.address.toLowerCase())) continue;
|
||||
// A token that the spoof rule refuses has no stored balance, and
|
||||
// gets no zero row either.
|
||||
if (isSpoofedSymbol(t.symbol, t.address)) continue;
|
||||
if (
|
||||
isSpoofedSymbol(t.symbol, t.address, currentNetwork().chainId)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
html += balanceLine(
|
||||
t.symbol,
|
||||
t.balanceNotFetched ? null : 0,
|
||||
|
||||
Reference in New Issue
Block a user