forked from cerc-io/cosmos-explorer
Fix - Delegate/Redelegate decimal issue
The options for delegation and redelegation in the "Delegation" area for the Dashboard or Wallet details, when clicked only represented the amount with 2 decimals. Often this was rounding up and when a user chooses to redelegate, if they enter in the amount shown can run into an issue where they cannot submit the transaction due to the share amount being incorrect.
This commit is contained in:
parent
d86f9753ff
commit
03a2f3e4ef
@ -469,7 +469,7 @@ import {
|
||||
} from 'bootstrap-vue'
|
||||
import {
|
||||
formatNumber, formatTokenAmount, isToken, percent, timeIn, toDay, toDuration, tokenFormatter, getLocalAccounts,
|
||||
getStakingValidatorOperator,
|
||||
getStakingValidatorOperator, formatToken,
|
||||
} from '@/libs/utils'
|
||||
import OperationModal from '@/views/components/OperationModal/index.vue'
|
||||
import Ripple from 'vue-ripple-directive'
|
||||
@ -580,10 +580,12 @@ export default {
|
||||
stakingList() {
|
||||
return this.delegations.map(x => {
|
||||
const rewards = this.rewards.find(r => r.validator_address === x.delegation.validator_address)
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
return {
|
||||
valAddress: x.delegation.validator_address,
|
||||
validator: getStakingValidatorOperator(this.$store.state.chains.selected.chain_name, x.delegation.validator_address),
|
||||
delegation: this.formatToken([x.balance]),
|
||||
delegation: formatToken(x.balance, {}, decimal),
|
||||
rewards: rewards ? this.formatToken(rewards.reward) : '',
|
||||
action: '',
|
||||
}
|
||||
@ -697,6 +699,8 @@ export default {
|
||||
return '-'
|
||||
},
|
||||
fetchAccount(address) {
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
this.address = address
|
||||
this.$http.getBankAccountBalance(address).then(bal => {
|
||||
this.walletBalances = this.formatToken(bal)
|
||||
|
@ -621,12 +621,14 @@ export default {
|
||||
},
|
||||
deleTable() {
|
||||
const re = []
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
if (this.reward.rewards && this.delegations && this.delegations.length > 0) {
|
||||
this.delegations.forEach(e => {
|
||||
const reward = this.reward.rewards.find(r => r.validator_address === e.delegation.validator_address)
|
||||
re.push({
|
||||
validator: getStakingValidatorOperator(this.$http.config.chain_name, e.delegation.validator_address, 8),
|
||||
token: formatToken(e.balance, {}, 2),
|
||||
token: formatToken(e.balance, {}, decimal),
|
||||
reward: tokenFormatter(reward.reward, this.denoms),
|
||||
action: e.delegation.validator_address,
|
||||
})
|
||||
|
@ -119,6 +119,8 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
formatedDelegations() {
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
return this.delegations.map(x => ({
|
||||
validator: {
|
||||
logo: x.chain.logo,
|
||||
@ -128,13 +130,15 @@ export default {
|
||||
},
|
||||
delegator: x.keyname,
|
||||
delegator_address: x.delegation.delegator_address,
|
||||
delegation: formatToken(x.balance),
|
||||
delegation: formatToken(x.balance, {}, decimal),
|
||||
reward: this.findReward(x.delegation.delegator_address, x.delegation.validator_address),
|
||||
// action: '',
|
||||
}))
|
||||
},
|
||||
groupedDelegations() {
|
||||
const group = {}
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
this.delegations.forEach(x => {
|
||||
const d = {
|
||||
validator: {
|
||||
@ -145,7 +149,7 @@ export default {
|
||||
},
|
||||
delegator: x.keyname,
|
||||
delegator_address: x.delegation.delegator_address,
|
||||
delegation: formatToken(x.balance),
|
||||
delegation: formatToken(x.balance, {}, decimal),
|
||||
reward: this.findReward(x.delegation.delegator_address, x.delegation.validator_address),
|
||||
// action: '',
|
||||
}
|
||||
|
@ -235,7 +235,9 @@ export default {
|
||||
return formatTokenDenom(this.token)
|
||||
},
|
||||
format(v) {
|
||||
return formatToken(v, this.IBCDenom, 6)
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
return formatToken(v, this.IBCDenom, decimal)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -179,8 +179,10 @@ export default {
|
||||
return options
|
||||
},
|
||||
tokenOptions() {
|
||||
const conf = this.$http.getSelectedConfig()
|
||||
const decimal = conf.assets.exponent || '6'
|
||||
if (!this.delegations) return []
|
||||
return this.delegations.filter(x => x.delegation.validator_address === this.validatorAddress).map(x => ({ value: x.balance.denom, label: formatToken(x.balance) }))
|
||||
return this.delegations.filter(x => x.delegation.validator_address === this.validatorAddress).map(x => ({ value: x.balance.denom, label: formatToken(x.balance, {}, decimal) }))
|
||||
},
|
||||
msg() {
|
||||
return [{
|
||||
|
Loading…
Reference in New Issue
Block a user