diff --git a/src/libs/fetch.js b/src/libs/fetch.js index f94e6b22..450c370d 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -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)) } diff --git a/src/views/OperationDelegateComponent.vue b/src/views/OperationDelegateComponent.vue index 7e9140e2..738daaeb 100644 --- a/src/views/OperationDelegateComponent.vue +++ b/src/views/OperationDelegateComponent.vue @@ -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) { diff --git a/src/views/OperationRedelegateComponent.vue b/src/views/OperationRedelegateComponent.vue index 1db25d1b..df1ceb6e 100644 --- a/src/views/OperationRedelegateComponent.vue +++ b/src/views/OperationRedelegateComponent.vue @@ -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()