Skip to content

Commit

Permalink
Merge PR 1354: CLI: Show fractional in human-readable format
Browse files Browse the repository at this point in the history
Fix #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
7768 authored and Adrian Brink committed Jul 2, 2018
1 parent c692d28 commit 62dc17f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FIXES
* Fixed bug where chain ID wasn't passed properly in x/bank REST handler
* Fixed bug where `democli account` didn't decode the account data correctly
* \#1343 - fixed unnecessary parallelism in CI
* \#1353 - CLI: Show pool shares fractions in human-readable format
* \#1258 - printing big.rat's can no longer overflow int64

## 0.19.0
Expand Down
1 change: 1 addition & 0 deletions types/rational.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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 r.Rat.String() }
func (r Rat) FloatString() string { return r.Rat.FloatString(10) } // a human-friendly string format. The last digit is rounded to nearest, with halves rounded away from zero.

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 @@ -272,8 +272,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 62dc17f

Please sign in to comment.