import BigNumber from 'bignumber.js' ; import { initBigNumber } from '@app/common/utils' ; import { microStxToStx } from '@app/common/stacks-utils' ; import { SendFormErrorMessages } from '@app/common/error-messages' ; export function formatPrecisionError ( symbol , decimals ) { const error = SendFormErrorMessages . TooMuchPrecision ; return error . replace ( '{token}' , symbol ) . replace ( '{decimals}' , String ( decimals ) ) ; } export function formatInsufficientBalanceError ( availableBalance ? , symbol ? ) { if ( ! availableBalance || ! symbol ) return ; const isStx = symbol === 'STX' ; const amount = initBigNumber ( availableBalance ) ; const formattedAmount = isStx ? microStxToStx ( amount ) . toString ( ) : amount . toString ( 10 ) ; return `${ SendFormErrorMessages . InsufficientBalance } ${ amount . lt ( 0 ) ? '0' : formattedAmount } ${ symbol }` ; }