forked from LaconicNetwork/cosmos-explorer
feat: progress voter status add
This commit is contained in:
@@ -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);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user