forked from cerc-io/cosmos-explorer
Merge pull request #265 from effofxprime/master
Fix - Delegate/Redelegate decimal issue
This commit is contained in:
commit
972290e451
@ -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[0].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[0].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[0].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[0].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[0].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[0].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[0].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