Files
AutistMask/tests/bundledListScreens.test.js
T
clawbot a72f301fe1
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
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.

Eighteen existing tests and three shared test helpers read the bundled
list without naming a network. Each now names Ethereum Mainnet.

Model: opus-5-5
2026-10-27 20:14:25 +00:00

82 lines
3.0 KiB
JavaScript

// The token screen, the Send screen and the confirmation screen for the
// contract at USDC's mainnet address. No address holds it and the user does
// not track it, so only the bundled token list can name it.
//
// The bundled token list holds Ethereum Mainnet contracts, so these screens
// name the token from it on Ethereum Mainnet only
// (https://git.eeqj.de/sneak/AutistMask/issues/632). Driven through the real
// popup over a stored profile.
const {
bootPopup,
cleanupPopup,
unversionedValidProfile,
} = require("./support/popupBoot");
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const RECIPIENT = "0x711e691962E5c054b78071C789A0C8CE657377aD";
afterEach(() => {
cleanupPopup();
});
// The popup reopened onto AddressToken for USDC's address, on `networkId`.
function bootOnToken(networkId) {
return bootPopup(
unversionedValidProfile({
networkId,
currentView: "address-token",
viewStack: ["main", "address"],
selectedWallet: 0,
selectedAddress: 0,
selectedToken: USDC,
}),
);
}
// AddressToken's Send, then Review for 1 token to RECIPIENT.
async function reviewSend(boot) {
await boot.click("btn-address-token-send");
expect(boot.visibleViews()).toEqual(["send"]);
boot.node("send-to").value = RECIPIENT;
boot.node("send-amount").value = "1";
await boot.click("btn-send-review");
expect(boot.visibleViews()).toEqual(["confirm-tx"]);
}
describe("on Ethereum Mainnet, the bundled list names the token", () => {
test("on the token screen", async () => {
const boot = await bootOnToken("mainnet");
expect(boot.visibleViews()).toEqual(["address-token"]);
expect(boot.text("address-token-title")).toContain("USDC");
const info = boot.node("address-token-contract-info").innerHTML;
expect(info).toContain(
'<span class="text-muted">Decimals:</span> 6</div>',
);
});
test("on the Send screen and the confirmation screen", async () => {
const boot = await bootOnToken("mainnet");
await reviewSend(boot);
expect(boot.text("send-balance")).toContain("USDC");
expect(boot.text("confirm-amount")).toContain("USDC");
});
});
describe("with Sepolia active, the bundled list does not name the token", () => {
test("on the token screen", async () => {
const boot = await bootOnToken("sepolia");
expect(boot.visibleViews()).toEqual(["address-token"]);
expect(boot.text("address-token-title")).not.toContain("USDC");
const info = boot.node("address-token-contract-info").innerHTML;
expect(info).not.toContain("Decimals:");
});
test("on the Send screen and the confirmation screen", async () => {
const boot = await bootOnToken("sepolia");
await reviewSend(boot);
expect(boot.text("send-balance")).not.toContain("USDC");
expect(boot.text("confirm-amount")).not.toContain("USDC");
});
});