fix: say an unknown-scale balance the same way on Send and on confirm (closes #377)
When two addresses' explorer reports disagree on a token's decimals, the Send screen showed the stored figure while the confirmation screen said the balance was unknown. One function in send.js now gives both the balance and scale, so both read `unknown (SYMBOL)`. The confirmation screen's fee-unknown message names its cause: for an unknown scale it says the wallet does not know the token's decimal places and the transaction cannot be sent, instead of asking for a retry that cannot help. Other causes keep the old sentence. Model: opus-5-5
This commit is contained in:
@@ -382,8 +382,56 @@ describe("a scale the explorer's own rows disagree about", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// https://git.eeqj.de/sneak/AutistMask/issues/377. The Send screen read the
|
||||
// stored balance and said "5.0000 NOVEL", the confirmation screen it leads
|
||||
// to said "unknown (NOVEL)", and the fee message asked the user to go back
|
||||
// and try again, which cannot supply a scale.
|
||||
test("reads the same on the Send screen and the confirmation screen, and the fee message names the scale", async () => {
|
||||
await fetchOntoBoth([novel("6", 5000000n)], [novel("18", FIVE_WETH)]);
|
||||
state.selectedToken = NOVEL;
|
||||
send.updateSendBalance();
|
||||
expect(text("send-balance")).toBe("Current balance: unknown (NOVEL)");
|
||||
|
||||
const txInfo = await reviewSend(NOVEL, "1.5");
|
||||
confirmTx.show(txInfo);
|
||||
await settle();
|
||||
expect(text("confirm-balance")).toBe("unknown (NOVEL)");
|
||||
expect(text("confirm-fee-unknown-error")).toBe(
|
||||
"The network fee could not be estimated, because this wallet" +
|
||||
" does not know how many decimal places this token uses, so" +
|
||||
" this transaction cannot be sent.",
|
||||
);
|
||||
expect(el("confirm-fee-unknown-error").style.visibility).toBe(
|
||||
"visible",
|
||||
);
|
||||
});
|
||||
|
||||
test("while a fee that fails for any other reason keeps its retry", async () => {
|
||||
await fetchOntoBoth([novel("6", 5000000n)], [novel("6", 5000000n)]);
|
||||
const txInfo = await reviewSend(NOVEL, "1.5");
|
||||
const getFeeData = mockProvider.getFeeData;
|
||||
mockProvider.getFeeData = async () => {
|
||||
throw new Error("the node did not answer");
|
||||
};
|
||||
try {
|
||||
confirmTx.show(txInfo);
|
||||
await settle();
|
||||
} finally {
|
||||
mockProvider.getFeeData = getFeeData;
|
||||
}
|
||||
expect(text("confirm-fee-amount")).toBe("Unable to estimate");
|
||||
expect(text("confirm-fee-unknown-error")).toBe(
|
||||
"The network fee could not be estimated, so this transaction" +
|
||||
" cannot be checked against your balance. Please go back and" +
|
||||
" try again.",
|
||||
);
|
||||
});
|
||||
|
||||
test("while agreeing rows leave the scale usable", async () => {
|
||||
await fetchOntoBoth([novel("6", 5000000n)], [novel("6", 5000000n)]);
|
||||
state.selectedToken = NOVEL;
|
||||
send.updateSendBalance();
|
||||
expect(text("send-balance")).toBe("Current balance: 5.0000 NOVEL");
|
||||
const txInfo = await reviewSend(NOVEL, "1.5");
|
||||
expect(txInfo.tokenDecimals).toBe(6);
|
||||
expect(txInfo.tokenBalance).toBe("5.0");
|
||||
|
||||
Reference in New Issue
Block a user