From ba3a9d56d43f5e2de955c33ed1cfccbccfb336ff Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 22 Apr 2022 13:56:34 +0800 Subject: [PATCH] add upgrade events --- src/libs/fetch.js | 14 +++- src/views/Governance.vue | 2 +- src/views/WalletUpgradeEvents.vue | 131 +++++++++++++++++++++++++++++- src/views/WalletVotes.vue | 22 ++--- 4 files changed, 146 insertions(+), 23 deletions(-) diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 8dd6acd1..e0da8862 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -287,11 +287,17 @@ export default class ChainFetch { }) } - async getGovernanceList(next = '') { + /// does NOT return value as expected + async getUpgradeCurrentPlan(chain = null) { + return this.get('/cosmos/upgrade/v1beta1/current_plan', chain) + } + + async getGovernanceList(next = '', chain = null) { + const key = next || '' const url = this.config.chain_name === 'shentu' - ? `/shentu/gov/v1alpha1/proposals?pagination.limit=50&pagination.reverse=true&pagination.key=${next}` - : `/cosmos/gov/v1beta1/proposals?pagination.limit=50&pagination.reverse=true&pagination.key=${next}` - return this.get(url).then(data => { + ? `/shentu/gov/v1alpha1/proposals?pagination.limit=50&pagination.reverse=true&pagination.key=${key}` + : `/cosmos/gov/v1beta1/proposals?pagination.limit=50&pagination.reverse=true&pagination.key=${key}` + return this.get(url, chain).then(data => { // const pool = new StakingPool().init(commonProcess(data[1])) let proposals = commonProcess(data) if (Array.isArray(proposals.proposals)) { diff --git a/src/views/Governance.vue b/src/views/Governance.vue index 2d2b3dfc..628f8ebd 100644 --- a/src/views/Governance.vue +++ b/src/views/Governance.vue @@ -232,7 +232,7 @@ export default { proposals: [], max: 1, operationModalType: '', - next: null, + next: '', } }, mounted() { diff --git a/src/views/WalletUpgradeEvents.vue b/src/views/WalletUpgradeEvents.vue index e6776e32..80ec92fb 100644 --- a/src/views/WalletUpgradeEvents.vue +++ b/src/views/WalletUpgradeEvents.vue @@ -1,8 +1,135 @@ + diff --git a/src/views/WalletVotes.vue b/src/views/WalletVotes.vue index 766a59bd..1ad80ad0 100644 --- a/src/views/WalletVotes.vue +++ b/src/views/WalletVotes.vue @@ -169,15 +169,7 @@ title="Upgrade Events" lazy > - -
- {{ votes }} -
-
+ @@ -192,6 +184,7 @@ import { getLocalAccounts, getLocalChains, percent, ProposalTally, tokenFormatter, } from '@/libs/utils' import dayjs from 'dayjs' +import WalletUpgradeEvents from './WalletUpgradeEvents.vue' export default { components: { @@ -208,6 +201,7 @@ export default { BProgress, BProgressBar, BTooltip, + WalletUpgradeEvents, }, directives: { 'b-tooltip': VBTooltip, @@ -229,7 +223,7 @@ export default { x2.tally = this.tally[`${x.chain.chain_name}-${x.id}`] || new ProposalTally() x2.votes = this.votes.filter(v => v.vote.proposal_id === x.id) return x2 - }) + }).sort((a, b) => dayjs(b.voting_start_time).unix() - dayjs(a.voting_start_time).unix()) }, }, created() { @@ -287,18 +281,14 @@ export default { }) }) - let promise = Promise.resolve() Object.values(toQuery).forEach(item => { - promise = promise.then(() => new Promise(resolve => { - this.fetchProposals(item, resolve) - })) + this.fetchProposals(item) }) } }, - fetchProposals(item, resolve) { + fetchProposals(item) { if (this.islive) { this.$http.getGovernanceListByStatus(2, item.conf).then(data => { - resolve() data.proposals.forEach(p => { const p2 = p p2.chain = item.conf