chore: the native token's label follows the active network (closes #372)
check / check (push) Failing after 2s
e2e / e2e-chrome (push) Failing after 2s
e2e / e2e-firefox (push) Failing after 2s

networks.js gives each network a nativeCurrency (ETH, SepoliaETH) and nothing
read it: every screen wrote a hardcoded ETH, so on Sepolia the balance, the
value and the fee all read ETH. A nativeCurrency() helper in the popup's
helpers.js returns the active network's, and every native balance, value, fee,
reserve, type line and history entry is labelled with it. The "ETH" that
selectedToken and txInfo.token hold is the native token's id and is unchanged.
The confirmation screen's not-enough-to-pay-the-fee sentence now names the
coin to add, so show() sets it.

Model: opus-5-5
This commit is contained in:
2026-10-04 21:53:00 +00:00
parent 6127fd9432
commit f47d17a98f
15 changed files with 407 additions and 43 deletions
+13 -4
View File
@@ -28,7 +28,7 @@ function normalizeAddress(addr) {
return (addr || "").toLowerCase();
}
function parseTx(tx, addrLower) {
function parseTx(tx, addrLower, nativeCurrency) {
const from = tx.from?.hash || "";
const to = tx.to?.hash || "";
const rawWei = tx.value || "0";
@@ -36,7 +36,7 @@ function parseTx(tx, addrLower) {
const method = tx.method || null;
// For contract calls, produce a meaningful label instead of "0.0000 ETH"
let symbol = "ETH";
let symbol = nativeCurrency;
let value = formatTxValue(formatEther(rawWei));
let exactValue = formatEther(rawWei);
let rawAmount = rawWei;
@@ -221,7 +221,14 @@ function mergeTransactions(txs, tokenTransfers) {
return merged;
}
async function fetchRecentTransactions(address, blockscoutUrl, count = 25) {
// `nativeCurrency` is the active network's native token symbol from
// networks.js (`ETH`, `SepoliaETH`), which a native entry is labelled with.
async function fetchRecentTransactions(
address,
blockscoutUrl,
nativeCurrency,
count = 25,
) {
log.debugf("fetchRecentTransactions", address);
const addrLower = normalizeAddress(address);
@@ -254,7 +261,9 @@ async function fetchRecentTransactions(address, blockscoutUrl, count = 25) {
const ttJson = ttResp.ok ? await ttResp.json() : {};
const txs = mergeTransactions(
(txJson.items || []).map((tx) => parseTx(tx, addrLower)),
(txJson.items || []).map((tx) =>
parseTx(tx, addrLower, nativeCurrency),
),
(ttJson.items || []).map((tt) => parseTokenTransfer(tt, addrLower)),
);