parse attofil to fil
This commit is contained in:
parent
6607019788
commit
18834de7d0
@ -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 {
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user