commit
405cb90667
@ -157,15 +157,15 @@ export default class ChainFetch {
|
||||
}
|
||||
|
||||
async getValidatorListByStatus(status) {
|
||||
return this.get(`/cosmos/staking/v1beta1/validators?status=${status}`).then(data => {
|
||||
return this.get(`/cosmos/staking/v1beta1/validators?status=${status}&pagination.limit=500`).then(data => {
|
||||
const result = commonProcess(data)
|
||||
const vals = result.validators ? result.validators : result
|
||||
return vals.map(i => new Validator().init(i))
|
||||
})
|
||||
}
|
||||
|
||||
async getValidatorListByHeight(height) {
|
||||
return this.get(`/cosmos/base/tendermint/v1beta1/validatorsets/${height}?pagination.limit=500`).then(data => commonProcess(data))
|
||||
async getValidatorListByHeight(height, offset) {
|
||||
return this.get(`/cosmos/base/tendermint/v1beta1/validatorsets/${height}?pagination.limit=100&pagination.offset=${offset}`).then(data => commonProcess(data))
|
||||
}
|
||||
|
||||
async getStakingValidator(address) {
|
||||
|
@ -327,28 +327,7 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$http.getValidatorListByHeight('latest').then(data => {
|
||||
let height = Number(data.block_height)
|
||||
if (height > 14400) {
|
||||
height -= 14400
|
||||
} else {
|
||||
height = 1
|
||||
}
|
||||
const changes = {}
|
||||
data.validators.forEach(x => {
|
||||
changes[x.pub_key.key] = { latest: Number(x.voting_power), previous: 0 }
|
||||
})
|
||||
this.$http.getValidatorListByHeight(height).then(previous => {
|
||||
previous.validators.forEach(x => {
|
||||
if (changes[x.pub_key.key]) {
|
||||
changes[x.pub_key.key].previous = Number(x.voting_power)
|
||||
} else {
|
||||
changes[x.pub_key.key] = { latest: 0, previous: Number(x.voting_power) }
|
||||
}
|
||||
})
|
||||
this.$set(this, 'changes', changes)
|
||||
})
|
||||
})
|
||||
this.getValidatorListByHeight()
|
||||
this.$http.getStakingParameters().then(res => {
|
||||
this.stakingParameters = res
|
||||
})
|
||||
@ -358,6 +337,30 @@ export default {
|
||||
this.islive = false
|
||||
},
|
||||
methods: {
|
||||
getValidatorListByHeight(offset = 0) {
|
||||
this.$http.getValidatorListByHeight('latest', offset).then(data => {
|
||||
let height = Number(data.block_height)
|
||||
if (height > 14400) {
|
||||
height -= 14400
|
||||
} else {
|
||||
height = 1
|
||||
}
|
||||
const { changes } = this
|
||||
data.validators.forEach(x => {
|
||||
changes[x.pub_key.key] = { latest: Number(x.voting_power), previous: 0 }
|
||||
})
|
||||
this.$http.getValidatorListByHeight(height, offset).then(previous => {
|
||||
previous.validators.forEach(x => {
|
||||
if (changes[x.pub_key.key]) {
|
||||
changes[x.pub_key.key].previous = Number(x.voting_power)
|
||||
} else {
|
||||
changes[x.pub_key.key] = { latest: 0, previous: Number(x.voting_power) }
|
||||
}
|
||||
})
|
||||
this.$set(this, 'changes', changes)
|
||||
})
|
||||
})
|
||||
},
|
||||
getValidatorListByStatus(statusList) {
|
||||
this.validators = []
|
||||
statusList.forEach(status => {
|
||||
@ -376,6 +379,9 @@ export default {
|
||||
}
|
||||
}
|
||||
this.stakingPool = total
|
||||
if (total > 100) {
|
||||
this.getValidatorListByHeight(100)
|
||||
}
|
||||
this.validators.push(...temp)
|
||||
|
||||
// fetch avatar from keybase
|
||||
|
Loading…
Reference in New Issue
Block a user