Merge pull request #265 from effofxprime/master

Fix - Delegate/Redelegate decimal issue
This commit is contained in:
ping 2022-11-11 09:27:41 +08:00 committed by GitHub
commit 972290e451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 7 deletions

View File

@ -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)

View File

@ -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,
})

View File

@ -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: '',
}

View File

@ -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)
},
},
}

View File

@ -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 [{