Fixed issue: unable to delegate to unbond validators

This commit is contained in:
liangping 2022-02-11 17:58:53 +08:00
parent 10ad6fef38
commit 3f0dcdf276
3 changed files with 22 additions and 2 deletions

View File

@ -148,6 +148,14 @@ export default class ChainFetch {
})
}
async getValidatorUnbondedList() {
return this.get('/cosmos/staking/v1beta1/validators?status=BOND_STATUS_UNBONDED').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(`/validatorsets/${height}`).then(data => commonProcess(data))
}

View File

@ -294,6 +294,7 @@ export default {
selectedAddress: this.address,
availableAddress: [],
validators: [],
unbundValidators: [],
selectedValidator: null,
token: '',
amount: null,
@ -327,7 +328,9 @@ export default {
},
computed: {
valOptions() {
return this.validators.map(x => ({ value: x.operator_address, label: `${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
const vals = this.validators.map(x => ({ value: x.operator_address, label: `${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
const unbunded = this.unbundValidators.map(x => ({ value: x.operator_address, label: `* ${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
return vals.concat(unbunded)
},
feeDenoms() {
if (!this.balance) return []
@ -401,6 +404,9 @@ export default {
this.$http.getValidatorList().then(v => {
this.validators = v
})
this.$http.getValidatorUnbondedList().then(v => {
this.unbundValidators = v
})
this.onChange()
},
handleOk(bvModalEvt) {

View File

@ -256,6 +256,7 @@ export default {
return {
selectedAddress: this.address,
availableAddress: [],
unbundValidators: [],
validators: [],
toValidator: null,
token: '',
@ -290,7 +291,9 @@ export default {
},
computed: {
valOptions() {
return this.validators.map(x => ({ value: x.operator_address, label: `${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
const vals = this.validators.map(x => ({ value: x.operator_address, label: `${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
const unbunded = this.unbundValidators.map(x => ({ value: x.operator_address, label: `* ${x.description.moniker} (${Number(x.commission.rate) * 100}%)` }))
return vals.concat(unbunded)
},
tokenOptions() {
if (!this.delegations) return []
@ -312,6 +315,9 @@ export default {
this.$http.getValidatorList().then(v => {
this.validators = v
})
this.$http.getValidatorUnbondedList().then(v => {
this.unbundValidators = v
})
this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) {
this.balance = res.reverse()