Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(ui): always display crypto amounts as positve numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Mar 28, 2020
1 parent ca76230 commit a203b15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion renderer/components/UI/Value.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -46,7 +51,7 @@ const Value = ({ value, currency, currentTicker, fiatTicker, style }) => {
currency={fiatTicker}
maximumFractionDigits={dp}
style={style}
value={convertedAmount}
value={absAmount}
/>
)
}
Expand Down

0 comments on commit a203b15

Please sign in to comment.