diff --git a/chain/types/fil.go b/chain/types/fil.go index 21125e6d6..4c26414a9 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -3,6 +3,7 @@ package types import ( "encoding" "fmt" + "github.com/filecoin-project/go-state-types/abi" "math/big" "strings" @@ -122,6 +123,13 @@ func ParseFIL(s string) (FIL, error) { return FIL{r.Num()}, nil } + +func ParseAttoFilToFIL(atto abi.TokenAmount) string { + vfil := big.NewFloat(0) + vfil.Add(vfil, new(big.Float).SetInt(atto.Int)) + return new(big.Float).Quo(vfil, big.NewFloat(float64(build.FilecoinPrecision))).String() + " FIL" +} + func MustParseFIL(s string) FIL { n, err := ParseFIL(s) if err != nil { diff --git a/cli/wallet.go b/cli/wallet.go index f7ad79e77..f70af7926 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -647,9 +647,9 @@ var walletMarketWithdraw = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s FIL\n", withdrawn) + fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) if withdrawn.LessThan(amt) { - fmt.Printf("Note that this is less than the requested amount of %s FIL\n", amt) + fmt.Printf("Note that this is less than the requested amount of %s \n", types.ParseAttoFilToFIL(amt)) } } diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index c5c9f572a..a5ea16804 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -306,9 +306,9 @@ var actorWithdrawCmd = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s FIL\n", withdrawn) + fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) if withdrawn.LessThan(amount) { - fmt.Printf("Note that this is less than the requested amount of %s FIL\n", amount) + fmt.Printf("Note that this is less than the requested amount of %s FIL\n", types.ParseAttoFilToFIL(amount)) } } diff --git a/cmd/lotus-shed/actor.go b/cmd/lotus-shed/actor.go index 822159bb4..16d90d4a1 100644 --- a/cmd/lotus-shed/actor.go +++ b/cmd/lotus-shed/actor.go @@ -151,9 +151,9 @@ var actorWithdrawCmd = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s FIL\n", withdrawn) + fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) if withdrawn.LessThan(amount) { - fmt.Printf("Note that this is less than the requested amount of %s FIL\n", amount) + fmt.Printf("Note that this is less than the requested amount of %s \n", types.ParseAttoFilToFIL(amount)) } }