From 3aa899bf90c563b8c02a147a47db559b49bfb6f5 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 7 Nov 2022 10:47:38 +0800 Subject: [PATCH] add quorum --- src/views/Dashboard.vue | 35 ++++++++++++++++--- src/views/WalletVotes.vue | 11 ++++-- .../governance/ProposalSummaryComponent.vue | 12 ++++++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 14ac7d53..bb3c958e 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -119,9 +119,14 @@
- {{ prop.title }} + + {{ formatType(prop.contents['@type']) }} + {{ prop.title }}
- {{ formatType(prop.contents['@type']) }} {{ formatEnding(prop.voting_end_time) }} + will {{ caculateTallyResult(prop.tally) }} {{ formatEnding(prop.voting_end_time) }}
@@ -171,9 +176,18 @@
+
- + {{ walletName }} Assets import { BRow, BCol, BAlert, BCard, BTable, BFormCheckbox, BCardHeader, BCardTitle, BMedia, BMediaAside, BMediaBody, BAvatar, - BCardBody, BLink, BButtonGroup, BButton, BTooltip, VBModal, VBTooltip, BCardFooter, BProgress, BProgressBar, + BCardBody, BLink, BButtonGroup, BButton, BTooltip, VBModal, VBTooltip, BCardFooter, BProgress, BProgressBar, BBadge, } from 'bootstrap-vue' import { formatNumber, formatTokenAmount, isToken, percent, timeIn, toDay, toDuration, tokenFormatter, getLocalAccounts, @@ -490,6 +504,7 @@ export default { BProgress, BProgressBar, VueMarkdown, + BBadge, OperationModal, ParametersModuleComponent, @@ -630,11 +645,21 @@ export default { } }, methods: { + caculateTallyResult(tally) { + if (this.tallyParam && tally && this.totalPower > 0) { + if (tally.veto < Number(this.tallyParam.veto_threshold) + && tally.yes > Number(this.tallyParam.threshold) + && tally.total / this.totalPower > Number(this.tallyParam.quorum)) { + return 'pass' + } + } + return 'be rejected' + }, scaleWidth() { if (this.tallyParam) { return Number(this.tallyParam.quorum) * Number(this.tallyParam.threshold) * 100 } - return 30 + return 50 }, selectProposal(modal, pid, title) { this.operationModalType = modal diff --git a/src/views/WalletVotes.vue b/src/views/WalletVotes.vue index f0f34ea0..ffa35112 100644 --- a/src/views/WalletVotes.vue +++ b/src/views/WalletVotes.vue @@ -98,7 +98,7 @@ /> {{ v.keyname }} : {{ v.vote.option }} + > {{ v.keyname }} : {{ formatOption(v.vote.option) }} @@ -236,6 +236,13 @@ export default { percent: v => percent(v), formatDate: v => dayjs(v).format('YYYY-MM-DD'), formatToken: v => tokenFormatter(v, {}), + formatOption: v => { + const start = String(v).lastIndexOf('_') + if (start > 0) { + return String(v).substring(start + 1) + } + return v + }, init() { this.accounts = getLocalAccounts() if (this.accounts) { diff --git a/src/views/components/governance/ProposalSummaryComponent.vue b/src/views/components/governance/ProposalSummaryComponent.vue index 0b568c8d..e79e3ed1 100644 --- a/src/views/components/governance/ProposalSummaryComponent.vue +++ b/src/views/components/governance/ProposalSummaryComponent.vue @@ -103,9 +103,18 @@
+
import { - BCard, BCardTitle, BCardFooter, BButton, BProgressBar, BProgress, BBadge, BTooltip, BRow, BCol, VBModal, + BCard, BCardTitle, BCardFooter, BButton, BProgressBar, BProgress, BBadge, BTooltip, BRow, BCol, VBModal, VBTooltip, } from 'bootstrap-vue' import Ripple from 'vue-ripple-directive' import { percent, tokenFormatter } from '@/libs/utils' @@ -189,6 +198,7 @@ export default { }, directives: { 'b-modal': VBModal, + 'b-tooltip': VBTooltip, Ripple, }, props: {