use existing util
This commit is contained in:
parent
0fc1239445
commit
dc6bd2b015
@ -6,8 +6,6 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -124,12 +122,6 @@ func ParseFIL(s string) (FIL, error) {
|
|||||||
return FIL{r.Num()}, nil
|
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 {
|
func MustParseFIL(s string) FIL {
|
||||||
n, err := ParseFIL(s)
|
n, err := ParseFIL(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -647,9 +647,9 @@ var walletMarketWithdraw = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn))
|
fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn))
|
||||||
if withdrawn.LessThan(amt) {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ var actorWithdrawCmd = &cli.Command{
|
|||||||
amount = abi.TokenAmount(f)
|
amount = abi.TokenAmount(f)
|
||||||
|
|
||||||
if amount.GreaterThan(available) {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn))
|
fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn))
|
||||||
if withdrawn.LessThan(amount) {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ var actorWithdrawCmd = &cli.Command{
|
|||||||
amount = abi.TokenAmount(f)
|
amount = abi.TokenAmount(f)
|
||||||
|
|
||||||
if amount.GreaterThan(available) {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Successfully withdrew %s \n", types.ParseAttoFilToFIL(withdrawn))
|
fmt.Printf("Successfully withdrew %s \n", types.FIL(withdrawn))
|
||||||
if withdrawn.LessThan(amount) {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user