diff --git a/src/libs/data/proposal-tally.js b/src/libs/data/proposal-tally.js index a7cb76aa..0bbb0b44 100644 --- a/src/libs/data/proposal-tally.js +++ b/src/libs/data/proposal-tally.js @@ -1,5 +1,3 @@ -import { percent } from '../utils' - export default class ProposalTally { constructor() { this.total = 0 @@ -17,11 +15,11 @@ export default class ProposalTally { } else { this.total = total } - this.yes = percent(Number(element.yes) / this.total) - this.no = percent(Number(element.no) / this.total) - this.veto = percent(Number(element.no_with_veto) / this.total) - this.abstain = percent(Number(element.abstain) / this.total) - this.turnout = percent(subtotal / this.total) + this.yes = Number(element.yes) / this.total + this.no = Number(element.no) / this.total + this.veto = Number(element.no_with_veto) / this.total + this.abstain = Number(element.abstain) / this.total + this.turnout = subtotal / this.total return this } diff --git a/src/libs/data/proposal.js b/src/libs/data/proposal.js index a1747eb3..938ebe81 100644 --- a/src/libs/data/proposal.js +++ b/src/libs/data/proposal.js @@ -1,5 +1,4 @@ import compareVersions from 'compare-versions' -import { toDay, formatToken } from '../utils' import ProposalTally from './proposal-tally' export default class Proposal { @@ -28,10 +27,11 @@ export default class Proposal { this.title = element.content.value.title this.description = element.content.value.description this.tally = new ProposalTally().init(element.final_tally_result, total) - this.submit_time = toDay(element.submit_time, 'date') - this.voting_end_time = toDay(element.voting_end_time, 'date') - this.voting_start_time = toDay(element.voting_start_time, 'date') - this.total_deposit = formatToken(element.total_deposit[0]) + this.submit_time = element.submit_time + this.voting_end_time = element.voting_end_time + this.voting_start_time = element.voting_start_time + // eslint-disable-next-line prefer-destructuring + this.total_deposit = element.total_deposit[0] this.contents = element.content.value return this } diff --git a/src/libs/data/staking-pool.js b/src/libs/data/staking-pool.js index 8972b84f..6008dcb2 100644 --- a/src/libs/data/staking-pool.js +++ b/src/libs/data/staking-pool.js @@ -1,5 +1,3 @@ -import { percent } from '../utils' - export default class StakingPool { constructor() { this.element = null @@ -19,6 +17,6 @@ export default class StakingPool { } bondedRatio() { - return percent((this.bondedToken * 100) / this.total()) + return (this.bondedToken * 100) / this.total() } } diff --git a/src/views/Governance.vue b/src/views/Governance.vue index 81d0d202..1a0d12e7 100644 --- a/src/views/Governance.vue +++ b/src/views/Governance.vue @@ -56,7 +56,7 @@ Start Date

- {{ p.voting_start_time }} + {{ formatDate(p.voting_start_time) }}
@@ -64,7 +64,7 @@ End Date

- {{ p.voting_end_time }} + {{ formatDate(p.voting_end_time) }}
@@ -72,7 +72,7 @@ Deposit

- {{ p.total_deposit || '-' }} + {{ formatToken(p.total_deposit) || '-' }}
@@ -80,7 +80,7 @@ Turnout

- {{ p.tally.turnout }}% + {{ percent(p.tally.turnout) }}%
@@ -95,51 +95,51 @@ - {{ p.tally.yes }}% voted Yes + {{ percent(p.tally.yes) }}% voted Yes - {{ p.tally.no }}% voted No + {{ percent(p.tally.no) }}% voted No - {{ p.tally.veto }}% voted No With Veta + {{ percent(p.tally.veto) }}% voted No With Veta - {{ p.tally.abstain }}% voted Abstain + {{ percent(p.tally.abstain) }}% voted Abstain percent(v), + formatDate: v => dayjs(v).format('YYYY-MM-DD'), + formatToken: v => tokenFormatter(v, {}), selectProposal(pid, title) { this.selectedProposalId = Number(pid) this.selectedTitle = title diff --git a/src/views/GovernanceProposalView.vue b/src/views/GovernanceProposalView.vue index 7e479119..856b36a3 100644 --- a/src/views/GovernanceProposalView.vue +++ b/src/views/GovernanceProposalView.vue @@ -65,17 +65,17 @@ {{ $t('proposal_total_deposit') }} - {{ proposal.total_deposit }} + {{ formatToken(proposal.total_deposit) }} {{ $t('proposal_submit_time') }} - {{ proposal.submit_time }} + {{ formatDate(proposal.submit_time) }} {{ $t('voting_time') }} - {{ proposal.voting_start_time }} - {{ proposal.voting_end_time }} + {{ formatDate(proposal.voting_start_time) }} - {{ formatDate(proposal.voting_end_time) }} @@ -134,51 +134,51 @@ - {{ proposal.tally.yes }}% voted Yes + {{ percent(proposal.tally.yes) }}% voted Yes - {{ proposal.tally.no }}% voted No + {{ percent(proposal.tally.no) }}% voted No - {{ proposal.tally.veto }}% voted No With Veta + {{ percent(proposal.tally.veto) }}% voted No With Veta - {{ proposal.tally.abstain }}% voted Abstain + {{ percent(proposal.tally.abstain) }}% voted Abstain - Deposits ({{ proposal.total_deposit }}) + Deposits ({{ formatToken(proposal.total_deposit) }}) @@ -268,7 +268,9 @@ import { import FlipCountdown from 'vue2-flip-countdown' // import fetch from 'node-fetch' -import { getCachedValidators, getStakingValidatorByAccount, tokenFormatter } from '@/libs/utils' +import { + getCachedValidators, getStakingValidatorByAccount, percent, tokenFormatter, +} from '@/libs/utils' import { Proposal, Proposer } from '@/libs/data' import dayjs from 'dayjs' import ObjectFieldComponent from './ObjectFieldComponent.vue' @@ -392,6 +394,9 @@ export default { }) }, methods: { + percent: v => percent(v), + formatDate: v => dayjs(v).format('YYYY-MM-DD HH:mm'), + formatToken: v => tokenFormatter(v, {}), loadVotes() { if (this.next) { const pid = this.$route.params.proposalid