Skip to content

Commit

Permalink
round usd conversions in transaction summary
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Feb 7, 2024
1 parent 9ea49ff commit 61cff1a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
47 changes: 25 additions & 22 deletions src/screens/activity/ActivityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ export const ActivityBasicRow = ({
// USD Balance
const usdBalance = roundBalance(price, 2)

const txSummary: TransactionSummaryScreenProps = useMemo(
() => ({
const txSummary: TransactionSummaryScreenProps = useMemo(() => {
const feeUsd = roundBalance(Number(fee.usdValue), 2)
const totalUsd = Number(price) + Number(fee.usdValue)

return {
transaction: {
tokenValue: {
symbol,
Expand All @@ -91,18 +94,18 @@ export const ActivityBasicRow = ({
usdValue: {
symbol: usdBalance || !price ? '$' : '<',
symbolType: 'usd',
balance: price ? usdBalance || '0.01' : '0.00',
balance: price ? usdBalance.toFixed(2) || '0.01' : '0.00',
},
totalToken:
symbol === fee.symbol
? Number(value) + Number(fee.tokenValue)
: Number(value),
totalUsd: Number(value) + Number(fee.usdValue),
totalUsd: roundBalance(totalUsd, 2).toFixed(2),
status,
fee: {
...fee,
tokenValue: fee.tokenValue,
symbol: fee.symbol || symbol,
usdValue: fee.usdValue,
usdValue: feeUsd.toFixed(2),
},
amIReceiver,
from,
Expand All @@ -111,22 +114,22 @@ export const ActivityBasicRow = ({
hashId: id,
},
contact: contact || { address },
}),
[
address,
amIReceiver,
contact,
fee,
from,
to,
status,
symbol,
timeHumanFormatted,
usdBalance,
value,
id,
],
)
}
}, [
fee,
symbol,
value,
usdBalance,
price,
status,
amIReceiver,
from,
to,
timeHumanFormatted,
id,
contact,
address,
])

const amount = useMemo(() => {
if (symbol.startsWith('BTC')) {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/transactionSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface TransactionSummaryScreenProps {
fee: TokenFeeValueObject
time: string
totalToken: number
totalUsd: number
totalUsd: string
hashId?: string
status?: TransactionStatus
amIReceiver?: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const formatSmallNumbers = (smallNumber: string | number) => {
return formatWithDigits(smallNumber)
}

return asNumber !== 0 ? `< ${tiniestAmount}` : '0.00'
return asNumber !== 0 ? `<${tiniestAmount}` : '0.00'
}

// this needs to be here because of the failing tests
Expand Down

0 comments on commit 61cff1a

Please sign in to comment.