diff --git a/app/src/renderer/components/staking/LiDelegate.vue b/app/src/renderer/components/staking/LiDelegate.vue index cee75f3784..cbf0dd325b 100644 --- a/app/src/renderer/components/staking/LiDelegate.vue +++ b/app/src/renderer/components/staking/LiDelegate.vue @@ -45,7 +45,10 @@ export default { } else { return 0 } }, vpTotal () { - return this.delegates.reduce((a, b) => a.voting_power + b.voting_power, 0) + return this.delegates + .sort((a, b) => b.voting_power - a.voting_power) + .slice(0, 100) + .reduce((sum, v) => sum + v.voting_power, 0) }, vpStyles () { let percentage = diff --git a/app/src/renderer/vuex/modules/delegation.js b/app/src/renderer/vuex/modules/delegation.js index e73c085bd5..e1561dfa5e 100644 --- a/app/src/renderer/vuex/modules/delegation.js +++ b/app/src/renderer/vuex/modules/delegation.js @@ -47,7 +47,6 @@ export default ({ commit }) => { async getBondedDelegates ({ state, dispatch }, {candidates, address}) { // TODO move into cosmos-sdk candidates.forEach(candidate => { - commit('addToCart', candidate) dispatch('getBondedDelegate', {address, pubkey: candidate.pub_key.data}) }) }, @@ -55,7 +54,6 @@ export default ({ commit }) => { async getBondedDelegate ({ commit }, {address, pubkey}) { // TODO move into cosmos-sdk let bond = (await axios.get('http://localhost:8998/query/stake/delegator/' + address + '/' + pubkey)).data.data - commit('setShares', {candidateId: bond.PubKey.data, value: bond.Shares}) commit('setCommittedDelegation', {candidateId: bond.PubKey.data, value: bond.Shares}) }, async walletDelegate ({ dispatch }, args) { diff --git a/test/unit/specs/LiDelegate.spec.js b/test/unit/specs/LiDelegate.spec.js index de59ff4072..50322ab096 100644 --- a/test/unit/specs/LiDelegate.spec.js +++ b/test/unit/specs/LiDelegate.spec.js @@ -54,15 +54,15 @@ describe('LiDelegate', () => { }) it('should show the voting power', () => { - expect(wrapper.html()).toContain('10,000') + expect(wrapper.html()).toContain('75%') }) - it('should show the relative voting power as a bar', () => { - expect(wrapper.vm.$el.querySelector('.voting_power .bar').style.width).toBe(Math.floor(10000 / 30000 * 100) + '%') + it('should show the number of bonded atoms', () => { + expect(wrapper.html()).toContain('30,000') }) - it('should show the relative shares hold as a bar', () => { - expect(wrapper.vm.$el.querySelector('.voting_power .bar').style.width).toBe(Math.floor(5000 / 15000 * 100) + '%') + it('should show the relative voting power as a bar', () => { + expect(wrapper.vm.$el.querySelector('.voting_power .bar').style.width).toBe('100%') }) it('should add to cart', () => { diff --git a/test/unit/specs/__snapshots__/LiDelegate.spec.js.snap b/test/unit/specs/__snapshots__/LiDelegate.spec.js.snap index c7d78d990b..4e2ae58fbd 100644 --- a/test/unit/specs/__snapshots__/LiDelegate.spec.js.snap +++ b/test/unit/specs/__snapshots__/LiDelegate.spec.js.snap @@ -37,7 +37,7 @@ exports[`LiDelegate has the expected html structure 1`] = ` class="li-delegate__value delegated" > - 0% + 25%