Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11c9481556 |
No files matched your search
@@ -1025,8 +1025,7 @@ removing the address only stops the wallet tracking it. It explains the way
|
|||||||
back: delete the whole wallet in Settings and import its backup again. The scan
|
back: delete the whole wallet in Settings and import its backup again. The scan
|
||||||
after an import finds only addresses with on-chain activity. When the address
|
after an import finds only addresses with on-chain activity. When the address
|
||||||
holds anything, the screen lists the holdings and the USD total under a warning.
|
holds anything, the screen lists the holdings and the USD total under a warning.
|
||||||
An ETH balance that no refresh has read counts as holding something. The warning
|
An ETH balance that no refresh has read counts as holding something.
|
||||||
then reads "This address may hold a balance."
|
|
||||||
|
|
||||||
"Remove Address" removes the address and its site permissions. It returns to
|
"Remove Address" removes the address and its site permissions. It returns to
|
||||||
Home with the flash message "Address removed." The wallet's `nextIndex` is not
|
Home with the flash message "Address removed." The wallet's `nextIndex` is not
|
||||||
|
|||||||
@@ -87,22 +87,15 @@ function recoveryPathText(wallet) {
|
|||||||
// when every holding here is one with no price, since "$0.00" directly under
|
// when every holding here is one with no price, since "$0.00" directly under
|
||||||
// "This address holds a balance." is a contradiction. A token holding below
|
// "This address holds a balance." is a contradiction. A token holding below
|
||||||
// 0.000001 does not count, as the lines below leave it out.
|
// 0.000001 does not count, as the lines below leave it out.
|
||||||
//
|
|
||||||
// While no refresh has read the ETH balance the address may be empty, so the
|
|
||||||
// sentence says "may hold".
|
|
||||||
function balanceWarningHtml(addr) {
|
function balanceWarningHtml(addr) {
|
||||||
if (!addressHoldsFunds(addr)) return " ";
|
if (!addressHoldsFunds(addr)) return " ";
|
||||||
const line = formatAddressTotal(getAddressValue(addr));
|
const line = formatAddressTotal(getAddressValue(addr));
|
||||||
const total = line
|
const total = line
|
||||||
? `<div class="text-xs text-muted mt-1">${escapeHtml(line)}</div>`
|
? `<div class="text-xs text-muted mt-1">${escapeHtml(line)}</div>`
|
||||||
: "";
|
: "";
|
||||||
const sentence =
|
|
||||||
addr.balance == null
|
|
||||||
? "This address may hold a balance."
|
|
||||||
: "This address holds a balance.";
|
|
||||||
return (
|
return (
|
||||||
`<p class="mb-1">${sentence} Removing it does not move or spend ` +
|
`<p class="mb-1">This address holds a balance. Removing it does not ` +
|
||||||
`anything; the balance stays at the address.</p>` +
|
`move or spend anything; the balance stays at the address.</p>` +
|
||||||
balanceLinesForAddress(addr, state.trackedTokens, false) +
|
balanceLinesForAddress(addr, state.trackedTokens, false) +
|
||||||
total
|
total
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,9 +494,9 @@ function balanceLinesForAddress(addr, trackedTokens, showZero) {
|
|||||||
// about holdings must ask this, not the rendered figure.
|
// about holdings must ask this, not the rendered figure.
|
||||||
function addressHoldsFunds(addr) {
|
function addressHoldsFunds(addr) {
|
||||||
if (!addr) return false;
|
if (!addr) return false;
|
||||||
// A null or absent ETH balance reads as unknown, so the address may hold
|
// A null ETH balance is one no refresh has read, so the address may hold
|
||||||
// funds. Warning about funds must err towards warning.
|
// funds. Warning about funds must err towards warning.
|
||||||
if (addr.balance == null) return true;
|
if (addr.balance === null) return true;
|
||||||
if (parseFloat(addr.balance) > 0) return true;
|
if (parseFloat(addr.balance) > 0) return true;
|
||||||
for (const t of addr.tokenBalances || []) {
|
for (const t of addr.tokenBalances || []) {
|
||||||
if (isBelowOneMillionth(t.balance)) continue;
|
if (isBelowOneMillionth(t.balance)) continue;
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ function formatUsd(amount) {
|
|||||||
// way an absent holders_count is not a count of zero.
|
// way an absent holders_count is not a count of zero.
|
||||||
//
|
//
|
||||||
// usd: the value of the holdings a price is known for, or null when
|
// usd: the value of the holdings a price is known for, or null when
|
||||||
// no total can be stated — testnet, before the first fetch, or an
|
// nothing is knowable at all — testnet, before the first fetch, or
|
||||||
// ETH balance no refresh has read.
|
// an ETH balance no refresh has read.
|
||||||
// partial: the address also holds a token with no price, so usd is a floor
|
// partial: the address also holds a token with no price, so usd is a floor
|
||||||
// and not the total.
|
// and not the total.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -117,13 +117,9 @@ describe("whether an address holds anything", () => {
|
|||||||
expect(addressHoldsFunds(ZERO_TOKEN)).toBe(false);
|
expect(addressHoldsFunds(ZERO_TOKEN)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a missing address does not", () => {
|
test("a missing address or missing fields do not", () => {
|
||||||
expect(addressHoldsFunds(undefined)).toBe(false);
|
expect(addressHoldsFunds(undefined)).toBe(false);
|
||||||
});
|
expect(addressHoldsFunds({ address: "0x1" })).toBe(false);
|
||||||
|
|
||||||
// It reads as unknown, as a null balance does.
|
|
||||||
test("an address with no ETH balance field counts", () => {
|
|
||||||
expect(addressHoldsFunds({ address: "0x1" })).toBe(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -150,23 +146,16 @@ describe("the balance warning on the removal confirmation", () => {
|
|||||||
expect(html).toContain("<span>0.0000</span>");
|
expect(html).toContain("<span>0.0000</span>");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The sentence must not assert an amount, because any amount it could
|
||||||
|
// assert has been rounded: "This address holds 0.0000 ETH." is what the
|
||||||
|
// rounded form produces for an address that holds real money.
|
||||||
test("an ETH balance no refresh has read is warned about, and reads as unknown", () => {
|
test("an ETH balance no refresh has read is warned about, and reads as unknown", () => {
|
||||||
const html = balanceWarningHtml(NOT_READ);
|
const html = balanceWarningHtml(NOT_READ);
|
||||||
expect(html).toContain("This address may hold a balance.");
|
expect(html).toContain("This address holds a balance");
|
||||||
expect(html).not.toContain("This address holds a balance.");
|
|
||||||
expect(html).toContain("quantity unknown");
|
expect(html).toContain("quantity unknown");
|
||||||
expect(html).not.toContain("0.0000");
|
expect(html).not.toContain("0.0000");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("an address with no ETH balance field reads the same", () => {
|
|
||||||
expect(balanceWarningHtml({ address: "0x1" })).toContain(
|
|
||||||
"This address may hold a balance.",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// The sentence must not assert an amount, because any amount it could
|
|
||||||
// assert has been rounded: "This address holds 0.0000 ETH." is what the
|
|
||||||
// rounded form produces for an address that holds real money.
|
|
||||||
test("the warning sentence asserts no rounded amount", () => {
|
test("the warning sentence asserts no rounded amount", () => {
|
||||||
for (const addr of [DUST, ETH_ONLY, TOKEN_ONLY]) {
|
for (const addr of [DUST, ETH_ONLY, TOKEN_ONLY]) {
|
||||||
expect(balanceWarningHtml(addr)).not.toMatch(
|
expect(balanceWarningHtml(addr)).not.toMatch(
|
||||||
|
|||||||
Reference in new issue
Block a user