mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Check if swapTokenValue is negative and set prefix accordingly (#9743)
* Check if swapTokenValue is negative and set prefix accordingly Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
557f9550d7
commit
0494f72128
@ -44,6 +44,11 @@ export function useSwappedTokenValue (transactionGroup, currentAsset) {
|
|||||||
decimals,
|
decimals,
|
||||||
)
|
)
|
||||||
: transactionCategory === SWAP && primaryTransaction.swapTokenValue
|
: transactionCategory === SWAP && primaryTransaction.swapTokenValue
|
||||||
|
|
||||||
|
const isNegative = typeof swapTokenValue === 'string'
|
||||||
|
? Math.sign(swapTokenValue) === -1
|
||||||
|
: false
|
||||||
|
|
||||||
const _swapTokenFiatAmount = useTokenFiatAmount(
|
const _swapTokenFiatAmount = useTokenFiatAmount(
|
||||||
address,
|
address,
|
||||||
swapTokenValue || '',
|
swapTokenValue || '',
|
||||||
@ -52,5 +57,5 @@ export function useSwappedTokenValue (transactionGroup, currentAsset) {
|
|||||||
const swapTokenFiatAmount = (
|
const swapTokenFiatAmount = (
|
||||||
swapTokenValue && isViewingReceivedTokenFromSwap && _swapTokenFiatAmount
|
swapTokenValue && isViewingReceivedTokenFromSwap && _swapTokenFiatAmount
|
||||||
)
|
)
|
||||||
return { swapTokenValue, swapTokenFiatAmount, isViewingReceivedTokenFromSwap }
|
return { swapTokenValue, swapTokenFiatAmount, isViewingReceivedTokenFromSwap, isNegative }
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ export function useTransactionDisplayData (transactionGroup) {
|
|||||||
// The primary title of the Tx that will be displayed in the activity list
|
// The primary title of the Tx that will be displayed in the activity list
|
||||||
let title
|
let title
|
||||||
|
|
||||||
const { swapTokenValue, swapTokenFiatAmount, isViewingReceivedTokenFromSwap } = useSwappedTokenValue(transactionGroup, currentAsset)
|
const { swapTokenValue, isNegative, swapTokenFiatAmount, isViewingReceivedTokenFromSwap } = useSwappedTokenValue(transactionGroup, currentAsset)
|
||||||
|
|
||||||
// There are seven types of transaction entries that are currently differentiated in the design
|
// There are seven types of transaction entries that are currently differentiated in the design
|
||||||
// 1. Signature request
|
// 1. Signature request
|
||||||
@ -145,8 +145,13 @@ export function useTransactionDisplayData (transactionGroup) {
|
|||||||
: initialTransaction.sourceTokenSymbol
|
: initialTransaction.sourceTokenSymbol
|
||||||
primaryDisplayValue = swapTokenValue
|
primaryDisplayValue = swapTokenValue
|
||||||
secondaryDisplayValue = swapTokenFiatAmount
|
secondaryDisplayValue = swapTokenFiatAmount
|
||||||
prefix = isViewingReceivedTokenFromSwap ? '+' : '-'
|
if (isNegative) {
|
||||||
|
prefix = ''
|
||||||
|
} else if (isViewingReceivedTokenFromSwap) {
|
||||||
|
prefix = '+'
|
||||||
|
} else {
|
||||||
|
prefix = '-'
|
||||||
|
}
|
||||||
} else if (transactionCategory === SWAP_APPROVAL) {
|
} else if (transactionCategory === SWAP_APPROVAL) {
|
||||||
category = TRANSACTION_CATEGORY_APPROVAL
|
category = TRANSACTION_CATEGORY_APPROVAL
|
||||||
title = t('swapApproval', [primaryTransaction.sourceTokenSymbol])
|
title = t('swapApproval', [primaryTransaction.sourceTokenSymbol])
|
||||||
|
Loading…
Reference in New Issue
Block a user