@@ -133,6 +133,7 @@ export const amountInput = (context: SendContext) => {
133133 minimumBalanceForRentExemptionSol,
134134 preferences : { locale } ,
135135 feeEstimatedInSol,
136+ selectedTokenMetadata,
136137 } = context ;
137138 const translate = i18n ( locale ) ;
138139
@@ -153,33 +154,19 @@ export const amountInput = (context: SendContext) => {
153154 const minimumBalanceForRentExemptionLamports = solToLamports (
154155 minimumBalanceForRentExemptionSol ?? '0' ,
155156 ) ;
156-
157- // If the value parses to 0, it's invalid but we don't want to show an error
158- if ( tokenAmountLamports . isZero ( ) ) {
159- return { message : '' , value } ;
160- }
157+ const solBalance = getNativeTokenBalance ( context ) ;
158+ const solBalanceLamports = solToLamports ( solBalance ) ;
159+ const isNativeToken = getIsNativeToken ( context ) ;
161160
162161 // If you try to send more than your balance, it's invalid
163162 const isAmountGreaterThanBalance = tokenAmountLamports . gt ( balanceLamports ) ;
164163 if ( isAmountGreaterThanBalance ) {
165164 return {
166- message : translate ( 'send.insufficientBalance' ) ,
165+ message : ` ${ translate ( 'send.insufficientBalance' ) } : ${ balance } ${ selectedTokenMetadata ?. symbol ?? '' } ` ,
167166 value,
168167 } ;
169168 }
170169
171- // If you have 0 SOL, you can't pay for the fee, it's invalid
172- const solBalance = getNativeTokenBalance ( context ) ;
173- const solBalanceLamports = solToLamports ( solBalance ) ;
174- if ( solBalanceLamports . isZero ( ) ) {
175- return {
176- message : translate ( 'send.insuffientSolToCoverFee' ) ,
177- value,
178- } ;
179- }
180-
181- const isNativeToken = getIsNativeToken ( context ) ;
182-
183170 if ( isNativeToken ) {
184171 // If the value is lower than the minimum balance for rent exemption, it's invalid
185172 const valueLowerThanMinimum = tokenAmountLamports . lt (
@@ -225,6 +212,19 @@ export const amountInput = (context: SendContext) => {
225212 }
226213 }
227214
215+ // If the value parses to 0, it's invalid but we don't want to show an error
216+ if ( tokenAmountLamports . isZero ( ) ) {
217+ return { message : '' , value } ;
218+ }
219+
220+ // If you have 0 SOL, you can't pay for the fee, it's invalid
221+ if ( solBalanceLamports . isZero ( ) ) {
222+ return {
223+ message : translate ( 'send.insuffientSolToCoverFee' ) ,
224+ value,
225+ } ;
226+ }
227+
228228 return null ;
229229 } ;
230230} ;
0 commit comments