diff --git a/src/components/ProposalListItem.vue b/src/components/ProposalListItem.vue index 7b32a13a..7a4bc4e0 100644 --- a/src/components/ProposalListItem.vue +++ b/src/components/ProposalListItem.vue @@ -1,14 +1,19 @@ - + @@ -98,9 +109,25 @@ const proposalInfo = ref(); - - - Vote + + + Vote + + + {{ item?.voterStatus }} + @@ -176,8 +203,26 @@ const proposalInfo = ref(); > - - Vote + + + Vote + + + {{ item?.voterStatus }} + + diff --git a/src/modules/[chain]/gov/index.vue b/src/modules/[chain]/gov/index.vue index 407751b2..b6c528a8 100644 --- a/src/modules/[chain]/gov/index.vue +++ b/src/modules/[chain]/gov/index.vue @@ -41,7 +41,7 @@ const changeTab = (val: '2' | '3' | '4') => { >Rejected - + diff --git a/src/stores/useGovStore.ts b/src/stores/useGovStore.ts index 9bb628da..3b2a2a14 100644 --- a/src/stores/useGovStore.ts +++ b/src/stores/useGovStore.ts @@ -2,6 +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 { reactive } from 'vue'; export const useGovStore = defineStore('govStore', { @@ -20,6 +21,9 @@ export const useGovStore = defineStore('govStore', { blockchain() { return useBlockchain(); }, + walletstore() { + return useWalletStore(); + } }, actions: { initial() { @@ -34,12 +38,29 @@ export const useGovStore = defineStore('govStore', { await this.blockchain.rpc?.getGovProposals(status) ); if (status === '2') { - proposals?.proposals?.forEach(async (x1) => { - await this.fetchTally(x1.proposal_id).then((res) => { - x1.final_tally_result = res?.tally; + proposals?.proposals?.forEach(async (item) => { + await this.fetchTally(item.proposal_id).then((res) => { + item.final_tally_result = res?.tally; + // + }); + if (this.walletstore.connectedWallet?.cosmosAddress) { + try { + await this.fetchProposalVotesVoter(item.proposal_id,this.walletstore.currentAddress).then((res) => { + console.log(res, 'fdfsds') + // VOTE_OPTION_YES VOTE_OPTION_NO VOTE_OPTION_ABSTAIN + item.voterStatus = res?.vote?.option || 'No With Veto' + }); + } catch (error) { + item.voterStatus = 'No With Veto' + } + console.log(this.walletstore.connectedWallet, 'this.walletstore.connectedWallet') + } else { + item.voterStatus = 'No With Veto' + } }); } + this.loading[status] = LoadingStatus.Loaded; this.proposals[status] = proposals; } @@ -62,5 +83,8 @@ export const useGovStore = defineStore('govStore', { async fetchProposalVotes(proposalId: string, next_key?: string) { return this.blockchain.rpc.getGovProposalVotes(proposalId, next_key); }, + async fetchProposalVotesVoter(proposalId: string, voter: string) { + return this.blockchain.rpc.getGovProposalVotesVoter(proposalId, voter); + }, }, }); diff --git a/src/types/gov.ts b/src/types/gov.ts index 7f9b4d53..a0261e5f 100644 --- a/src/types/gov.ts +++ b/src/types/gov.ts @@ -44,7 +44,8 @@ export interface GovProposal { "total_deposit": Coin[], "voting_start_time": string, "voting_end_time": string, - "is_expedited": boolean + "is_expedited": boolean, + "voterStatus"?: string, } export interface Tally {