forked from cerc-io/cosmos-explorer
Update gov module
This commit is contained in:
parent
4ea72891e5
commit
7d9618653c
@ -1,5 +1,3 @@
|
|||||||
import { percent } from '../utils'
|
|
||||||
|
|
||||||
export default class ProposalTally {
|
export default class ProposalTally {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.total = 0
|
this.total = 0
|
||||||
@ -17,11 +15,11 @@ export default class ProposalTally {
|
|||||||
} else {
|
} else {
|
||||||
this.total = total
|
this.total = total
|
||||||
}
|
}
|
||||||
this.yes = percent(Number(element.yes) / this.total)
|
this.yes = Number(element.yes) / this.total
|
||||||
this.no = percent(Number(element.no) / this.total)
|
this.no = Number(element.no) / this.total
|
||||||
this.veto = percent(Number(element.no_with_veto) / this.total)
|
this.veto = Number(element.no_with_veto) / this.total
|
||||||
this.abstain = percent(Number(element.abstain) / this.total)
|
this.abstain = Number(element.abstain) / this.total
|
||||||
this.turnout = percent(subtotal / this.total)
|
this.turnout = subtotal / this.total
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import compareVersions from 'compare-versions'
|
import compareVersions from 'compare-versions'
|
||||||
import { toDay, formatToken } from '../utils'
|
|
||||||
import ProposalTally from './proposal-tally'
|
import ProposalTally from './proposal-tally'
|
||||||
|
|
||||||
export default class Proposal {
|
export default class Proposal {
|
||||||
@ -28,10 +27,11 @@ export default class Proposal {
|
|||||||
this.title = element.content.value.title
|
this.title = element.content.value.title
|
||||||
this.description = element.content.value.description
|
this.description = element.content.value.description
|
||||||
this.tally = new ProposalTally().init(element.final_tally_result, total)
|
this.tally = new ProposalTally().init(element.final_tally_result, total)
|
||||||
this.submit_time = toDay(element.submit_time, 'date')
|
this.submit_time = element.submit_time
|
||||||
this.voting_end_time = toDay(element.voting_end_time, 'date')
|
this.voting_end_time = element.voting_end_time
|
||||||
this.voting_start_time = toDay(element.voting_start_time, 'date')
|
this.voting_start_time = element.voting_start_time
|
||||||
this.total_deposit = formatToken(element.total_deposit[0])
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
this.total_deposit = element.total_deposit[0]
|
||||||
this.contents = element.content.value
|
this.contents = element.content.value
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { percent } from '../utils'
|
|
||||||
|
|
||||||
export default class StakingPool {
|
export default class StakingPool {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.element = null
|
this.element = null
|
||||||
@ -19,6 +17,6 @@ export default class StakingPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bondedRatio() {
|
bondedRatio() {
|
||||||
return percent((this.bondedToken * 100) / this.total())
|
return (this.bondedToken * 100) / this.total()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
Start Date
|
Start Date
|
||||||
</p>
|
</p>
|
||||||
<h6 class="mb-0">
|
<h6 class="mb-0">
|
||||||
{{ p.voting_start_time }}
|
{{ formatDate(p.voting_start_time) }}
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="gov">
|
<div class="gov">
|
||||||
@ -64,7 +64,7 @@
|
|||||||
End Date
|
End Date
|
||||||
</p>
|
</p>
|
||||||
<h6 class="mb-0">
|
<h6 class="mb-0">
|
||||||
{{ p.voting_end_time }}
|
{{ formatDate(p.voting_end_time) }}
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="gov">
|
<div class="gov">
|
||||||
@ -72,7 +72,7 @@
|
|||||||
Deposit
|
Deposit
|
||||||
</p>
|
</p>
|
||||||
<h6 class="mb-0">
|
<h6 class="mb-0">
|
||||||
{{ p.total_deposit || '-' }}
|
{{ formatToken(p.total_deposit) || '-' }}
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="gov">
|
<div class="gov">
|
||||||
@ -80,7 +80,7 @@
|
|||||||
Turnout
|
Turnout
|
||||||
</p>
|
</p>
|
||||||
<h6 class="mb-0">
|
<h6 class="mb-0">
|
||||||
{{ p.tally.turnout }}%
|
{{ percent(p.tally.turnout) }}%
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -95,51 +95,51 @@
|
|||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-yes'+p.id"
|
:id="'vote-yes'+p.id"
|
||||||
variant="success"
|
variant="success"
|
||||||
:value="p.tally.yes"
|
:value="percent(p.tally.yes)"
|
||||||
show-progress
|
show-progress
|
||||||
:label="`${p.tally.yes.toFixed()}%`"
|
:label="`${percent(p.tally.yes).toFixed()}%`"
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-no'+p.id"
|
:id="'vote-no'+p.id"
|
||||||
variant="warning"
|
variant="warning"
|
||||||
:value="p.tally.no"
|
:value="percent(p.tally.no)"
|
||||||
:label="`${p.tally.no.toFixed()}%`"
|
:label="`${percent(p.tally.no).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-veto'+p.id"
|
:id="'vote-veto'+p.id"
|
||||||
variant="danger"
|
variant="danger"
|
||||||
:value="p.tally.veto"
|
:value="percent(p.tally.veto)"
|
||||||
:label="`${p.tally.veto.toFixed()}%`"
|
:label="`${percent(p.tally.veto).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-abstain'+p.id"
|
:id="'vote-abstain'+p.id"
|
||||||
variant="info"
|
variant="info"
|
||||||
:value="p.tally.abstain"
|
:value="percent(p.tally.abstain)"
|
||||||
:label="`${p.tally.abstain.toFixed()}%`"
|
:label="`${percent(p.tally.abstain).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
</b-progress>
|
</b-progress>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-yes'+p.id"
|
:target="'vote-yes'+p.id"
|
||||||
>
|
>
|
||||||
{{ p.tally.yes }}% voted Yes
|
{{ percent(p.tally.yes) }}% voted Yes
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-no'+p.id"
|
:target="'vote-no'+p.id"
|
||||||
>
|
>
|
||||||
{{ p.tally.no }}% voted No
|
{{ percent(p.tally.no) }}% voted No
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-veto'+p.id"
|
:target="'vote-veto'+p.id"
|
||||||
>
|
>
|
||||||
{{ p.tally.veto }}% voted No With Veta
|
{{ percent(p.tally.veto) }}% voted No With Veta
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-abstain'+p.id"
|
:target="'vote-abstain'+p.id"
|
||||||
>
|
>
|
||||||
{{ p.tally.abstain }}% voted Abstain
|
{{ percent(p.tally.abstain) }}% voted Abstain
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-card-footer class="pb-0">
|
<b-card-footer class="pb-0">
|
||||||
<router-link
|
<router-link
|
||||||
@ -194,6 +194,8 @@ import {
|
|||||||
} from 'bootstrap-vue'
|
} from 'bootstrap-vue'
|
||||||
import Ripple from 'vue-ripple-directive'
|
import Ripple from 'vue-ripple-directive'
|
||||||
import { Proposal } from '@/libs/data'
|
import { Proposal } from '@/libs/data'
|
||||||
|
import { percent, tokenFormatter } from '@/libs/utils'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import OperationVoteComponent from './OperationVoteComponent.vue'
|
import OperationVoteComponent from './OperationVoteComponent.vue'
|
||||||
import OperationGovDepositComponent from './OperationGovDepositComponent.vue'
|
import OperationGovDepositComponent from './OperationGovDepositComponent.vue'
|
||||||
|
|
||||||
@ -229,6 +231,9 @@ export default {
|
|||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
percent: v => percent(v),
|
||||||
|
formatDate: v => dayjs(v).format('YYYY-MM-DD'),
|
||||||
|
formatToken: v => tokenFormatter(v, {}),
|
||||||
selectProposal(pid, title) {
|
selectProposal(pid, title) {
|
||||||
this.selectedProposalId = Number(pid)
|
this.selectedProposalId = Number(pid)
|
||||||
this.selectedTitle = title
|
this.selectedTitle = title
|
||||||
|
@ -65,17 +65,17 @@
|
|||||||
<b-tr>
|
<b-tr>
|
||||||
<b-td>
|
<b-td>
|
||||||
{{ $t('proposal_total_deposit') }}
|
{{ $t('proposal_total_deposit') }}
|
||||||
</b-td><b-td>{{ proposal.total_deposit }} </b-td>
|
</b-td><b-td>{{ formatToken(proposal.total_deposit) }} </b-td>
|
||||||
</b-tr>
|
</b-tr>
|
||||||
<b-tr>
|
<b-tr>
|
||||||
<b-td>
|
<b-td>
|
||||||
{{ $t('proposal_submit_time') }}
|
{{ $t('proposal_submit_time') }}
|
||||||
</b-td><b-td>{{ proposal.submit_time }}</b-td>
|
</b-td><b-td>{{ formatDate(proposal.submit_time) }}</b-td>
|
||||||
</b-tr>
|
</b-tr>
|
||||||
<b-tr>
|
<b-tr>
|
||||||
<b-td>
|
<b-td>
|
||||||
{{ $t('voting_time') }}
|
{{ $t('voting_time') }}
|
||||||
</b-td><b-td>{{ proposal.voting_start_time }} - {{ proposal.voting_end_time }}</b-td>
|
</b-td><b-td>{{ formatDate(proposal.voting_start_time) }} - {{ formatDate(proposal.voting_end_time) }}</b-td>
|
||||||
</b-tr>
|
</b-tr>
|
||||||
<b-tr>
|
<b-tr>
|
||||||
<b-td>
|
<b-td>
|
||||||
@ -134,51 +134,51 @@
|
|||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-yes'+proposal.id"
|
:id="'vote-yes'+proposal.id"
|
||||||
variant="success"
|
variant="success"
|
||||||
:value="proposal.tally.yes"
|
:value="percent(proposal.tally.yes)"
|
||||||
:label="`${proposal.tally.yes.toFixed()}%`"
|
:label="`${percent(proposal.tally.yes).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-no'+proposal.id"
|
:id="'vote-no'+proposal.id"
|
||||||
variant="warning"
|
variant="warning"
|
||||||
:value="proposal.tally.no"
|
:value="percent(proposal.tally.no)"
|
||||||
:label="`${proposal.tally.no.toFixed()}%`"
|
:label="`${percent(proposal.tally.no).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-veto'+proposal.id"
|
:id="'vote-veto'+proposal.id"
|
||||||
variant="danger"
|
variant="danger"
|
||||||
:value="proposal.tally.veto"
|
:value="percent(proposal.tally.veto)"
|
||||||
:label="`${proposal.tally.veto.toFixed()}%`"
|
:label="`${percent(proposal.tally.veto).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
<b-progress-bar
|
<b-progress-bar
|
||||||
:id="'vote-abstain'+proposal.id"
|
:id="'vote-abstain'+proposal.id"
|
||||||
variant="info"
|
variant="info"
|
||||||
:value="proposal.tally.abstain"
|
:value="percent(proposal.tally.abstain)"
|
||||||
:label="`${proposal.tally.abstain.toFixed()}%`"
|
:label="`${percent(proposal.tally.abstain).toFixed()}%`"
|
||||||
show-progress
|
show-progress
|
||||||
/>
|
/>
|
||||||
</b-progress>
|
</b-progress>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-yes'+proposal.id"
|
:target="'vote-yes'+proposal.id"
|
||||||
>
|
>
|
||||||
{{ proposal.tally.yes }}% voted Yes
|
{{ percent(proposal.tally.yes) }}% voted Yes
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-no'+proposal.id"
|
:target="'vote-no'+proposal.id"
|
||||||
>
|
>
|
||||||
{{ proposal.tally.no }}% voted No
|
{{ percent(proposal.tally.no) }}% voted No
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-veto'+proposal.id"
|
:target="'vote-veto'+proposal.id"
|
||||||
>
|
>
|
||||||
{{ proposal.tally.veto }}% voted No With Veta
|
{{ percent(proposal.tally.veto) }}% voted No With Veta
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-tooltip
|
<b-tooltip
|
||||||
:target="'vote-abstain'+proposal.id"
|
:target="'vote-abstain'+proposal.id"
|
||||||
>
|
>
|
||||||
{{ proposal.tally.abstain }}% voted Abstain
|
{{ percent(proposal.tally.abstain) }}% voted Abstain
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
<b-table
|
<b-table
|
||||||
v-if="votes.votes && votes.votes.length > 0"
|
v-if="votes.votes && votes.votes.length > 0"
|
||||||
@ -206,7 +206,7 @@
|
|||||||
<b-card no-body>
|
<b-card no-body>
|
||||||
<b-card-header>
|
<b-card-header>
|
||||||
<b-card-title>
|
<b-card-title>
|
||||||
Deposits ({{ proposal.total_deposit }})
|
Deposits ({{ formatToken(proposal.total_deposit) }})
|
||||||
</b-card-title>
|
</b-card-title>
|
||||||
</b-card-header>
|
</b-card-header>
|
||||||
<b-card-body>
|
<b-card-body>
|
||||||
@ -268,7 +268,9 @@ import {
|
|||||||
import FlipCountdown from 'vue2-flip-countdown'
|
import FlipCountdown from 'vue2-flip-countdown'
|
||||||
// import fetch from 'node-fetch'
|
// 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 { Proposal, Proposer } from '@/libs/data'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import ObjectFieldComponent from './ObjectFieldComponent.vue'
|
import ObjectFieldComponent from './ObjectFieldComponent.vue'
|
||||||
@ -392,6 +394,9 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
percent: v => percent(v),
|
||||||
|
formatDate: v => dayjs(v).format('YYYY-MM-DD HH:mm'),
|
||||||
|
formatToken: v => tokenFormatter(v, {}),
|
||||||
loadVotes() {
|
loadVotes() {
|
||||||
if (this.next) {
|
if (this.next) {
|
||||||
const pid = this.$route.params.proposalid
|
const pid = this.$route.params.proposalid
|
||||||
|
Loading…
Reference in New Issue
Block a user