Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jordan/2267+2278 validator table bugs #2300

Merged
merged 17 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Added

- [\#2228](https://github.com/cosmos/voyager/issues/2228) display balances of vesting accounts @faboweb
- [\#2230](https://github.com/cosmos/voyager/issues/2230) calculate fees and estimated transaction gas @fedekunze
- [\#2291](https://github.com/cosmos/voyager/pull/2291) master built against main net full node @sabau

### Fixed

- [\#2269](https://github.com/cosmos/voyager/pull/2269) Persist session type if signed in with ledger @faboweb
- [\#2273](https://github.com/cosmos/voyager/issues/2273) fixed atoms and uatoms conversion @fedekunze
- [\#2267](https://github.com/cosmos/voyager/issues/2267) fixed sorting on validator table @jbibla
- [\#2278](https://github.com/cosmos/voyager/issues/2278) fixed commission calculation on validator table @jbibla
123 changes: 33 additions & 90 deletions app/src/renderer/components/staking/LiValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
name: 'validator',
params: { validator: validator.operator_address }
}"
:class="styles"
class="data-table__row__info__container__name"
>
{{ validator.description.moniker }}
Expand All @@ -41,35 +40,38 @@
</td>
<td class="li-validator__delegated-steak">
{{
yourVotes.isLessThan(0.01) && yourVotes.isGreaterThan(0)
? num.shortNumber(0.01)
: num.shortNumber(yourVotes)
validator.my_delegations
? num.shortNumber(num.atoms(validator.my_delegations))
: `--`
}}
</td>
<td class="li-validator__rewards data-table__row__cell__separator">
{{ rewards || "--" }}
<td class="li-validator__rewards">
{{
validator.rewards
? num.shortNumber(num.atoms(validator.rewards.uatom))
: `--`
}}
</td>
<td class="li-validator__voting-power">
{{ validator.percent_of_vote ? validator.percent_of_vote : `--` }}
</td>
<td class="li-validator__uptime">
{{ uptime }}
{{
validator.percent_of_vote
? num.percent(validator.percent_of_vote)
: `--`
}}
</td>
<td class="li-validator__commission">
{{ commission }}
{{ validator.commission ? num.percent(validator.commission) : `--` }}
</td>
<td class="li-validator__slashes">
--
<td class="li-validator__uptime">
{{ validator.uptime ? num.percent(validator.uptime) : `--` }}
</td>
</tr>
</template>

<script>
import { mapGetters } from "vuex"
import num from "scripts/num"
import { calculateTokens, ratToBigNumber } from "scripts/common"
import ShortBech32 from "common/ShortBech32"
import BigNumber from "bignumber.js"
export default {
name: `li-validator`,
components: {
Expand All @@ -80,110 +82,51 @@ export default {
type: Object,
required: true
},
disabled: {
type: Boolean,
required: true
}
},
data: () => ({ num }),
computed: {
...mapGetters([
`delegates`,
`committedDelegations`,
`distribution`,
`bondDenom`,
`session`,
`lastHeader`
]),
commission() {
return `${this.num.pretty(this.validator.commission.rate)}%`
},
uptime() {
const rollingWindow = 10000 // param of slashing period
const info = this.validator.signing_info
if (info) {
// uptime in the past 10k blocks
const uptimeRollingWindow =
(rollingWindow - info.missed_blocks_counter) / rollingWindow
return num.percent(uptimeRollingWindow)
}
return `--`
},
yourVotes() {
return this.committedDelegations[this.validator.operator_address]
? BigNumber(
num
.atoms(
calculateTokens(
this.validator,
this.committedDelegations[this.validator.operator_address]
)
)
.toString()
)
: BigNumber(0)
},
styles() {
let value = ``
if (this.validator.isValidator) value += `li-validator-validator `
return value
},
delegateType() {
return this.validator.revoked
? `Revoked`
: this.validator.isValidator
? `Validator`
: `Candidate`
},
powerRatio() {
return ratToBigNumber(this.validator.tokens)
.div(this.delegates.globalPower)
.toNumber()
},
status() {
// status: jailed
if (this.validator.revoked)
if (this.validator.jailed)
return `This validator has been jailed and is not currently validating`

// status: inactive
if (parseFloat(this.validator.voting_power) === 0)
return `This validator does not have enough voting power yet and is inactive`
return `This validator does not have enough voting power and is inactive`

// status: active
return `This validator is actively validating`
},
statusColor() {
// status: jailed
if (this.validator.revoked) return `red`
if (this.validator.jailed) return `red`

// status: inactive
if (parseFloat(this.validator.voting_power) === 0) return `yellow`

// status: active
return `green`
},
rewards() {
if (!this.session.signedIn) return null
const validatorRewards = this.distribution.rewards[
this.validator.operator_address
]
return validatorRewards
? num.shortNumber(num.atoms(validatorRewards[this.bondDenom]) || 0)
: null
}
},
watch: {
lastHeader: {
immediate: true,
handler() {
if (this.yourVotes > 0) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.validator.operator_address
)
}
}
}
}
// watch: {
// lastHeader: {
// immediate: true,
// handler() {
// if (this.validator.my_delegations > 0) {
// this.$store.dispatch(
// `getRewardsFromValidator`,
// this.validator.operator_address
// )
// }
// }
// }
// }
}
</script>
5 changes: 1 addition & 4 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@
{{ percent(validator.commission.rate) }}
</dd>
</dl>
<dl
v-if="session.experimentalMode"
class="info_dl colored_dl"
>
<dl v-if="session.experimentalMode" class="info_dl colored_dl">
<dt>Slashes</dt>
<dd>--</dd>
</dl>
Expand Down
Loading