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) { async getValidatorListByHeight(height) {
return this.get(`/validatorsets/${height}`).then(data => commonProcess(data)) return this.get(`/validatorsets/${height}`).then(data => commonProcess(data))
} }

View File

@ -294,6 +294,7 @@ export default {
selectedAddress: this.address, selectedAddress: this.address,
availableAddress: [], availableAddress: [],
validators: [], validators: [],
unbundValidators: [],
selectedValidator: null, selectedValidator: null,
token: '', token: '',
amount: null, amount: null,
@ -327,7 +328,9 @@ export default {
}, },
computed: { computed: {
valOptions() { 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() { feeDenoms() {
if (!this.balance) return [] if (!this.balance) return []
@ -401,6 +404,9 @@ export default {
this.$http.getValidatorList().then(v => { this.$http.getValidatorList().then(v => {
this.validators = v this.validators = v
}) })
this.$http.getValidatorUnbondedList().then(v => {
this.unbundValidators = v
})
this.onChange() this.onChange()
}, },
handleOk(bvModalEvt) { handleOk(bvModalEvt) {

View File

@ -256,6 +256,7 @@ export default {
return { return {
selectedAddress: this.address, selectedAddress: this.address,
availableAddress: [], availableAddress: [],
unbundValidators: [],
validators: [], validators: [],
toValidator: null, toValidator: null,
token: '', token: '',
@ -290,7 +291,9 @@ export default {
}, },
computed: { computed: {
valOptions() { 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() { tokenOptions() {
if (!this.delegations) return [] if (!this.delegations) return []
@ -312,6 +315,9 @@ export default {
this.$http.getValidatorList().then(v => { this.$http.getValidatorList().then(v => {
this.validators = v this.validators = v
}) })
this.$http.getValidatorUnbondedList().then(v => {
this.unbundValidators = v
})
this.$http.getBankBalances(this.address).then(res => { this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.balance = res.reverse() this.balance = res.reverse()