Skip to content

Commit

Permalink
CLI: Show fractionals as decimals
Browse files Browse the repository at this point in the history
🐛 Fix cosmos#1353

before:
```
Shares: Status Bonded,  Amount: -6508168128760126341/-3308135364330552608
Delegator Shares: -6508168128760126341/-3308135364330552608
```
after:
```
Shares: Status Bonded,  Amount: 2.0000000000
Delegator Shares: 2.0000000000
```
  • Loading branch information
MD committed Jun 24, 2018
1 parent c671181 commit 05bc706
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions types/rational.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (r Rat) Quo(r2 Rat) Rat { return Rat{*new(big.Rat).Quo(&(r.Rat), &(r2.Ra
func (r Rat) Add(r2 Rat) Rat { return Rat{*new(big.Rat).Add(&(r.Rat), &(r2.Rat))} } // Add - addition
func (r Rat) Sub(r2 Rat) Rat { return Rat{*new(big.Rat).Sub(&(r.Rat), &(r2.Rat))} } // Sub - subtraction
func (r Rat) String() string { return fmt.Sprintf("%v/%v", r.Num(), r.Denom()) }
func (r Rat) FloatString() string { return fmt.Sprintf("%v", r.Rat.FloatString(10)) }

var (
zero = big.NewInt(0)
Expand Down
4 changes: 2 additions & 2 deletions x/stake/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ func (v Validator) HumanReadableString() (string, error) {
resp := "Validator \n"
resp += fmt.Sprintf("Owner: %s\n", bechOwner)
resp += fmt.Sprintf("Validator: %s\n", bechVal)
resp += fmt.Sprintf("Shares: Status %s, Amount: %s\n", sdk.BondStatusToString(v.PoolShares.Status), v.PoolShares.Amount.String())
resp += fmt.Sprintf("Delegator Shares: %s\n", v.DelegatorShares.String())
resp += fmt.Sprintf("Shares: Status %s, Amount: %s\n", sdk.BondStatusToString(v.PoolShares.Status), v.PoolShares.Amount.FloatString())
resp += fmt.Sprintf("Delegator Shares: %s\n", v.DelegatorShares.FloatString())
resp += fmt.Sprintf("Description: %s\n", v.Description)
resp += fmt.Sprintf("Bond Height: %d\n", v.BondHeight)
resp += fmt.Sprintf("Proposer Reward Pool: %s\n", v.ProposerRewardPool.String())
Expand Down

0 comments on commit 05bc706

Please sign in to comment.