Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/cosmos/voyager into fede…
Browse files Browse the repository at this point in the history
…kunze/1472-redelegation-lcdClientMock

Merge develop
  • Loading branch information
Federico Kunze committed Oct 26, 2018
2 parents d342161 + a0c9035 commit 5901e94
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* catching errors on cache encryption. @faboweb
* #1436 governance endpoints and vuex module @fedekunze
* [\#1482](https://github.com/cosmos/voyager/issues/1482) Added ESLint errors: no-var. @sgobotta
* [\#1449](https://github.com/cosmos/voyager/issues/1449) shortNumber to num scripts for more readable numbers. @jbibla

### Changed

Expand All @@ -23,12 +24,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Updated contribution guidelines. @faboweb
* [\#1447](https://github.com/cosmos/voyager/issues/1447) Removed titles from all pages. @faboweb
* Updated PR template @fedekunze
* [\#1473](https://github.com/cosmos/voyager/issues/1473) added "percent of vote" to validator in vuex module instead of in component @jbibla

### Fixed

* Fixed gaia binary not be found on linux and windows in development @faboweb
* [\#1419](https://github.com/cosmos/voyager/issues/1419) Restored "Amount" label to delegation modal. @NodeGuy
* Fixed upstream cross compilation issue from SDK @faboweb
* [\#1487](https://github.com/cosmos/voyager/issues/1487) Fixed running of local testnet. @NodeGuy

## [0.10.7] - 2018-10-10

Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
img.icon(src="~assets/images/cosmos-logo.png")
.total-atoms.top-section
h3 Total {{bondingDenom}}
h2 {{this.num.full(totalAtoms)}}
h2 {{this.num.shortNumber(totalAtoms)}}
.unbonded-atoms.top-section(v-if="unbondedAtoms")
h3 Unbonded {{bondingDenom}}
h2 {{unbondedAtoms}}
Expand Down Expand Up @@ -50,7 +50,7 @@ export default {
return this.user.address
},
unbondedAtoms() {
return this.num.full(this.user.atoms)
return this.num.shortNumber(this.user.atoms)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/components/staking/LiValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ li.li-validator(:class='styles')
.top {{ validator.description.moniker }}
short-bech32(:address="validator.operator_address")
.li-validator__value.your-votes
span {{ yourVotes.isLessThan(0.01) && yourVotes.isGreaterThan(0) ? '< ' + num.full(0.01) : num.full(yourVotes) }}
span {{ yourVotes.isLessThan(0.01) && yourVotes.isGreaterThan(0) ? '< ' + num.shortNumber(0.01) : num.shortNumber(yourVotes) }}
.li-validator__value.your-rewards
span n/a
.li-validator__break: span
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tm-page(data-title="Validator")
.row.validator-profile__header__data
dl.colored_dl
dt Bonded {{bondingDenom}}
dd {{myBond.isLessThan(0.01) && myBond.isGreaterThan(0) ? '< ' + 0.01 : num.full(myBond)}}
dd {{myBond.isLessThan(0.01) && myBond.isGreaterThan(0) ? '< ' + 0.01 : num.shortNumber(myBond)}}
dl.colored_dl(v-if="config.devMode")
dt My Rewards
dd n/a
Expand Down Expand Up @@ -77,7 +77,7 @@ tm-page(data-title="Validator")
dt Max Daily Commission Change
dd {{validator.commission.max_change_rate}} %
dl.info_dl
dt Last Commission Change
dt Last Commission Change
dd {{new Date(validator.commission.update_time).getTime() === 0 ? 'Never' : moment(new Date(validator.commission.update_time)).fromNow() }}
dl.info_dl
dt Self Bonded {{bondingDenom}}
Expand Down
7 changes: 6 additions & 1 deletion app/src/renderer/connectors/lcdClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ const Client = (axios, localLcdURL, remoteLcdURL) => {

seed: () => keys.get(`seed`),
set: argReq(`PUT`, `/keys`),
values: req(`GET`, `/keys`)

values: async () => {
const values = await req(`GET`, `/keys`)()
// Workaround for https://github.com/cosmos/cosmos-sdk/issues/2470
return values === `[]` ? [] : values
}
}

return {
Expand Down
4 changes: 4 additions & 0 deletions app/src/renderer/scripts/num.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ function usdInt(num) {
function full(num) {
return numeral(num).format(`0,0.0000000000`)
}
function shortNumber(num) {
return numeral(num).format(`0,0.0000`) + `…`
}
function pretty(num) {
return numeral(num).format(`0,0.00`)
}
Expand Down Expand Up @@ -45,6 +48,7 @@ module.exports = {
usd,
usdInt,
full,
shortNumber,
pretty,
prettyInt,
short,
Expand Down
18 changes: 11 additions & 7 deletions app/src/renderer/vuex/modules/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import BN from "bignumber.js"
import { ratToBigNumber } from "scripts/common"
import num from "scripts/num"
import { isEmpty } from "lodash"
export default ({ node }) => {
const emptyState = {
Expand All @@ -16,18 +17,21 @@ export default ({ node }) => {
state.loading = loading
},
setDelegates(state, validators) {
validators.forEach(validator => {
validator.id = validator.operator_address
validator.voting_power = ratToBigNumber(validator.tokens)
})
state.delegates = validators

// update global power for quick access
state.globalPower = state.delegates
state.globalPower = validators
.reduce((sum, validator) => {
return sum.plus(ratToBigNumber(validator.tokens))
}, new BN(0))
.toNumber()

validators.forEach(validator => {
validator.id = validator.operator_address
validator.voting_power = ratToBigNumber(validator.tokens)
validator.percent_of_vote = num.percent(
validator.voting_power / state.globalPower
)
})
state.delegates = validators
},
setSelfBond(
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ exports[`TmBalance has the expected html structure before adding props 1`] = `
Total Steak
</h3>
<h2>
321.0000000000
321.0000…
</h2>
</div>
<div class=\\"unbonded-atoms top-section\\">
<h3>
Unbonded Steak
</h3>
<h2>
123.0000000000
123.0000…
</h2>
</div>
<!---->
Expand Down Expand Up @@ -48,15 +48,15 @@ exports[`TmBalance shows correct stats depending on props 1`] = `
Total Steak
</h3>
<h2>
321.0000000000
321.0000…
</h2>
</div>
<div class=\\"unbonded-atoms top-section\\">
<h3>
Unbonded Steak
</h3>
<h2>
123.0000000000
123.0000…
</h2>
</div>
<div class=\\"total-earnings top-section\\">
Expand Down
1 change: 1 addition & 0 deletions test/unit/specs/components/staking/PageValidator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ describe(`onDelegation`, () => {
id: lcdClientMock.validators[0],
keybase: undefined,
operator_address: lcdClientMock.validators[0],
percent_of_vote: `65.52%`,
prev_bonded_shares: `0`,
proposer_reward_pool: null,
pub_key: `cosmoschiapudding123456789`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ exports[`LiValidator has the expected html structure 1`] = `
class="li-validator__value your-votes"
>
<span>
0.0000000000
0.0000…
</span>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ exports[`PageStaking has the expected html structure 1`] = `
Total Steak
</h3>
<h2>
1,351.0000000000
1,351.0000…
</h2>
</div>
<div class=\\"unbonded-atoms top-section\\">
<h3>
Unbonded Steak
</h3>
<h2>
1,337.0000000000
1,337.0000…
</h2>
</div>
<!---->
Expand Down Expand Up @@ -85,15 +85,15 @@ exports[`PageStaking has the expected html structure 1`] = `
Total Steak
</h3>
<h2>
1,351.0000000000
1,351.0000…
</h2>
</div>
<div class=\\"unbonded-atoms top-section\\">
<h3>
Unbonded Steak
</h3>
<h2>
1,337.0000000000
1,337.0000…
</h2>
</div>
<!---->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`PageValidator has the expected html structure 1`] = `
Total Steak
</h3>
<h2>
123.4567800000
123.4568…
</h2>
</div>
<div
Expand All @@ -50,7 +50,7 @@ exports[`PageValidator has the expected html structure 1`] = `
Unbonded Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<!---->
Expand Down Expand Up @@ -221,7 +221,7 @@ exports[`PageValidator has the expected html structure 1`] = `
Bonded Steak
</dt>
<dd>
123.4567800000
123.4568…
</dd>
</dl>
<dl
Expand Down Expand Up @@ -385,7 +385,7 @@ exports[`PageValidator has the expected html structure 1`] = `
class="info_dl"
>
<dt>
Last Commission Change
Last Commission Change
</dt>
<dd>
a few seconds ago
Expand Down Expand Up @@ -483,7 +483,7 @@ exports[`PageValidator shows a default avatar 1`] = `
Total Steak
</h3>
<h2>
123.4567800000
123.4568…
</h2>
</div>
<div
Expand All @@ -493,7 +493,7 @@ exports[`PageValidator shows a default avatar 1`] = `
Unbonded Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<!---->
Expand Down Expand Up @@ -664,7 +664,7 @@ exports[`PageValidator shows a default avatar 1`] = `
Bonded Steak
</dt>
<dd>
123.4567800000
123.4568…
</dd>
</dl>
<dl
Expand Down Expand Up @@ -828,7 +828,7 @@ exports[`PageValidator shows a default avatar 1`] = `
class="info_dl"
>
<dt>
Last Commission Change
Last Commission Change
</dt>
<dd>
a few seconds ago
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports[`TabValidators has the expected html structure 1`] = `
</div>
</div>
<div class=\\"li-validator__value your-votes\\">
<span>0.0000000000</span>
<span>0.0000…</span>
</div>
<div class=\\"li-validator__value your-rewards\\">
<span>n/a</span>
Expand Down Expand Up @@ -113,7 +113,7 @@ exports[`TabValidators has the expected html structure 1`] = `
</div>
</div>
<div class=\\"li-validator__value your-votes\\">
<span>0.0000000000</span>
<span>0.0000…</span>
</div>
<div class=\\"li-validator__value your-rewards\\">
<span>n/a</span>
Expand Down Expand Up @@ -154,7 +154,7 @@ exports[`TabValidators has the expected html structure 1`] = `
</div>
</div>
<div class=\\"li-validator__value your-votes\\">
<span>0.0000000000</span>
<span>0.0000…</span>
</div>
<div class=\\"li-validator__value your-rewards\\">
<span>n/a</span>
Expand Down Expand Up @@ -333,7 +333,7 @@ exports[`TabValidators should filter the delegates 1`] = `
class="li-validator__value your-votes"
>
<span>
0.0000000000
0.0000…
</span>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`PageTransactions has the expected html structure 1`] = `
Total Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<div
Expand All @@ -50,7 +50,7 @@ exports[`PageTransactions has the expected html structure 1`] = `
Unbonded Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<!---->
Expand Down Expand Up @@ -262,7 +262,7 @@ exports[`PageTransactions should filter the transactions 1`] = `
Total Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<div
Expand All @@ -272,7 +272,7 @@ exports[`PageTransactions should filter the transactions 1`] = `
Unbonded Steak
</h3>
<h2>
0.0000000000
0.0000…
</h2>
</div>
<!---->
Expand Down
Loading

0 comments on commit 5901e94

Please sign in to comment.