update active validator set

This commit is contained in:
BitcoinVM 2024-02-26 09:37:47 +08:00
parent d0b42899a4
commit 5c341e9306

View File

@ -63,7 +63,7 @@ export const useStakingStore = defineStore('stakingStore', {
} }
}, },
async fetchAcitveValdiators() { async fetchAcitveValdiators() {
return this.fetchValidators('BOND_STATUS_BONDED'); return this.fetchValidators('BOND_STATUS_BONDED', 500);
}, },
async fetchInacitveValdiators() { async fetchInacitveValdiators() {
return this.fetchValidators('BOND_STATUS_UNBONDED'); return this.fetchValidators('BOND_STATUS_UNBONDED');
@ -132,12 +132,12 @@ export const useStakingStore = defineStore('stakingStore', {
await this.fetchKeyRotation(chain_id, pubKeyToValcons(val.consensus_pubkey, prefix.replace('valoper',''))) await this.fetchKeyRotation(chain_id, pubKeyToValcons(val.consensus_pubkey, prefix.replace('valoper','')))
} }
}, },
async fetchValidators(status: string) { async fetchValidators(status: string, limit = 300) {
if(this.blockchain.isConsumerChain) { if(this.blockchain.isConsumerChain) {
if(this.blockchain.current?.providerChain.api && this.blockchain.current.providerChain.api.length > 0) { if(this.blockchain.current?.providerChain.api && this.blockchain.current.providerChain.api.length > 0) {
const client = CosmosRestClient.newDefault(this.blockchain.current.providerChain.api[0].address) const client = CosmosRestClient.newDefault(this.blockchain.current.providerChain.api[0].address)
// provider validators // provider validators
const res = await client.getStakingValidators(status) const res = await client.getStakingValidators(status, limit)
const proVals = res.validators.sort( const proVals = res.validators.sort(
(a, b) => Number(b.delegator_shares) - Number(a.delegator_shares) (a, b) => Number(b.delegator_shares) - Number(a.delegator_shares)
) )
@ -148,7 +148,7 @@ export const useStakingStore = defineStore('stakingStore', {
return proVals return proVals
} }
} }
return this.blockchain.rpc?.getStakingValidators(status).then((res) => { return this.blockchain.rpc?.getStakingValidators(status, limit).then((res) => {
const vals = res.validators.sort( const vals = res.validators.sort(
(a, b) => Number(b.delegator_shares) - Number(a.delegator_shares) (a, b) => Number(b.delegator_shares) - Number(a.delegator_shares)
); );