Skip to content

Commit

Permalink
use existing util
Browse files Browse the repository at this point in the history
  • Loading branch information
jennijuju committed Oct 27, 2021
1 parent 0fc1239 commit dc6bd2b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
8 changes: 0 additions & 8 deletions chain/types/fil.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"math/big"
"strings"

"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/build"
)

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/lotus-miner/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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))
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/lotus-shed/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit dc6bd2b

Please sign in to comment.