From a23ef3aa5e5f507e823058612a5ae074f8d3c08c Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Tue, 20 Jul 2021 18:11:33 +0800 Subject: [PATCH 1/7] Added proposals.getValidatorsDidNotVote --- imports/api/proposals/server/methods.js | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/imports/api/proposals/server/methods.js b/imports/api/proposals/server/methods.js index f04796d3f..10f2f701f 100644 --- a/imports/api/proposals/server/methods.js +++ b/imports/api/proposals/server/methods.js @@ -128,6 +128,32 @@ Meteor.methods({ } } return true + }, + 'proposals.getValidatorsDidNotVote': function () { + this.unblock(); + let proposals = Proposals.find({ "status": { $in: ["PROPOSAL_STATUS_VOTING_PERIOD"] } }).fetch(); + let validators = Validators.find({}).fetch(); + if (proposals && (proposals.length > 0)) { + for (let i in proposals) { + let validatorsWithoutVote = []; + let counter = 0; + if (parseInt(proposals[i].proposalId) > 0) { + for (let o in validators) { + let finder = (proposals[i].votes).some((voter) => voter.voter === validators[o].delegator_address); + if(!finder){ + validatorsWithoutVote[counter] = validators[o]; + counter++; + } + }; + try { + Proposals.update({ proposalId: proposals[i].proposalId }, { $set: { validatorsDidNotVote: { list: validatorsWithoutVote, lastUpdated: new Date() } } }); + } + catch (e) { + console.log(e); + } + } + } + } } }) From ab19eb8f61d6e6a7428ded26f3abc868aef14529 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Tue, 20 Jul 2021 18:13:21 +0800 Subject: [PATCH 2/7] Added getValidatorsDidNotVote in main.js --- server/main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/main.js b/server/main.js index 1ef69d8d8..7796fc3da 100644 --- a/server/main.js +++ b/server/main.js @@ -22,6 +22,7 @@ timerMissedBlock = 0; timerDelegation = 0; timerAggregate = 0; timerFetchKeybase = 0; +timerValidatorsDidNotVote = 0; const DEFAULTSETTINGS = '/default_settings.json'; @@ -121,6 +122,17 @@ getDelegations = () => { }); } +getValidatorsDidNotVote = () => { + Meteor.call('proposals.getValidatorsDidNotVote', (error, result) => { + if (error) { + console.log("get validators did not vote error: %o", error) + } + else { + console.log("get validators did not vote ok: %o", result) + } + }); +} + aggregateMinutely = () =>{ // doing something every min Meteor.call('Analytics.aggregateBlockTimeAndVotingPower', "m", (error, result) => { @@ -220,6 +232,10 @@ Meteor.startup(async function(){ timerProposalsResults = Meteor.setInterval(function (){ getProposalsResults(); }, Meteor.settings.params.proposalInterval); + + timerValidatorsDidNotVote = Meteor.setInterval(function () { + getValidatorsDidNotVote() + }, Meteor.settings.params.proposalInterval) } timerMissedBlock = Meteor.setInterval(function(){ From b104b417d482506eeed41b23cb8a83ac851c01ba Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Tue, 20 Jul 2021 18:27:29 +0800 Subject: [PATCH 3/7] Display validators that did not vote for proposal as a list --- both/i18n/en-us.i18n.yml | 1 + imports/ui/proposals/Proposal.jsx | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/both/i18n/en-us.i18n.yml b/both/i18n/en-us.i18n.yml index ec99fb327..9ef4bcebc 100644 --- a/both/i18n/en-us.i18n.yml +++ b/both/i18n/en-us.i18n.yml @@ -56,6 +56,7 @@ common: channel: 'Channel' proofClient: 'Proof Client' counterparty: 'Counterparty' + didNotVote: 'Did not vote' navbar: siteName: 'BIG DIPPER' diff --git a/imports/ui/proposals/Proposal.jsx b/imports/ui/proposals/Proposal.jsx index d7ef6f60f..ff8a9fc81 100644 --- a/imports/ui/proposals/Proposal.jsx +++ b/imports/ui/proposals/Proposal.jsx @@ -270,6 +270,22 @@ export default class Proposal extends Component{ } + renderValidatorsWithoutVote() { + return + + {this.props.proposal.validatorsDidNotVote.list.map((vote, i) => + (vote.operator_address ? + + {i + 1} + + + + : null) + )} + + + } + render(){ if (this.props.loading){ return @@ -405,6 +421,14 @@ export default class Proposal extends Component{ {this.renderTallyResultDetail(4, 'VOTE_OPTION_NO_WITH_VETO')} + + common.didNotVote + {this.props?.proposal?.validatorsDidNotVote?.list.length ?? ''} + this.handleClick(6, e)}>{this.state.open === 6 ? 'arrow_drop_down' : 'arrow_left'} + + {this.renderValidatorsWithoutVote()} + + {this.state.voteStarted? From 6396e7d24f6370cb2a1caca274cc581d6e09e122 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Wed, 21 Jul 2021 13:16:09 +0800 Subject: [PATCH 4/7] Sort in alphabetical order --- imports/api/proposals/server/methods.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imports/api/proposals/server/methods.js b/imports/api/proposals/server/methods.js index 10f2f701f..5e179f0ce 100644 --- a/imports/api/proposals/server/methods.js +++ b/imports/api/proposals/server/methods.js @@ -146,7 +146,10 @@ Meteor.methods({ } }; try { - Proposals.update({ proposalId: proposals[i].proposalId }, { $set: { validatorsDidNotVote: { list: validatorsWithoutVote, lastUpdated: new Date() } } }); + let list = validatorsWithoutVote.sort(function (a, b) { + return ('' + a.description.moniker).localeCompare(b.description.moniker); + }); + Proposals.update({ proposalId: proposals[i].proposalId }, { $set: { validatorsDidNotVote: { list: list, lastUpdated: new Date() } } }); } catch (e) { console.log(e); From 48b3c48953754fe5515ca3e532c6f348626fe289 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Wed, 21 Jul 2021 13:27:42 +0800 Subject: [PATCH 5/7] Add CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11fa80d81..cf4aae1ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [UNRELEASED] * [#523] Implemented readable messages for IBC messages +* [#355] Displayed validators who have not voted for proposal yet ## [v0.41.x-14.2] * Fixes Ledger WebUSB + Chrome 91.x issue (https://github.com/LedgerHQ/ledgerjs/issues/607) From e7e8669b9eccaf39c28178649aaf8c547303e401 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Wed, 21 Jul 2021 15:17:53 +0800 Subject: [PATCH 6/7] Update label --- imports/ui/proposals/Proposal.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/ui/proposals/Proposal.jsx b/imports/ui/proposals/Proposal.jsx index ff8a9fc81..8e1bdeb14 100644 --- a/imports/ui/proposals/Proposal.jsx +++ b/imports/ui/proposals/Proposal.jsx @@ -423,7 +423,7 @@ export default class Proposal extends Component{ common.didNotVote - {this.props?.proposal?.validatorsDidNotVote?.list.length ?? ''} + {this.props?.proposal?.validatorsDidNotVote?.list.length + " validators" ?? ''} this.handleClick(6, e)}>{this.state.open === 6 ? 'arrow_drop_down' : 'arrow_left'} {this.renderValidatorsWithoutVote()} From 6c410cc51a35e844c09d89edc134645c4123a99a Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 5 Aug 2021 12:26:29 +0100 Subject: [PATCH 7/7] Handle undefined values --- both/i18n/en-us.i18n.yml | 1 + imports/ui/proposals/Proposal.jsx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/both/i18n/en-us.i18n.yml b/both/i18n/en-us.i18n.yml index 9ef4bcebc..6d289cdce 100644 --- a/both/i18n/en-us.i18n.yml +++ b/both/i18n/en-us.i18n.yml @@ -214,6 +214,7 @@ proposals: recipient: 'Recipient' changes: 'Changes' subspace: 'Subspace' + validators: '{$number} validators' votingPower: distribution: 'Voting Power Distribution' pareto: 'Pareto Principle (20/80 rule)' diff --git a/imports/ui/proposals/Proposal.jsx b/imports/ui/proposals/Proposal.jsx index 8e1bdeb14..b16a8e992 100644 --- a/imports/ui/proposals/Proposal.jsx +++ b/imports/ui/proposals/Proposal.jsx @@ -271,14 +271,15 @@ export default class Proposal extends Component{ } renderValidatorsWithoutVote() { + let validatorsDidNotVoteList = this.props?.proposal?.validatorsDidNotVote?.list ?? []; return - {this.props.proposal.validatorsDidNotVote.list.map((vote, i) => - (vote.operator_address ? + {validatorsDidNotVoteList.map((vote, i) => + (vote?.operator_address ? {i + 1} - + : null) )} @@ -292,7 +293,6 @@ export default class Proposal extends Component{ } else{ if (this.props.proposalExist && this.state.proposal != ''){ - // console.log(this.state.proposal); const proposalId = Number(this.props.proposal.proposalId), maxProposalId = Number(this.props.proposalCount); const powerReduction = Meteor.settings.public.powerReduction || Coin.StakingCoin.fraction; let totalVotingPower = (this.props.activeVotingPower || this.props.chain.activeVotingPower) * powerReduction; @@ -423,7 +423,7 @@ export default class Proposal extends Component{ common.didNotVote - {this.props?.proposal?.validatorsDidNotVote?.list.length + " validators" ?? ''} + {this.props?.proposal?.validatorsDidNotVote?.list.length > 0 ? proposals.validators : proposals.validators } this.handleClick(6, e)}>{this.state.open === 6 ? 'arrow_drop_down' : 'arrow_left'} {this.renderValidatorsWithoutVote()}