From a4b2fd2e231dab5b1bb931c356993ca65c62e178 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 11:19:52 +0800 Subject: [PATCH 01/22] feat: gov vote --- src/components/ProposalListItem.vue | 455 +++++++++++++--------------- src/stores/useGovStore.ts | 62 ++-- src/types/gov.ts | 122 ++++---- 3 files changed, 311 insertions(+), 328 deletions(-) diff --git a/src/components/ProposalListItem.vue b/src/components/ProposalListItem.vue index c2ac75fc..dcca7a95 100644 --- a/src/components/ProposalListItem.vue +++ b/src/components/ProposalListItem.vue @@ -1,9 +1,9 @@ diff --git a/src/stores/useGovStore.ts b/src/stores/useGovStore.ts index e415153e..48b07fce 100644 --- a/src/stores/useGovStore.ts +++ b/src/stores/useGovStore.ts @@ -2,7 +2,7 @@ import { defineStore } from 'pinia'; import { useBlockchain } from './useBlockchain'; import type { PageRequest, PaginatedProposals } from '@/types'; import { LoadingStatus } from './useDashboard'; -import { useWalletStore } from './useWalletStore' +import { useWalletStore } from './useWalletStore'; import { reactive } from 'vue'; export const useGovStore = defineStore('govStore', { @@ -23,41 +23,49 @@ export const useGovStore = defineStore('govStore', { }, walletstore() { return useWalletStore(); - } + }, }, actions: { initial() { - this.$reset() + this.$reset(); this.fetchParams(); - this.fetchProposals("2"); + this.fetchProposals('2'); }, async fetchProposals(status: string, pagination?: PageRequest) { //if (!this.loading[status]) { - this.loading[status] = LoadingStatus.Loading; - const proposals = reactive( - await this.blockchain.rpc?.getGovProposals(status, pagination) - ); - if (status === '2') { - proposals?.proposals?.forEach((item) => { - this.fetchTally(item.proposal_id).then((res) => { - item.final_tally_result = res?.tally; - }); - if (this.walletstore.currentAddress) { - try { - this.fetchProposalVotesVoter(item.proposal_id, this.walletstore.currentAddress).then((res) => { - item.voterStatus = res?.vote?.option || 'No With Veto' - }); - } catch (error) { - item.voterStatus = 'No With Veto' - } - } else { - item.voterStatus = 'No With Veto' - } + this.loading[status] = LoadingStatus.Loading; + const proposals = reactive( + await this.blockchain.rpc?.getGovProposals(status, pagination) + ); + if (status === '2') { + proposals?.proposals?.forEach((item) => { + this.fetchTally(item.proposal_id).then((res) => { + item.final_tally_result = res?.tally; }); - } + if (this.walletstore.currentAddress) { + try { + this.fetchProposalVotesVoter( + item.proposal_id, + this.walletstore.currentAddress + ) + .then((res) => { + item.voterStatus = res?.vote?.option || 'VOTE_OPTION_NO_WITH_VETO' + // 'No With Veto'; + }) + .catch((reject) => { + item.voterStatus = 'VOTE_OPTION_NO_WITH_VETO' + }); + } catch (error) { + item.voterStatus = 'VOTE_OPTION_NO_WITH_VETO' + } + } else { + item.voterStatus = 'VOTE_OPTION_NO_WITH_VETO' + } + }); + } - this.loading[status] = LoadingStatus.Loaded; - this.proposals[status] = proposals; + this.loading[status] = LoadingStatus.Loaded; + this.proposals[status] = proposals; //} return this.proposals[status]; }, diff --git a/src/types/gov.ts b/src/types/gov.ts index a0261e5f..c09a380f 100644 --- a/src/types/gov.ts +++ b/src/types/gov.ts @@ -1,79 +1,83 @@ - -import type { Coin, PaginatedResponse } from "./common" +import type { Coin, PaginatedResponse } from './common'; export interface GovParams { - "voting_params": { - "voting_period": string, - "proposal_voting_periods": any[], - "expedited_voting_period": string - }, - "deposit_params": { - "min_deposit": Coin[], - "max_deposit_period": string, - "min_expedited_deposit": Coin[], - "min_initial_deposit_ratio": string - }, - "tally_params": { - "quorum": string, - "threshold": string, - "veto_threshold": string, - "expedited_threshold": string - } + voting_params: { + voting_period: string; + proposal_voting_periods: any[]; + expedited_voting_period: string; + }; + deposit_params: { + min_deposit: Coin[]; + max_deposit_period: string; + min_expedited_deposit: Coin[]; + min_initial_deposit_ratio: string; + }; + tally_params: { + quorum: string; + threshold: string; + veto_threshold: string; + expedited_threshold: string; + }; } export interface GovProposal { - "proposal_id": string, - "content": { - "@type": string, - "title": string, - "description": string, - "plan"?: { - 'height'?: string | number, - 'time'?: string | number, - } - }, - "status": string, - "final_tally_result": { - "yes": string, - "abstain": string, - "no": string, - "no_with_veto": string, - }, - "submit_time": string, - "deposit_end_time": string, - "total_deposit": Coin[], - "voting_start_time": string, - "voting_end_time": string, - "is_expedited": boolean, - "voterStatus"?: string, + proposal_id: string; + content: { + '@type': string; + title: string; + description: string; + plan?: { + height?: string | number; + time?: string | number; + }; + }; + status: string; + final_tally_result: { + yes: string; + abstain: string; + no: string; + no_with_veto: string; + }; + submit_time: string; + deposit_end_time: string; + total_deposit: Coin[]; + voting_start_time: string; + voting_end_time: string; + is_expedited: boolean; + voterStatus?: string +// VoteOption[]; } +export interface VoteOption { + option: string; + weight: string; +} export interface Tally { - yes: string, - abstain: string, - no: string, - no_with_veto: string + yes: string; + abstain: string; + no: string; + no_with_veto: string; } export interface GovVote { - proposal_id: string, - voter: string, - option: string, - options: { "option": string, "weight": string }[] + proposal_id: string; + voter: string; + option: string; + options: { option: string; weight: string }[]; } export interface PaginatedProposals extends PaginatedResponse { - proposals: GovProposal[] + proposals: GovProposal[]; } export interface PaginatedProposalDeposit extends PaginatedResponse { - deposits: { - amount: Coin[], - proposal_id: string, - depositor: string - } + deposits: { + amount: Coin[]; + proposal_id: string; + depositor: string; + }; } export interface PaginatedProposalVotes extends PaginatedResponse { - votes: GovVote[] -} \ No newline at end of file + votes: GovVote[]; +} From 9adf179b7bd89e37e9305fc97540cde5dc300bbb Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 16:30:08 +0800 Subject: [PATCH 02/22] feat: add consensus page --- src/modules/[chain]/consensus/index.vue | 137 ++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/modules/[chain]/consensus/index.vue diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue new file mode 100644 index 00000000..3f50a2af --- /dev/null +++ b/src/modules/[chain]/consensus/index.vue @@ -0,0 +1,137 @@ + + + + + + { + meta: { + i18n: 'consensus', + } + } + From 1fb696e6c6beb439ec37dd4442c26d51717128f0 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 16:30:29 +0800 Subject: [PATCH 03/22] feat: add i18n --- src/plugins/i18n/locales/cn.json | 3 ++- src/plugins/i18n/locales/en.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/i18n/locales/cn.json b/src/plugins/i18n/locales/cn.json index c2f010df..e73441e3 100644 --- a/src/plugins/i18n/locales/cn.json +++ b/src/plugins/i18n/locales/cn.json @@ -5,7 +5,8 @@ "staking": "质押生息", "governance": "社区治理", "parameters": "参数", - "uptime": "状态" + "uptime": "状态", + "consensus": "Consensus" }, "index": { "slogan": "Ping Dashboard 是一个区块链浏览器,也是一个网页钱包,还有更多 ... 🛠", diff --git a/src/plugins/i18n/locales/en.json b/src/plugins/i18n/locales/en.json index fa57d67c..33da7d76 100644 --- a/src/plugins/i18n/locales/en.json +++ b/src/plugins/i18n/locales/en.json @@ -9,7 +9,8 @@ "state-sync": "State Sync", "cosmwasm": "Cosmwasm", "widget": "Widgets", - "ibc": "IBC" + "ibc": "IBC", + "consensus": "Consensus" }, "index": { "slogan": "Ping Dashboard is not just an explorer but also a wallet and more ... 🛠", From 0bf0ebb0596a57ed85460016de1036e7f95c113a Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 16:37:06 +0800 Subject: [PATCH 04/22] feat: add sign btn --- src/modules/[chain]/consensus/index.vue | 9 ++++++++- src/stores/useBlockchain.ts | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue index 3f50a2af..57e0c01f 100644 --- a/src/modules/[chain]/consensus/index.vue +++ b/src/modules/[chain]/consensus/index.vue @@ -121,9 +121,16 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
-

Updated at {{ }}

+

Updated at {{}}

+
+
+ Proposer Signed + Proposer Not Signed + Signed + Not Signed +
diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index d3063557..9841a9ba 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -35,6 +35,7 @@ export const useBlockchain = defineStore('blockchain', { }, getters: { current(): ChainConfig | undefined { + console.log(this.dashboard.chains[this.chainName], 'jljfkj') return this.dashboard.chains[this.chainName]; }, logo(): string { From 98f1696a5deb4260dd6ff3f12a50c96350d6912f Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 16:56:47 +0800 Subject: [PATCH 05/22] feat: add tips --- src/modules/[chain]/consensus/index.vue | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue index 57e0c01f..c08738b3 100644 --- a/src/modules/[chain]/consensus/index.vue +++ b/src/modules/[chain]/consensus/index.vue @@ -36,7 +36,7 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc); class="input input-bordered input-md w-full" v-model="rpc" /> --> - @@ -132,6 +132,30 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc); Not Signed + + +
+
+

Tips

+
+
+
    +
  • + This tool is useful for validators to monitor who is onboard during + an upgrade +
  • +
  • + If you want to change the default rpc endpoint. make sure that + "https" and "CORS" are enabled on your server. +
  • +
+
+
From 31434f96f3bbd2363d49775b1fcd1cf276047e53 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Mon, 5 Jun 2023 19:10:03 +0800 Subject: [PATCH 06/22] feat: add function --- src/modules/[chain]/consensus/index.vue | 53 +++++++++++++++++++++---- src/stores/useStakingStore.ts | 1 + 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue index c08738b3..1cbeac60 100644 --- a/src/modules/[chain]/consensus/index.vue +++ b/src/modules/[chain]/consensus/index.vue @@ -1,4 +1,5 @@