@@ -30,6 +30,8 @@ import {
30
30
import Name from '../../../../../../../../components/app/name/name' ;
31
31
import { TokenDetailsERC20 } from '../../../../../../utils/token' ;
32
32
import { getAmountColors } from '../../../utils' ;
33
+ import { useI18nContext } from '../../../../../../../../hooks/useI18nContext' ;
34
+ import { UNLIMITED_THRESHOLD } from '../../../approve/hooks/use-approve-token-simulation' ;
33
35
34
36
type PermitSimulationValueDisplayParams = {
35
37
/** ID of the associated chain. */
@@ -69,6 +71,8 @@ const PermitSimulationValueDisplay: React.FC<
69
71
credit,
70
72
debit,
71
73
} ) => {
74
+ const t = useI18nContext ( ) ;
75
+
72
76
const exchangeRate = useTokenExchangeRate ( tokenContract ) ;
73
77
74
78
const tokenDetails = useGetTokenStandardAndDetails ( tokenContract ) ;
@@ -88,18 +92,24 @@ const PermitSimulationValueDisplay: React.FC<
88
92
return undefined ;
89
93
} , [ exchangeRate , tokenDecimals , value ] ) ;
90
94
91
- const { tokenValue, tokenValueMaxPrecision } = useMemo ( ( ) => {
92
- if ( ! value || tokenId ) {
93
- return { tokenValue : null , tokenValueMaxPrecision : null } ;
94
- }
95
+ const { tokenValue, tokenValueMaxPrecision, shouldShowUnlimitedValue } =
96
+ useMemo ( ( ) => {
97
+ if ( ! value || tokenId ) {
98
+ return {
99
+ tokenValue : null ,
100
+ tokenValueMaxPrecision : null ,
101
+ shouldShowUnlimitedValue : false ,
102
+ } ;
103
+ }
95
104
96
- const tokenAmount = calcTokenAmount ( value , tokenDecimals ) ;
105
+ const tokenAmount = calcTokenAmount ( value , tokenDecimals ) ;
97
106
98
- return {
99
- tokenValue : formatAmount ( 'en-US' , tokenAmount ) ,
100
- tokenValueMaxPrecision : formatAmountMaxPrecision ( 'en-US' , tokenAmount ) ,
101
- } ;
102
- } , [ tokenDecimals , value ] ) ;
107
+ return {
108
+ tokenValue : formatAmount ( 'en-US' , tokenAmount ) ,
109
+ tokenValueMaxPrecision : formatAmountMaxPrecision ( 'en-US' , tokenAmount ) ,
110
+ shouldShowUnlimitedValue : Number ( value ) > UNLIMITED_THRESHOLD ,
111
+ } ;
112
+ } , [ tokenDecimals , value ] ) ;
103
113
104
114
/** Temporary error capturing as we are building out Permit Simulations */
105
115
if ( ! tokenContract ) {
@@ -138,13 +148,15 @@ const PermitSimulationValueDisplay: React.FC<
138
148
>
139
149
{ credit && '+ ' }
140
150
{ debit && '- ' }
141
- { tokenValue !== null &&
142
- shortenString ( tokenValue || '' , {
143
- truncatedCharLimit : 15 ,
144
- truncatedStartChars : 15 ,
145
- truncatedEndChars : 0 ,
146
- skipCharacterInEnd : true ,
147
- } ) }
151
+ { shouldShowUnlimitedValue
152
+ ? t ( 'unlimited' )
153
+ : tokenValue !== null &&
154
+ shortenString ( tokenValue || '' , {
155
+ truncatedCharLimit : 15 ,
156
+ truncatedStartChars : 15 ,
157
+ truncatedEndChars : 0 ,
158
+ skipCharacterInEnd : true ,
159
+ } ) }
148
160
{ tokenId && `#${ tokenId } ` }
149
161
</ Text >
150
162
</ Tooltip >
0 commit comments