Skip to content
Snippets Groups Projects
Commit a9d3d99c authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

adapt balance format

parent 700c1890
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,11 @@ export function formatStatus(txt: string) {
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
}
export function balFmt(amount: u64 | number): string {
export function balFmt(amount: u64 | number | BigInt): string {
if (!tokenDecimals.value || !tokenSymbol.value) return amount.toString()
const fmt = new Intl.NumberFormat()
const [td, ts] = [tokenDecimals.value!, tokenSymbol.value!]
const amountBN = new BN(amount)
const amountBN = new BN(amount.toString())
const decimalDivisor = new BN(10).pow(new BN(td))
const wholePart = amountBN.div(decimalDivisor)
const localizedWholePart = fmt.format(wholePart.toNumber())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment