From cfbb98c9f6d051cb059d031d673a3df813f9147e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 21 Apr 2022 22:13:35 +0800 Subject: [PATCH] add markdown. myvotes. --- package.json | 1 + src/layouts/components/Navbar.vue | 9 + src/libs/fetch.js | 52 +++- src/router/index.js | 16 ++ src/views/Governance.vue | 5 +- src/views/GovernanceProposalView.vue | 20 +- src/views/ObjectFieldComponent.vue | 7 +- src/views/WalletUpgradeEvents.vue | 8 + src/views/WalletVotes.vue | 361 +++++++++++++++++++++++++++ yarn.lock | 5 + 10 files changed, 461 insertions(+), 23 deletions(-) create mode 100644 src/views/WalletUpgradeEvents.vue create mode 100644 src/views/WalletVotes.vue diff --git a/package.json b/package.json index 53d3317a..4f5b7d4f 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "leaflet": "1.6.0", "ledger-cosmos-js": "2.1.8", "long": "^5.2.0", + "marked": "^4.0.14", "node-fetch": "^2.6.5", "pako": "^1.0.11", "portal-vue": "2.1.7", diff --git a/src/layouts/components/Navbar.vue b/src/layouts/components/Navbar.vue index 36bc5aa0..bbb8cf83 100644 --- a/src/layouts/components/Navbar.vue +++ b/src/layouts/components/Navbar.vue @@ -157,6 +157,15 @@ /> My Validators + + + + My Votes + + commonProcess(data)) } - async getGovernanceTally(pid, total) { - return this.get(`/gov/proposals/${pid}/tally`).then(data => new ProposalTally().init(commonProcess(data), total)) + async getGovernanceTally(pid, total, conf) { + return this.get(`/gov/proposals/${pid}/tally`, conf).then(data => new ProposalTally().init(commonProcess(data), total)) } getGovernance(pid) { @@ -246,19 +246,49 @@ export default class ChainFetch { pagination: {}, })) } - if (this.config.chain_name === 'certik') { - return this.get(`/shentu/gov/v1alpha1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}`) + if (this.config.chain_name === 'shentu') { + return this.get(`/shentu/gov/v1alpha1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}&pagination.reverse=true`) } - return this.get(`/cosmos/gov/v1beta1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}`) + return this.get(`/cosmos/gov/v1beta1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}&pagination.reverse=true`) } - async getGovernanceListByStatus(status) { - const url = this.config.chain_name === 'certik' ? `/shentu/gov/v1alpha1/proposals?pagination.limit=100&proposal_status=${status}` : `/cosmos/gov/v1beta1/proposals?pagination.limit=100&proposal_status=${status}` - return this.get(url) + async getGovernanceListByStatus(status, chain = null) { + const conf = chain || this.config + const url = conf.chain_name === 'shentu' ? `/shentu/gov/v1alpha1/proposals?pagination.limit=100&proposal_status=${status}` : `/cosmos/gov/v1beta1/proposals?pagination.limit=100&proposal_status=${status}` + return this.get(url, conf).then(data => { + let proposals = commonProcess(data) + if (Array.isArray(proposals.proposals)) { + proposals = proposals.proposals + } + const ret = [] + if (proposals) { + proposals.forEach(e => { + const g = new Proposal().init(e, 0) + g.versionFixed(this.config.sdk_version) + ret.push(g) + }) + } + return { + proposals: ret, + pagination: data.pagination, + } + }) + } + + async getGovernanceProposalVote(pid, voter, chain) { + const url = this.config.chain_name === 'shentu' + ? `/shentu/gov/v1alpha1/proposals/${pid}/votes/${voter}` + : `/cosmos/gov/v1beta1/proposals/${pid}/votes/${voter}` + return this.get(url, chain).then(data => { + if (data.code === 3) { + throw new Error('not found') + } + return data + }) } async getGovernanceList(next = '') { - const url = this.config.chain_name === 'certik' + 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 => { diff --git a/src/router/index.js b/src/router/index.js index aa2baafe..2d75d502 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -101,6 +101,22 @@ const router = new VueRouter({ ], }, }, + { + path: '/wallet/votes', + name: 'myVotes', + component: () => import('@/views/WalletVotes.vue'), + meta: { + pageTitle: 'My Votes', + breadcrumb: [ + { + text: 'Wallet', + }, + { + text: 'My Votes', + }, + ], + }, + }, // chain modules { path: '/:chain/', diff --git a/src/views/Governance.vue b/src/views/Governance.vue index e770850a..2d2b3dfc 100644 --- a/src/views/Governance.vue +++ b/src/views/Governance.vue @@ -50,7 +50,7 @@ {{ p.title }} -
+

Type @@ -285,7 +285,7 @@ export default { diff --git a/yarn.lock b/yarn.lock index 593ef445..0a63e420 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6416,6 +6416,11 @@ marked@^2.0.3: resolved "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz" integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA== +marked@^4.0.14: + version "4.0.14" + resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.14.tgz#7a3a5fa5c80580bac78c1ed2e3b84d7bd6fc3870" + integrity sha512-HL5sSPE/LP6U9qKgngIIPTthuxC0jrfxpYMZ3LdGDD3vTnLs59m2Z7r6+LNDR3ToqEQdkKd6YaaEfJhodJmijQ== + md5.js@^1.3.4: version "1.3.5" resolved "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz"