Skip to content

Commit

Permalink
show "infinite" if token approval is very large (#2746)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNerdi authored Jul 19, 2024
1 parent 62768a7 commit 45a776b
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import { getTokenFromActivity } from '@core/activity/utils/getTokenFromActivity'
import { formatCurrency, localize } from '@core/i18n'
import { getFiatValueFromTokenAmount } from '@core/market/actions'
import { BASE_TOKEN_ID, ITokenWithBalance, TokenStandard } from '@core/token'
import { BASE_TOKEN_ID, formatTokenAmount, ITokenWithBalance, TokenStandard } from '@core/token'
import { Text } from '@bloomwalletio/ui'
import { selectedAccountTokens } from '@core/token/stores'
import { getPersistedToken, selectedAccountTokens } from '@core/token/stores'
import { NetworkNamespace } from '@core/network'
import { EvmActivityType } from '@core/activity/enums/evm'
import { NftStandard } from '@core/nfts'
Expand Down Expand Up @@ -51,11 +51,21 @@
) {
return '1 ' + localize('general.nft')
} else {
return getFormattedAmountFromActivity(
_activity.tokenTransfer.rawAmount,
_activity.tokenTransfer.tokenId,
_activity
)
if (_activity.type === EvmActivityType.TokenApproval) {
const { rawAmount, tokenId } = _activity.tokenTransfer
const metadata = getPersistedToken(activity.sourceNetworkId, tokenId)?.metadata
const amount = metadata ? formatTokenAmount(rawAmount, metadata) : ''
if (amount.length > 20) {
return 'INFINITE'
}
return amount
} else {
return getFormattedAmountFromActivity(
_activity.tokenTransfer.rawAmount,
_activity.tokenTransfer.tokenId,
_activity
)
}
}
} else {
return '-'
Expand Down

0 comments on commit 45a776b

Please sign in to comment.