diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 25d54338..3c4bdea2 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -102,18 +102,26 @@ export default class ChainFetch { } async getValidatorDistribution(address) { - // return this.get(`/distribution/validators/${address}`).then(data => { - return Promise.all([ - this.get(`/cosmos/distribution/v1beta1/validators/${address}/commission`), - this.get(`/cosmos/distribution/v1beta1/validators/${address}/outstanding_rewards`), - ]).then(data => { + return this.get(`/distribution/validators/${address}`).then(data => { + const value = commonProcess(data) const ret = ValidatorDistribution.create({ operator_address: address, - self_bond_rewards: data[1].rewards.rewards, - val_commission: data[0].commission.commission, + self_bond_rewards: value.self_bond_rewards, + val_commission: value.val_commission.commission, }) return ret }) + // return Promise.all([ + // this.get(`/cosmos/distribution/v1beta1/validators/${address}/commission`), + // this.get(`/cosmos/distribution/v1beta1/validators/${address}/outstanding_rewards`), + // ]).then(data => { + // const ret = ValidatorDistribution.create({ + // operator_address: address, + // self_bond_rewards: data[1].rewards.rewards, + // val_commission: data[0].commission.commission, + // }) + // return ret + // }) } async getStakingDelegatorDelegation(delegatorAddr, validatorAddr) { @@ -370,7 +378,7 @@ export default class ChainFetch { async getAuthAccount(address, config = null) { return this.get('/cosmos/auth/v1beta1/accounts/'.concat(address), config).then(data => { const result = commonProcess(data) - return result.value ? result : { value: result } + return result }) } diff --git a/src/libs/utils.js b/src/libs/utils.js index fdd57a14..e8240e93 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -156,11 +156,11 @@ export function chartColors() { } export function extractAccountNumberAndSequence(ret) { - let account = ret.value - if (ret.value && ret.value.base_vesting_account) { // vesting account - account = ret.value.base_vesting_account?.base_account - } else if (ret.value && ret.value.base_account) { // evmos based account - account = ret.value.base_account + let { account } = ret + if (account && account.base_vesting_account) { // vesting account + account = account.base_vesting_account?.base_account + } else if (account && account.base_account) { // evmos based account + account = account.base_account } const accountNumber = account.account_number const sequence = account?.sequence || 0 diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue index 5cabd885..9feea086 100644 --- a/src/views/components/OperationModal/index.vue +++ b/src/views/components/OperationModal/index.vue @@ -358,8 +358,8 @@ export default { this.sequence = account.sequence }) this.$http.getBankBalances(this.selectedAddress, this.selectedChain).then(res => { - if (res && res.length > 0) { - this.balance = res.reverse() + if (res.balances && res.balances.length > 0) { + this.balance = res.balances.reverse() const token = this.balance.find(i => !i.denom.startsWith('ibc')) this.token = token.denom if (token) this.feeDenom = token.denom @@ -391,6 +391,7 @@ export default { }, async sendTx() { const txMsgs = this.$refs.component.msg + if (txMsgs.length === 0) { this.error = 'No delegation found' return ''