mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-01-22 09:19:28 +00:00
feat: add to fixed util function
This commit is contained in:
parent
cb05a57185
commit
60f6776417
@ -38,3 +38,15 @@ export const getFormattedWalletAddress = (address: string) => {
|
||||
// 0xb9dasdfc35 -> 0xb9d...c35
|
||||
return `${address.slice(0, 5)}...${address.slice(-3)}`
|
||||
}
|
||||
|
||||
export const formatToFixed4 = (value: number) => {
|
||||
const str = value.toString()
|
||||
const decimalPart = str.split('.')[1]
|
||||
const decimalLength = decimalPart ? decimalPart.length : 0
|
||||
|
||||
if (decimalLength > 4) {
|
||||
return value.toFixed(4)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user