fix redelegate

This commit is contained in:
donne1226 2022-03-30 21:50:49 +08:00
parent a592e0ed16
commit f99f0093b9

View File

@ -147,13 +147,7 @@ export default {
toValidator: null, toValidator: null,
token: '', token: '',
amount: null, amount: null,
balance: [],
delegations: [], delegations: [],
feeDenom: '',
error: null,
sequence: 1,
accountNumber: 0,
account: [],
required, required,
password, password,
@ -170,9 +164,18 @@ export default {
}, },
computed: { computed: {
valOptions() { valOptions() {
let options = []
const vals = 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}%)` }))
if (vals.length > 0) {
options.push({ value: null, label: '=== ACTIVE VALIDATORS ===' })
options = options.concat(vals)
}
const unbunded = this.unbundValidators.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) if (unbunded.length > 0) {
options.push({ value: null, label: '=== INACTIVE VALIDATORS ===', disabled: true })
options = options.concat(unbunded)
}
return options
}, },
tokenOptions() { tokenOptions() {
if (!this.delegations) return [] if (!this.delegations) return []
@ -198,24 +201,16 @@ export default {
modalTitle: 'Redelegate Token', modalTitle: 'Redelegate Token',
historyName: 'redelegate', historyName: 'redelegate',
}) })
this.loadBalance() this.loadData()
}, },
methods: { methods: {
printDenom() { loadData() {
return formatTokenDenom(this.token)
},
loadBalance() {
this.$http.getValidatorList().then(v => { this.$http.getValidatorList().then(v => {
this.validators = v this.validators = v
}) })
this.$http.getValidatorUnbondedList().then(v => { this.$http.getValidatorUnbondedList().then(v => {
this.unbundValidators = v this.unbundValidators = v
}) })
this.$http.getBankBalances(this.address).then(res => {
if (res && res.length > 0) {
this.balance = res.reverse()
}
})
this.$http.getStakingDelegations(this.address).then(res => { this.$http.getStakingDelegations(this.address).then(res => {
this.delegations = res.delegation_responses this.delegations = res.delegation_responses
console.log(res) console.log(res)
@ -233,7 +228,9 @@ export default {
format(v) { format(v) {
return formatToken(v) return formatToken(v)
}, },
printDenom() {
return formatTokenDenom(this.token)
},
}, },
} }
</script> </script>