forked from LaconicNetwork/cosmos-explorer
add gov
This commit is contained in:
@@ -151,7 +151,10 @@ export const useFormatter = defineStore('formatter', {
|
||||
})
|
||||
return output.join(', ')
|
||||
}
|
||||
},
|
||||
},
|
||||
multiLine(v: string) {
|
||||
return v? v.replaceAll("\\n","\n"): ""
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { useBlockchain } from "./useBlockchain";
|
||||
import type { PageRequest } from "@/types";
|
||||
import type { PageRequest, PaginatedProposals } from "@/types";
|
||||
import { LoadingStatus } from "./useDashboard";
|
||||
|
||||
export const useGovStore = defineStore('govStore', {
|
||||
state: () => {
|
||||
@@ -9,7 +10,9 @@ export const useGovStore = defineStore('govStore', {
|
||||
deposit: {},
|
||||
voting: {},
|
||||
tally: {},
|
||||
}
|
||||
},
|
||||
proposals: {} as Record<string, PaginatedProposals>,
|
||||
loading: {} as Record<string, LoadingStatus>
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
@@ -22,8 +25,22 @@ export const useGovStore = defineStore('govStore', {
|
||||
this.fetchParams()
|
||||
},
|
||||
async fetchProposals( status: string, pagination?: PageRequest ) {
|
||||
const proposals = await this.blockchain.rpc.getGovProposals(status)
|
||||
return proposals
|
||||
if(!this.loading[status]) {
|
||||
this.loading[status] = LoadingStatus.Loading
|
||||
const proposals = await this.blockchain.rpc.getGovProposals(status)
|
||||
this.loading[status] = LoadingStatus.Loaded
|
||||
this.proposals[status] = proposals
|
||||
|
||||
if(status === '2') {
|
||||
proposals.proposals.forEach(x1 => {
|
||||
this.fetchTally(x1.proposal_id).then(t => {
|
||||
x1.final_tally_result = t.tally
|
||||
this.proposals[status] = proposals
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
return this.proposals[status]
|
||||
},
|
||||
async fetchParams() {
|
||||
// this.blockchain.rpc.getGovParamsDeposit().then(x => {
|
||||
|
||||
Reference in New Issue
Block a user