From 0fd71d283995dbcd6abfcb8f4eefafab559ea976 Mon Sep 17 00:00:00 2001 From: Nicolas Mosconi Date: Thu, 4 Jul 2019 17:14:59 -0300 Subject: [PATCH] Fix asset formatting for tokens with a precision other than 4 --- cli/formatting.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/formatting.go b/cli/formatting.go index 0214a687..2ef5f7ca 100644 --- a/cli/formatting.go +++ b/cli/formatting.go @@ -3,6 +3,7 @@ package cli import ( "bytes" "fmt" + "math" "strconv" "text/tabwriter" @@ -239,7 +240,7 @@ func prettifyTime(micro int64) string { } func prettifyAsset(w eos.Asset) string { - const unit = 10000 + unit := math.Pow10(int(w.Precision)) formatting := fmt.Sprintf("%%.%df", w.Precision) return rightAlignColumnize(fmt.Sprintf(formatting, float64(w.Amount)/float64(unit)), w.Symbol.Symbol)