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'
|
} from 'bootstrap-vue'
|
||||||
import {
|
import {
|
||||||
formatNumber, formatTokenAmount, isToken, percent, timeIn, toDay, toDuration, tokenFormatter, getLocalAccounts,
|
formatNumber, formatTokenAmount, isToken, percent, timeIn, toDay, toDuration, tokenFormatter, getLocalAccounts,
|
||||||
getStakingValidatorOperator,
|
getStakingValidatorOperator, formatToken,
|
||||||
} from '@/libs/utils'
|
} from '@/libs/utils'
|
||||||
import OperationModal from '@/views/components/OperationModal/index.vue'
|
import OperationModal from '@/views/components/OperationModal/index.vue'
|
||||||
import Ripple from 'vue-ripple-directive'
|
import Ripple from 'vue-ripple-directive'
|
||||||
@ -580,10 +580,12 @@ export default {
|
|||||||
stakingList() {
|
stakingList() {
|
||||||
return this.delegations.map(x => {
|
return this.delegations.map(x => {
|
||||||
const rewards = this.rewards.find(r => r.validator_address === x.delegation.validator_address)
|
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 {
|
return {
|
||||||
valAddress: x.delegation.validator_address,
|
valAddress: x.delegation.validator_address,
|
||||||
validator: getStakingValidatorOperator(this.$store.state.chains.selected.chain_name, 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) : '',
|
rewards: rewards ? this.formatToken(rewards.reward) : '',
|
||||||
action: '',
|
action: '',
|
||||||
}
|
}
|
||||||
@ -697,6 +699,8 @@ export default {
|
|||||||
return '-'
|
return '-'
|
||||||
},
|
},
|
||||||
fetchAccount(address) {
|
fetchAccount(address) {
|
||||||
|
const conf = this.$http.getSelectedConfig()
|
||||||
|
const decimal = conf.assets.exponent || '6'
|
||||||
this.address = address
|
this.address = address
|
||||||
this.$http.getBankAccountBalance(address).then(bal => {
|
this.$http.getBankAccountBalance(address).then(bal => {
|
||||||
this.walletBalances = this.formatToken(bal)
|
this.walletBalances = this.formatToken(bal)
|
||||||
|
@ -621,12 +621,14 @@ export default {
|
|||||||
},
|
},
|
||||||
deleTable() {
|
deleTable() {
|
||||||
const re = []
|
const re = []
|
||||||
|
const conf = this.$http.getSelectedConfig()
|
||||||
|
const decimal = conf.assets.exponent || '6'
|
||||||
if (this.reward.rewards && this.delegations && this.delegations.length > 0) {
|
if (this.reward.rewards && this.delegations && this.delegations.length > 0) {
|
||||||
this.delegations.forEach(e => {
|
this.delegations.forEach(e => {
|
||||||
const reward = this.reward.rewards.find(r => r.validator_address === e.delegation.validator_address)
|
const reward = this.reward.rewards.find(r => r.validator_address === e.delegation.validator_address)
|
||||||
re.push({
|
re.push({
|
||||||
validator: getStakingValidatorOperator(this.$http.config.chain_name, e.delegation.validator_address, 8),
|
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),
|
reward: tokenFormatter(reward.reward, this.denoms),
|
||||||
action: e.delegation.validator_address,
|
action: e.delegation.validator_address,
|
||||||
})
|
})
|
||||||
|
@ -119,6 +119,8 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formatedDelegations() {
|
formatedDelegations() {
|
||||||
|
const conf = this.$http.getSelectedConfig()
|
||||||
|
const decimal = conf.assets.exponent || '6'
|
||||||
return this.delegations.map(x => ({
|
return this.delegations.map(x => ({
|
||||||
validator: {
|
validator: {
|
||||||
logo: x.chain.logo,
|
logo: x.chain.logo,
|
||||||
@ -128,13 +130,15 @@ export default {
|
|||||||
},
|
},
|
||||||
delegator: x.keyname,
|
delegator: x.keyname,
|
||||||
delegator_address: x.delegation.delegator_address,
|
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),
|
reward: this.findReward(x.delegation.delegator_address, x.delegation.validator_address),
|
||||||
// action: '',
|
// action: '',
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
groupedDelegations() {
|
groupedDelegations() {
|
||||||
const group = {}
|
const group = {}
|
||||||
|
const conf = this.$http.getSelectedConfig()
|
||||||
|
const decimal = conf.assets.exponent || '6'
|
||||||
this.delegations.forEach(x => {
|
this.delegations.forEach(x => {
|
||||||
const d = {
|
const d = {
|
||||||
validator: {
|
validator: {
|
||||||
@ -145,7 +149,7 @@ export default {
|
|||||||
},
|
},
|
||||||
delegator: x.keyname,
|
delegator: x.keyname,
|
||||||
delegator_address: x.delegation.delegator_address,
|
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),
|
reward: this.findReward(x.delegation.delegator_address, x.delegation.validator_address),
|
||||||
// action: '',
|
// action: '',
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,9 @@ export default {
|
|||||||
return formatTokenDenom(this.token)
|
return formatTokenDenom(this.token)
|
||||||
},
|
},
|
||||||
format(v) {
|
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
|
return options
|
||||||
},
|
},
|
||||||
tokenOptions() {
|
tokenOptions() {
|
||||||
|
const conf = this.$http.getSelectedConfig()
|
||||||
|
const decimal = conf.assets.exponent || '6'
|
||||||
if (!this.delegations) return []
|
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() {
|
msg() {
|
||||||
return [{
|
return [{
|
||||||
|
Loading…
Reference in New Issue
Block a user