From 24cac493dded00ef40e0e30a0d2263e4f35c3e29 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 4 Jan 2023 11:24:58 -0300 Subject: fix #7522 --- .../src/wallet/DeveloperPage.tsx | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index 4805c03ca..74e7ce611 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -92,6 +92,7 @@ type CoinsInfo = CoinDumpJson["coins"]; type CalculatedCoinfInfo = { ageKeysCount: number | undefined; denom_value: number; + denom_fraction: number; //remain_value: number; status: string; from_refresh: boolean; @@ -151,7 +152,8 @@ export function View({ } prev[cur.exchange_base_url].push({ ageKeysCount: cur.ageCommitmentProof?.proof.privateKeys.length, - denom_value: parseFloat(Amounts.stringifyValue(denom)), + denom_value: denom.value, + denom_fraction: denom.fraction, // remain_value: parseFloat( // Amounts.stringifyValue(Amounts.parseOrThrow(cur.remaining_value)), // ), @@ -340,7 +342,10 @@ export function View({ {Object.keys(money_by_exchange).map((ex, idx) => { const allcoins = money_by_exchange[ex]; allcoins.sort((a, b) => { - return b.denom_value - a.denom_value; + if (b.denom_value !== a.denom_value) { + return b.denom_value - a.denom_value; + } + return b.denom_fraction - a.denom_fraction; }); const coins = allcoins.reduce( @@ -407,11 +412,31 @@ function ShowAllCoins({ const { i18n } = useTranslationContext(); const [collapsedSpent, setCollapsedSpent] = useState(true); const [collapsedUnspent, setCollapsedUnspent] = useState(false); - const total = coins.usable.reduce((prev, cur) => prev + cur.denom_value, 0); + const totalUsable = coins.usable.reduce( + (prev, cur) => + Amounts.add(prev, { + currency: "NONE", + fraction: cur.denom_fraction, + value: cur.denom_value, + }).amount, + Amounts.zeroOfCurrency("NONE"), + ); + const totalSpent = coins.spent.reduce( + (prev, cur) => + Amounts.add(prev, { + currency: "NONE", + fraction: cur.denom_fraction, + value: cur.denom_value, + }).amount, + Amounts.zeroOfCurrency("NONE"), + ); return (

- {ex}: {total} {currencies[ex]} + {ex}: {Amounts.stringifyValue(totalUsable)} {currencies[ex]} +

+

+ spent: {Amounts.stringifyValue(totalSpent)} {currencies[ex]}

setCollapsedUnspent(true)}> -- cgit v1.2.3