Fix minThreshold for ballot
This commit is contained in:
parent
6b0b54f670
commit
34f11a2f06
|
@ -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
|
||||
|
@ -667,7 +677,7 @@ export class BallotCard extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
let { contractsStore, votingType, children, votingState } = this.props
|
||||
let { votingType, children } = this.props
|
||||
let votes
|
||||
|
||||
const networkBranch = this.getVotingNetworkBranch()
|
||||
|
@ -728,12 +738,7 @@ export class BallotCard extends React.Component {
|
|||
/>
|
||||
</div>
|
||||
<Votes networkBranch={networkBranch} votes={votes} />
|
||||
<BallotInfoContainer
|
||||
memo={this.memo}
|
||||
networkBranch={networkBranch}
|
||||
threshold={votingState.threshold}
|
||||
validatorsLength={contractsStore.validatorsLength}
|
||||
/>
|
||||
<BallotInfoContainer memo={this.memo} networkBranch={networkBranch} threshold={this.minThreshold} />
|
||||
<BallotFooter
|
||||
buttonState={this.cancelOrFinalizeButtonState}
|
||||
buttonText={this.cancelOrFinalizeButtonDisplayName}
|
||||
|
|
|
@ -18,7 +18,7 @@ export class BallotInfoContainer extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
let { memo = '', threshold, validatorsLength, networkBranch } = this.props
|
||||
let { memo = '', threshold, networkBranch } = this.props
|
||||
let toggleShowMore =
|
||||
memo.length > MAX_DETAILS_LENGTH ? (
|
||||
<span
|
||||
|
@ -34,7 +34,7 @@ export class BallotInfoContainer extends React.Component {
|
|||
return (
|
||||
<div className="bc-BallotInfoContainer">
|
||||
<div className="bc-BallotInfoContainer_Info bc-BallotInfoContainer_Info-minimum">
|
||||
Minimum {threshold} from {validatorsLength} validators are required to pass the proposal
|
||||
Minimum {threshold} validators are required to pass the proposal
|
||||
</div>
|
||||
<div
|
||||
className={`bc-BallotInfoContainer_Info bc-BallotInfoContainer_Info-details ${
|
||||
|
|
|
@ -62,6 +62,10 @@ export default class VotingToChangeKeys {
|
|||
return this.instance.methods.votingState(_id).call()
|
||||
}
|
||||
|
||||
getMinThresholdOfVoters(_id) {
|
||||
return this.instance.methods.getMinThresholdOfVoters(_id).call()
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ export default class VotingToChangeMinThreshold {
|
|||
return this.instance.methods.votingState(_id).call()
|
||||
}
|
||||
|
||||
getMinThresholdOfVoters(_id) {
|
||||
return this.instance.methods.getMinThresholdOfVoters(_id).call()
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ export default class VotingToChangeProxy {
|
|||
return this.instance.methods.votingState(_id).call()
|
||||
}
|
||||
|
||||
getMinThresholdOfVoters(_id) {
|
||||
return this.instance.methods.getMinThresholdOfVoters(_id).call()
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ export default class VotingToManageEmissionFunds {
|
|||
return this.instance.methods.getBallotInfo(_id).call()
|
||||
}
|
||||
|
||||
getMinThresholdOfVoters(_id) {
|
||||
return this.instance.methods.getMinThresholdOfVoters(_id).call()
|
||||
}
|
||||
|
||||
getQuorumState(_id) {
|
||||
return this.instance.methods.getQuorumState(_id).call()
|
||||
}
|
||||
|
|
|
@ -330,12 +330,8 @@ class ContractsStore {
|
|||
getCard = async (id, contractType) => {
|
||||
let votingState
|
||||
try {
|
||||
const data = await Promise.all([
|
||||
this[contractType].getBallotInfo(id, this.votingKey),
|
||||
this[contractType].instance.methods.getMinThresholdOfVoters(id).call()
|
||||
])
|
||||
votingState = this.fillCardVotingState(data[0], contractType)
|
||||
votingState.threshold = data[1]
|
||||
votingState = await this[contractType].getBallotInfo(id, this.votingKey)
|
||||
votingState = this.fillCardVotingState(votingState, contractType)
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue