fix: string prop for to fixed util func

This commit is contained in:
RadoslavDimchev 2023-10-11 21:45:48 +03:00
parent 60f6776417
commit 1ce29acc46

View File

@ -39,14 +39,12 @@ export const getFormattedWalletAddress = (address: string) => {
return `${address.slice(0, 5)}...${address.slice(-3)}`
}
export const formatToFixed4 = (value: number) => {
const str = value.toString()
const decimalPart = str.split('.')[1]
export const formatToFixed4 = (value: string) => {
const decimalPart = value.split('.')[1]
const decimalLength = decimalPart ? decimalPart.length : 0
if (decimalLength > 4) {
return value.toFixed(4)
return Number(value).toFixed(4)
}
return str
return value
}