Fix delegations fetch error

This commit is contained in:
liangping 2021-10-14 02:50:39 +08:00
parent fb1b6edc01
commit b54eec0d4b
2 changed files with 10 additions and 9 deletions

View File

@ -260,7 +260,7 @@ const chainAPI = class ChainFetch {
}
async getStakingReward(address, config = null) {
if (compareVersions(config || this.config.sdk_version, '0.40') < 0) {
if (compareVersions(config ? config.sdk_version : this.config.sdk_version, '0.40') < 0) {
return this.get(`/distribution/delegators/${address}/rewards`, config).then(data => commonProcess(data))
}
return this.get(`/cosmos/distribution/v1beta1/delegators/${address}/rewards`).then(data => commonProcess(data))
@ -271,7 +271,7 @@ const chainAPI = class ChainFetch {
}
async getStakingDelegations(address, config = null) {
if (compareVersions(config || this.config.sdk_version, '0.40') < 0) {
if (compareVersions(config ? config.sdk_version : this.config.sdk_version, '0.40') < 0) {
return this.get(`/staking/delegators/${address}/delegations`, config).then(data => commonProcess(data).map(x => {
const xh = x
if (!xh.delegation) {
@ -287,14 +287,14 @@ const chainAPI = class ChainFetch {
}
async getStakingRedelegations(address, config = null) {
if (compareVersions(config || this.config.sdk_version, '0.40') < 0) {
if (compareVersions(config ? config.sdk_version : this.config.sdk_version, '0.40') < 0) {
return this.get(`/staking/redelegations?delegator=${address}`, config).then(data => commonProcess(data))
}
return this.get(`/cosmos/staking/v1beta1/delegators/${address}/redelegations`, config).then(data => commonProcess(data))
}
async getStakingUnbonding(address, config = null) {
if (compareVersions(config || this.config.sdk_version, '0.40') < 0) {
if (compareVersions(config ? config.sdk_version : this.config.sdk_version, '0.40') < 0) {
return this.get(`/staking/delegators/${address}/unbonding_delegations`, config).then(data => commonProcess(data))
}
return this.get(`/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`, config).then(data => commonProcess(data))

View File

@ -245,9 +245,7 @@
<b-td> Public Key </b-td><b-td> <object-field-component :tablefield="account.value.public_key" /> </b-td>
</b-tr>
</b-tbody>
<b-tbody
v-if="account.type === 'cosmos-sdk/PeriodicVestingAccount' && account.value.base_vesting_account"
>
<b-tbody v-else-if="account.type === 'cosmos-sdk/PeriodicVestingAccount' && account.value.base_vesting_account">
<b-tr>
<b-td>
Account Type
@ -326,7 +324,7 @@
</b-tbody>
<object-field-component
v-else
:tablefield="account.value?account.value:account"
:tablefield="account.value || account"
/>
</b-table-simple>
</b-card>
@ -521,6 +519,9 @@ export default {
tmp1 += Number(e.balance)
})
})
const unbonding = this.formatCurrency(tmp1, stakingDenom)
sumCurrency += unbonding
sum += tmp1
total.push({
type: 'unbonding',
color: 'danger',
@ -528,7 +529,7 @@ export default {
denom: stakingDenom,
amount: tmp1,
percent: 0,
currency: 0,
currency: unbonding,
})
}
total = total.map(x => {