Merge pull request #496 from filecoin-project/fix/fmt-FIL

Implment formatter on FIL to override big.Int
This commit is contained in:
Łukasz Magiera 2019-10-30 08:29:56 +01:00 committed by GitHub
commit 981f108565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,15 @@ func (f FIL) String() string {
return strings.TrimRight(r.FloatString(18), "0.")
}
func (f FIL) Format(s fmt.State, ch rune) {
switch ch {
case 's', 'v':
fmt.Fprint(s, f.String())
default:
f.Int.Format(s, ch)
}
}
func ParseFIL(s string) (FIL, error) {
r, ok := new(big.Rat).SetString(s)
if !ok {

View File

@ -197,7 +197,7 @@ var statePledgeCollateralCmd = &cli.Command{
return err
}
fmt.Println(types.FIL(coll).String())
fmt.Println(types.FIL(coll))
return nil
},
}

View File

@ -105,7 +105,7 @@ var walletBalance = &cli.Command{
return err
}
fmt.Printf("%s\n", types.FIL(balance).String())
fmt.Printf("%s\n", types.FIL(balance))
return nil
},
}