From a203b15a2b28dc147aa6926e9e0c3497795803a7 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sat, 28 Mar 2020 13:53:05 +0100 Subject: [PATCH] fix(ui): always display crypto amounts as positve numbers --- renderer/components/UI/Value.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/renderer/components/UI/Value.js b/renderer/components/UI/Value.js index 7460abcab88..eaaf18c92e8 100644 --- a/renderer/components/UI/Value.js +++ b/renderer/components/UI/Value.js @@ -2,6 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import { FormattedNumber } from 'react-intl' import { convert } from '@zap/utils/btc' +import { CoinBig } from '@zap/utils/coin' /** * Value - Renders a satoshi amount into a specific currency/unit. @@ -19,6 +20,10 @@ const Value = ({ value, currency, currentTicker, fiatTicker, style }) => { // Convert the satoshi amount to the requested currency. const convertedAmount = convert('sats', currency, value, price) + const absAmount = CoinBig(convertedAmount) + .abs() + .toString() + // Truncate the amount to the most relevant number of decimal places. let dp switch (currency) { @@ -46,7 +51,7 @@ const Value = ({ value, currency, currentTicker, fiatTicker, style }) => { currency={fiatTicker} maximumFractionDigits={dp} style={style} - value={convertedAmount} + value={absAmount} /> ) }