Implment formatter on FIL to override big.Int

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2019-10-30 01:52:24 +01:00
parent d080dbd1ec
commit bc97a73d67
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
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
},
}