From 18834de7d00ba6cf54f9a417856282c7bad7e6a2 Mon Sep 17 00:00:00 2001 From: Jennifer Wang Date: Tue, 26 Oct 2021 19:32:16 -0400 Subject: [PATCH 1/3] parse attofil to fil --- chain/types/fil.go | 8 ++++++++ cli/wallet.go | 4 ++-- cmd/lotus-miner/actor.go | 4 ++-- cmd/lotus-shed/actor.go | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/chain/types/fil.go b/chain/types/fil.go index 21125e6d617..4c26414a9cb 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 f7ad79e7795..f70af79267c 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 c5c9f572afb..a5ea1680470 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 822159bb4e4..16d90d4a129 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)) } } From 0fc123944521dda7a020989f7f1956e11546e839 Mon Sep 17 00:00:00 2001 From: Jennifer Wang Date: Tue, 26 Oct 2021 19:42:57 -0400 Subject: [PATCH 2/3] make jen --- chain/types/fil.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/types/fil.go b/chain/types/fil.go index 4c26414a9cb..79f67fb951a 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -3,10 +3,11 @@ package types import ( "encoding" "fmt" - "github.com/filecoin-project/go-state-types/abi" "math/big" "strings" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/build" ) @@ -123,7 +124,6 @@ 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)) From dc6bd2b0152fdd931161822374f10e9839b78b93 Mon Sep 17 00:00:00 2001 From: Jennifer Wang Date: Tue, 26 Oct 2021 20:51:40 -0400 Subject: [PATCH 3/3] use existing util --- chain/types/fil.go | 8 -------- cli/wallet.go | 4 ++-- cmd/lotus-miner/actor.go | 6 +++--- cmd/lotus-shed/actor.go | 6 +++--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/chain/types/fil.go b/chain/types/fil.go index 79f67fb951a..21125e6d617 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -6,8 +6,6 @@ import ( "math/big" "strings" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/build" ) @@ -124,12 +122,6 @@ 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 f70af79267c..9faa10677dd 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -647,9 +647,9 @@ var walletMarketWithdraw = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) + fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn)) if withdrawn.LessThan(amt) { - fmt.Printf("Note that this is less than the requested amount of %s \n", types.ParseAttoFilToFIL(amt)) + fmt.Printf("Note that this is less than the requested amount of %s \n", types.FIL(amt)) } } diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index a5ea1680470..6c4611327e1 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -257,7 +257,7 @@ var actorWithdrawCmd = &cli.Command{ amount = abi.TokenAmount(f) if amount.GreaterThan(available) { - return xerrors.Errorf("can't withdraw more funds than available; requested: %s; available: %s", amount, available) + return xerrors.Errorf("can't withdraw more funds than available; requested: %s; available: %s", types.FIL(amount), types.FIL(available)) } } @@ -306,9 +306,9 @@ var actorWithdrawCmd = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) + fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn)) if withdrawn.LessThan(amount) { - fmt.Printf("Note that this is less than the requested amount of %s FIL\n", types.ParseAttoFilToFIL(amount)) + fmt.Printf("Note that this is less than the requested amount of %s\n", types.FIL(amount)) } } diff --git a/cmd/lotus-shed/actor.go b/cmd/lotus-shed/actor.go index 16d90d4a129..7ddc79b1835 100644 --- a/cmd/lotus-shed/actor.go +++ b/cmd/lotus-shed/actor.go @@ -104,7 +104,7 @@ var actorWithdrawCmd = &cli.Command{ amount = abi.TokenAmount(f) if amount.GreaterThan(available) { - return xerrors.Errorf("can't withdraw more funds than available; requested: %s; available: %s", amount, available) + return xerrors.Errorf("can't withdraw more funds than available; requested: %s; available: %s", types.FIL(amount), types.FIL(available)) } } @@ -151,9 +151,9 @@ var actorWithdrawCmd = &cli.Command{ return err } - fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn)) + fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn)) if withdrawn.LessThan(amount) { - fmt.Printf("Note that this is less than the requested amount of %s \n", types.ParseAttoFilToFIL(amount)) + fmt.Printf("Note that this is less than the requested amount of %s \n", types.FIL(amount)) } }