Skip to content

Commit

Permalink
fedekunze/1648 gov params tab (#1678)
Browse files Browse the repository at this point in the history
* gov params tab

* keep fixing params

* update gov params tab

* update gov params and tabParams tests

* fix unit tests

* updated lcd and snaps

* changelog

* switch to percentages

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>

* Update CHANGELOG.md

Co-Authored-By: fedekunze <[email protected]>

* Update CHANGELOG.md

Co-Authored-By: fedekunze <[email protected]>

* Update app/src/renderer/components/governance/TabParameters.vue

Co-Authored-By: fedekunze <[email protected]>
  • Loading branch information
fedekunze authored and jbibla committed Dec 4, 2018
1 parent d9250a7 commit 1ceb282
Show file tree
Hide file tree
Showing 16 changed files with 532 additions and 79 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1685](https://github.com/cosmos/voyager/pull/1685) added .idea to .gitignore @sabau
- [\#1578](https://github.com/cosmos/voyager/issues/1578) added e2e tests for submit governance proposals @fedekunze
- [\#1672](https://github.com/cosmos/voyager/issues/1672) added e2e tests for staking parameters tab @fedekunze
- [\#1550](https://github.com/cosmos/voyager/issues/1578) added e2e tests for voting on governance proposals @fedekunze
- [\#1555](https://github.com/cosmos/voyager/issues/1578) added e2e tests for submitting a deposit on a governance proposal @fedekunze
- [\#1648](https://github.com/cosmos/voyager/issues/1648) added governance parameters tab @fedekunze
- [\#1550](https://github.com/cosmos/voyager/issues/1550) added e2e tests for voting on governance proposals @fedekunze
- [\#1555](https://github.com/cosmos/voyager/issues/1555) added e2e tests for submitting a deposit on a governance proposal @fedekunze
- [\#1681](https://github.com/cosmos/voyager/issues/1681) Governance: Fixed voting starting date @sabau
- [\#1690](https://github.com/cosmos/voyager/issues/1690) Governance: Fixed error messages for maxLength @sabau

Expand Down
5 changes: 5 additions & 0 deletions app/src/renderer/components/governance/PageGovernance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export default {
displayName: `Proposals`,
pathName: `Proposals`
}
// TODO uncomment when updated to latest SDK
// {
// displayName: `Parameters`,
// pathName: `Governance Parameters`
// }
],
showModalPropose: false
}),
Expand Down
278 changes: 278 additions & 0 deletions app/src/renderer/components/governance/TabParameters.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
<template>
<div>
<div>
<h3>
Deposit Parameters
<i
v-tooltip.top="depositTooltips.description"
class="material-icons info-button"
>info_outline</i
>
</h3>
<div class="parameters__details parameters__section">
<div class="row">
<div class="column">
<dl class="info_dl">
<dt>
Minimum Deposit
<i
v-tooltip.top="depositTooltips.min_deposit"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.deposit.min_deposit
? minimumDeposit
: `n/a`
}}
</dd>
</dl>
</div>
<div class="column">
<dl class="info_dl">
<dt>
Maximum Deposit Period
<i
v-tooltip.top="depositTooltips.max_deposit_period"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.deposit.max_deposit_period
? depositPeriodInDays + ` days`
: `n/a`
}}
</dd>
</dl>
</div>
</div>
</div>
</div>
<div>
<h3>
Tally Parameters
<i
v-tooltip.top="tallyingTooltips.description"
class="material-icons info-button"
>info_outline</i
>
</h3>
<div class="parameters__details parameters__section">
<div class="row">
<div class="column">
<dl class="info_dl">
<dt>
Threshold
<i
v-tooltip.top="tallyingTooltips.threshold"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.tallying.threshold
? `${parseFloat(
governanceParameters.parameters.tallying.threshold
) * 100} %`
: `n/a`
}}
</dd>
</dl>
<dl class="info_dl">
<dt>
Veto
<i
v-tooltip.top="tallyingTooltips.veto"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.tallying.veto
? `${parseFloat(
governanceParameters.parameters.tallying.veto
) * 100} %`
: `n/a`
}}
</dd>
</dl>
</div>
<div class="column">
<dl class="info_dl">
<dt>
Governance Penalty
<i
v-tooltip.top="tallyingTooltips.governance_penalty"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.tallying.governance_penalty
? governanceParameters.parameters.tallying
.governance_penalty
: `n/a`
}}
</dd>
</dl>
</div>
</div>
</div>
</div>
<div>
<h3>
Voting Parameters
<i
v-tooltip.top="votingTooltips.description"
class="material-icons info-button"
>info_outline</i
>
</h3>
<div class="parameters__details parameters__section">
<div class="row">
<div class="column">
<dl class="info_dl">
<dt>
Voting Period
<i
v-tooltip.top="votingTooltips.voting_period"
class="material-icons info-button"
>info_outline</i
>
</dt>
<dd>
{{
governanceParameters.parameters.voting.voting_period
? votingPeriodInDays + ` days`
: `n/a`
}}
</dd>
</dl>
</div>
<div class="column"></div>
</div>
</div>
</div>
</div>
</template>

<script>
import { mapGetters } from "vuex"
import { TmBtn, TmListItem, TmPage, TmPart, TmToolBar } from "@tendermint/ui"
export default {
name: `tab-staking-parameters`,
components: {
TmBtn,
TmListItem,
TmPage,
TmPart,
TmToolBar
},
data: () => ({
depositTooltips: {
description: `Governance deposit parameters for the Cosmos Hub`,
min_deposit: `Minimum deposit required before for a proposal can enter the voting period`,
max_deposit_period: `Deposits must reach the "minimum deposit" threshold in this period of time`
},
tallyingTooltips: {
description: `Tally parameters for governance in the Cosmos Hub`,
threshold: `Percentage of "Yes" votes required for proposal to pass`,
veto: `Percentage of "No With Veto" votes required for proposal to be vetoed`,
governance_penalty: `Penalty for a validator who fails to vote`
},
votingTooltips: {
description: `Voting parameters for governance in the Cosmos Hub`,
voting_period: `Length of the voting period for proposals on the Cosmos Hub`
}
}),
computed: {
...mapGetters([`config`, `governanceParameters`]),
minimumDeposit() {
let coin = this.governanceParameters.parameters.deposit.min_deposit[0]
return `${coin.amount} ${coin.denom}s`
},
depositPeriodInDays() {
return (
parseInt(
this.governanceParameters.parameters.deposit.max_deposit_period
) /
(10 ** 9 * 60 * 60 * 24)
)
},
votingPeriodInDays() {
return (
parseInt(this.governanceParameters.parameters.voting.voting_period) /
(10 ** 9 * 60 * 60 * 24)
)
}
},
async mounted() {
this.$store.dispatch(`getGovParameters`)
}
}
</script>
<style>
.parameters__details > .row > .column {
flex: 1;
}
.parameters__section {
background-color: var(--app-fg);
display: flex;
margin-bottom: 1rem;
padding: 2rem;
width: 100%;
}
h3 {
margin: 1em auto;
}
.info-button {
color: var(--link);
}
.column {
display: flex;
flex-flow: column;
position: relative;
}
.row {
display: flex;
flex-direction: row;
width: 100%;
}
.info_dl {
display: flex;
flex-flow: column;
margin-bottom: 1.5rem;
margin-right: 1rem;
}
.info_dl dt {
color: var(--dim);
font-size: small;
margin-bottom: 4px;
}
.info_dl dd {
border: 1px solid var(--white-fade-2);
border-radius: 2px;
font-size: 1rem;
line-height: 1rem;
padding: 0.5rem;
}
.info_dl dd.info_dl__text-box {
min-height: 6.91rem;
}
</style>
30 changes: 20 additions & 10 deletions app/src/renderer/components/staking/TabParameters.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="config.devMode">
<div>
<div>
<h3 class="staking-pool">
Staking Pool
Expand All @@ -14,7 +14,12 @@
<div class="column">
<dl class="info_dl">
<dt>
Loose {{ parameters.parameters.bond_denom }}
Loose
{{
stakingParameters.parameters.bond_denom
? stakingParameters.parameters.bond_denom
: bondingDenom
}}
<i
v-tooltip.top="poolTooltips.loose_tokens"
class="material-icons info-button"
Expand All @@ -29,7 +34,12 @@
<div class="column">
<dl class="info_dl">
<dt>
Delegated {{ parameters.parameters.bond_denom }}
Delegated
{{
stakingParameters.parameters.bond_denom
? stakingParameters.parameters.bond_denom
: bondingDenom
}}
<i
v-tooltip.top="poolTooltips.bonded_tokens"
class="material-icons info-button"
Expand Down Expand Up @@ -67,7 +77,7 @@
</dt>
<dd id="unbonding_time">
{{
parameters.parameters.unbonding_time
stakingParameters.parameters.unbonding_time
? unbondingTimeInDays + ` days`
: `n/a`
}}
Expand All @@ -77,8 +87,8 @@
<dt>Current Staking Coin Denomination</dt>
<dd id="bond_denom">
{{
parameters.parameters.bond_denom
? parameters.parameters.bond_denom
stakingParameters.parameters.bond_denom
? stakingParameters.parameters.bond_denom
: `n/a`
}}
</dd>
Expand All @@ -89,8 +99,8 @@
<dt>Maximum Number of Validators</dt>
<dd id="max_validators">
{{
parameters.parameters.max_validators
? parameters.parameters.max_validators
stakingParameters.parameters.max_validators
? stakingParameters.parameters.max_validators
: `n/a`
}}
</dd>
Expand Down Expand Up @@ -128,10 +138,10 @@ export default {
}
}),
computed: {
...mapGetters([`config`, `parameters`, `pool`]),
...mapGetters([`config`, `stakingParameters`, `pool`, `bondingDenom`]),
unbondingTimeInDays() {
return (
parseInt(this.parameters.parameters.unbonding_time) /
parseInt(this.stakingParameters.parameters.unbonding_time) /
(10 ** 9 * 60 * 60 * 24)
)
}
Expand Down
Loading

0 comments on commit 1ceb282

Please sign in to comment.