Implment formatter on FIL to override big.Int
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
d080dbd1ec
commit
bc97a73d67
@ -15,6 +15,15 @@ func (f FIL) String() string {
|
|||||||
return strings.TrimRight(r.FloatString(18), "0.")
|
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) {
|
func ParseFIL(s string) (FIL, error) {
|
||||||
r, ok := new(big.Rat).SetString(s)
|
r, ok := new(big.Rat).SetString(s)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -197,7 +197,7 @@ var statePledgeCollateralCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(types.FIL(coll).String())
|
fmt.Println(types.FIL(coll))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ var walletBalance = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s\n", types.FIL(balance).String())
|
fmt.Printf("%s\n", types.FIL(balance))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user