fix: add trackedTokens fallback for symbol/name/decimals resolution
All checks were successful
check / check (push) Successful in 22s
All checks were successful
check / check (push) Successful in 22s
Extends the fallback chain to: tb → state.trackedTokens → TOKEN_BY_ADDRESS → '?' This ensures user-added custom tokens (not just hardcoded known tokens) display correct symbol, name, and decimals even when Blockscout hasn't returned balance data (e.g. zero-balance tracked tokens).
This commit is contained in:
@@ -74,8 +74,14 @@ function updateSendBalance() {
|
||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||
);
|
||||
const knownToken = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
||||
const tracked = (state.trackedTokens || []).find(
|
||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||
);
|
||||
const symbol =
|
||||
(tb && tb.symbol) || (knownToken && knownToken.symbol) || "?";
|
||||
(tb && tb.symbol) ||
|
||||
(tracked && tracked.symbol) ||
|
||||
(knownToken && knownToken.symbol) ||
|
||||
"?";
|
||||
const bal = tb ? tb.balance || "0" : "0";
|
||||
$("send-balance").textContent =
|
||||
"Current balance: " + bal + " " + symbol;
|
||||
@@ -127,8 +133,14 @@ function init(_ctx) {
|
||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||
);
|
||||
const knownTk = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
||||
const trackedTk = (state.trackedTokens || []).find(
|
||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||
);
|
||||
tokenSymbol =
|
||||
(tb && tb.symbol) || (knownTk && knownTk.symbol) || "?";
|
||||
(tb && tb.symbol) ||
|
||||
(trackedTk && trackedTk.symbol) ||
|
||||
(knownTk && knownTk.symbol) ||
|
||||
"?";
|
||||
tokenBalance = tb ? tb.balance || "0" : "0";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user