use existing util

This commit is contained in:
Jennifer Wang 2021-10-26 20:51:40 -04:00
parent 0fc1239445
commit dc6bd2b015
4 changed files with 8 additions and 16 deletions

View File

@ -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 {

View File

@ -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))
}
}

View File

@ -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))
}
}

View File

@ -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))
}
}