From 8248992d46e6950136cbf12e29dcea0d753b7eb1 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Mon, 30 Dec 2019 14:58:01 +0300 Subject: [PATCH] Fetch the threshold for each ballot (#214) * load threshold for each ballot * Fix minThreshold for ballot Co-authored-by: varasev <33550681+varasev@users.noreply.github.com> --- src/components/BallotCard/index.js | 35 +++++++------------ src/components/BallotInfoContainer/index.js | 4 +-- src/contracts/VotingToChangeKeys.contract.js | 4 +++ .../VotingToChangeMinThreshold.contract.js | 4 +++ src/contracts/VotingToChangeProxy.contract.js | 4 +++ .../VotingToManageEmissionFunds.contract.js | 4 +++ 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/components/BallotCard/index.js b/src/components/BallotCard/index.js index 5a219ac..9db8426 100644 --- a/src/components/BallotCard/index.js +++ b/src/components/BallotCard/index.js @@ -59,6 +59,7 @@ export class BallotCard extends React.Component { @observable memo @observable quorumState @observable minBallotDuration + @observable minThreshold @computed get cancelOrFinalizeButtonDisplayName() { @@ -302,6 +303,9 @@ export class BallotCard extends React.Component { this.getHasAlreadyVoted() } + // minThreshold + this.getMinThreshold() + if (votingType === 'votingToManageEmissionFunds') { this.getQuorumState() } @@ -317,6 +321,12 @@ export class BallotCard extends React.Component { return formattedMs } + @action('ballot min threshold of voters') + getMinThreshold = async () => { + const { contractsStore, id, votingType } = this.props + this.minThreshold = await this.getContract(contractsStore, votingType).getMinThresholdOfVoters(id) + } + @action('validator has already voted') getHasAlreadyVoted = async () => { const { contractsStore, id, votingType } = this.props @@ -610,21 +620,6 @@ export class BallotCard extends React.Component { } } - getThreshold(contractsStore, votingType) { - switch (votingType) { - case 'votingToChangeKeys': - return contractsStore.keysBallotThreshold - case 'votingToChangeMinThreshold': - return contractsStore.minThresholdBallotThreshold - case 'votingToChangeProxy': - return contractsStore.proxyBallotThreshold - case 'votingToManageEmissionFunds': - return contractsStore.emissionFundsBallotThreshold - default: - return contractsStore.keysBallotThreshold - } - } - getMinBallotDuration(contractsStore, votingType) { switch (votingType) { case 'votingToChangeKeys': @@ -682,10 +677,9 @@ export class BallotCard extends React.Component { } render() { - let { contractsStore, votingType, children } = this.props + let { votingType, children } = this.props let votes - const threshold = this.getThreshold(contractsStore, votingType) const networkBranch = this.getVotingNetworkBranch() if (votingType === 'votingToManageEmissionFunds') { @@ -744,12 +738,7 @@ export class BallotCard extends React.Component { /> - + MAX_DETAILS_LENGTH ? (
- Minimum {threshold} from {validatorsLength} validators are required to pass the proposal + Minimum {threshold} validators are required to pass the proposal