Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9858541bf8 |
@@ -2233,8 +2233,8 @@ view would leave a wallet one click from deletion.
|
||||
**AddressDetail**
|
||||
- "Add" with a token already tracked, a scam-listed address, or a failed
|
||||
contract lookup → flash message, no screen change
|
||||
- "Add", then leaving AddToken before the contract lookup answers → tracks
|
||||
the token, no screen change
|
||||
- "Add", then the contract lookup answers while another screen shows, or
|
||||
after AddToken was opened again → tracks the token, no screen change
|
||||
- "Add", then a network switch in Settings before the contract lookup
|
||||
answers → nothing is tracked; "The active network changed before the
|
||||
lookup finished, so the token was not added." flash message, no screen
|
||||
|
||||
@@ -5,7 +5,12 @@ const { lookupTokenInfo } = require("../../shared/balances");
|
||||
const { isScamAddress } = require("../../shared/scamlist");
|
||||
const { log } = require("../../shared/log");
|
||||
|
||||
// Counts the times AddToken has opened. A contract lookup started before
|
||||
// AddToken was last opened changes neither the screen nor the status line.
|
||||
let addTokenScreenOpenings = 0;
|
||||
|
||||
function show() {
|
||||
addTokenScreenOpenings++;
|
||||
$("add-token-address").value = "";
|
||||
$("add-token-info").textContent = "";
|
||||
$("add-token-info").style.visibility = "hidden";
|
||||
@@ -55,6 +60,7 @@ function init(ctx) {
|
||||
// The network the lookup asks, which Settings may switch away from
|
||||
// before it answers, as for a transaction in confirmTx.js.
|
||||
const chainId = currentNetwork().chainId;
|
||||
const opening = addTokenScreenOpenings;
|
||||
try {
|
||||
const info = await lookupTokenInfo(
|
||||
contractAddr,
|
||||
@@ -80,11 +86,15 @@ function init(ctx) {
|
||||
});
|
||||
await saveState();
|
||||
ctx.doRefreshAndRender();
|
||||
// If the lookup answers after AddToken was opened again, the
|
||||
// token is still added, but the screen and the status line stay
|
||||
// as they are.
|
||||
if (addTokenScreenOpenings !== opening) return;
|
||||
// The lookup is over, so a later Back onto AddToken shows no
|
||||
// status.
|
||||
infoEl.textContent = "";
|
||||
infoEl.style.visibility = "hidden";
|
||||
// If the user left AddToken while the lookup ran, the token is
|
||||
// If the lookup answers while another screen shows, the token is
|
||||
// still added but the screen does not change.
|
||||
if (state.currentView !== "add-token") return;
|
||||
// Pop the stack (back to address detail) and re-render it
|
||||
|
||||
@@ -18,6 +18,9 @@ const TOKEN = {
|
||||
name: "Test Token",
|
||||
};
|
||||
|
||||
// A second contract address, typed after AddToken was opened again.
|
||||
const OTHER_TOKEN_ADDRESS = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
|
||||
|
||||
afterEach(() => {
|
||||
cleanupPopup();
|
||||
});
|
||||
@@ -85,6 +88,22 @@ test("Back onto AddToken after that answer shows no lookup status", async () =>
|
||||
expect(boot.node("add-token-info").style.visibility).toBe("hidden");
|
||||
});
|
||||
|
||||
test("an answer after AddToken was opened again adds the token and leaves AddToken and its status line as they are", async () => {
|
||||
const boot = await openAddToken();
|
||||
const answerFirstLookup = addWithPendingLookup(boot);
|
||||
await boot.click("btn-add-token-back");
|
||||
await boot.click("btn-add-token");
|
||||
expect(boot.visibleViews()).toEqual(["add-token"]);
|
||||
boot.node("add-token-address").value = OTHER_TOKEN_ADDRESS;
|
||||
// The second lookup is never answered.
|
||||
addWithPendingLookup(boot);
|
||||
|
||||
await answerFirstLookup();
|
||||
expect(boot.visibleViews()).toEqual(["add-token"]);
|
||||
expect(boot.text("add-token-info")).toBe("Looking up token...");
|
||||
expect(boot.storage.read("autistmask").trackedTokens).toEqual([TOKEN]);
|
||||
});
|
||||
|
||||
test("an answer while AddToken still shows goes to AddressDetail with the token listed", async () => {
|
||||
const boot = await openAddToken();
|
||||
const answerLookup = addWithPendingLookup(boot);
|
||||
|
||||
Reference in New Issue
Block a user