Skip to content

Commit

Permalink
Merge pull request #2998 from luniehq/fabo/remove-signing-info-calls
Browse files Browse the repository at this point in the history
Fabo/remove signing info calls
  • Loading branch information
faboweb authored Sep 30, 2019
2 parents ba8651c + 39ae9ee commit 7f7d0a1
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 135 deletions.
1 change: 1 addition & 0 deletions changes/fabo_remove-signing-info-calls
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Fixed] We don't need to call these infos anymore as we have the info from the backend @faboweb
1 change: 0 additions & 1 deletion src/ActionModal/components/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,4 @@ export default {
#edit-memo-btn {
margin-top: 2.4rem;
}
</style>
2 changes: 1 addition & 1 deletion src/components/common/Bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
},
show: Boolean
},
data: function () {
data: function() {
return {
showMessage: this.show
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/MaintenanceBar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div>
<div v-for="message in maintenance" :key="message.id">
<Bar :bar-type="message.type" :show="message.show">{{ message.message }}</Bar>
<Bar :bar-type="message.type" :show="message.show">{{
message.message
}}</Bar>
</div>
</div>
</template>
Expand Down
6 changes: 1 addition & 5 deletions src/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@
</li>
<li>
<h4>Validator Since</h4>
<span>
Block #{{
validator.signing_info ? validator.signing_info.start_height : 0
}}
</span>
<span> Block #{{ validator.start_height }} </span>
</li>
<li>
<h4>Uptime</h4>
Expand Down
3 changes: 2 additions & 1 deletion src/gql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import gql from "graphql-tag"
export const schemaMap = {
cosmoshub: "",
[`gaia-testnet`]: "gaia_testnet_",
testnet: ""
testnet: "gaia_testnet_"
}

const ValidatorFragment = `
Expand Down Expand Up @@ -36,6 +36,7 @@ const ValidatorFragment = `
userName
voting_power
website
start_height
`

export const AllValidators = schema => gql`
Expand Down
43 changes: 1 addition & 42 deletions src/vuex/modules/delegates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BN from "bignumber.js"
import b32 from "scripts/b32"
import Vue from "vue"
import { throttle } from "scripts/blocks-throttle"

export default ({ node }) => {
const emptyState = {
Expand All @@ -13,7 +12,6 @@ export default ({ node }) => {
selfBond: {}
}
const state = JSON.parse(JSON.stringify(emptyState))
const delegatesThrottle = throttle("delegates")(10)

const mutations = {
setDelegateLoading(state, loading) {
Expand All @@ -39,9 +37,6 @@ export default ({ node }) => {
}
) {
Vue.set(state.selfBond, operator_address, ratio)
},
setSigningInfos(state, signingInfos) {
state.signingInfos = signingInfos
}
}

Expand All @@ -51,42 +46,7 @@ export default ({ node }) => {
dispatch(`getDelegates`)
}
},
async updateSigningInfo(
{
commit,
getters: { lastHeader }
},
validators
) {
await delegatesThrottle(state, Number(lastHeader.height), async () => {
const signingInfos = await Promise.all(
validators.map(async validator => {
if (validator.consensus_pubkey) {
const signing_info = await node.get.validatorSigningInfo(
validator.consensus_pubkey
)
return {
operator_address: validator.operator_address,
signing_info
}
}
})
)
commit(
`setSigningInfos`,
signingInfos
.filter(x => !!x)
.reduce(
(signingInfos, { operator_address, signing_info }) => ({
...signingInfos,
[operator_address]: signing_info
}),
{}
)
)
})
},
async getDelegates({ state, commit, dispatch, rootState }) {
async getDelegates({ state, commit, rootState }) {
commit(`setDelegateLoading`, true)

if (!rootState.connection.connected) return
Expand All @@ -99,7 +59,6 @@ export default ({ node }) => {

commit(`setDelegates`, validators)
commit(`setDelegateLoading`, false)
dispatch(`updateSigningInfo`, validators)

return validators
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe(`DelegationModal`, () => {
const state = {
session: {
signedIn: true,
address: `cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw`,
address: `cosmosvaladdr15ky9du8a2wlstz6fpx3p4mqpjyrm5ctqzh8yqw`
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ exports[`PageValidator shows a validator profile information errors signing info
</h4>
<span>
Block #0
Block #15
</span>
</li>
Expand Down Expand Up @@ -422,9 +420,7 @@ exports[`PageValidator shows a validator profile information if user has signed
</h4>
<span>
Block #0
Block #15
</span>
</li>
Expand Down Expand Up @@ -672,9 +668,7 @@ exports[`PageValidator shows a validator profile information if user hasn't sign
</h4>
<span>
Block #0
Block #15
</span>
</li>
Expand Down Expand Up @@ -924,9 +918,7 @@ exports[`PageValidator shows a validator profile information shows empty website
</h4>
<span>
Block #0
Block #15
</span>
</li>
Expand Down Expand Up @@ -1174,9 +1166,7 @@ exports[`PageValidator shows a validator profile information shows http website
</h4>
<span>
Block #0
Block #15
</span>
</li>
Expand Down
63 changes: 0 additions & 63 deletions tests/unit/specs/store/delegates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@ describe(`Module: Delegates`, () => {
])
})

it(`sets the signing infos`, () => {
const { mutations, state } = instance
mutations.setSigningInfos(state, {
operatorX: {
signingInfoY: 1
}
})
expect(state.signingInfos).toEqual({
operatorX: {
signingInfoY: 1
}
})
})

it(`fetches all candidates`, async () => {
node.get.validators = () => []
const { actions, state } = instance
Expand Down Expand Up @@ -119,55 +105,6 @@ describe(`Module: Delegates`, () => {
])
})

it(`should query further info for validators`, async () => {
node.get.validators = () => []
const { actions, state } = instance
const commit = jest.fn()
const dispatch = jest.fn()
const candidates = await actions.getDelegates({
state,
commit,
dispatch,
rootState: mockRootState
})
expect(dispatch.mock.calls).toEqual([[`updateSigningInfo`, candidates]])
})

it(`fetches the signing information from all delegates`, async () => {
node.get.validators = () => []
node.get.validatorSigningInfo = () => ({
index_offset: 1,
jailed_until: "1970-01-01T00:00:42.000Z",
missed_blocks_counter: 1,
start_height: 2
})
const { actions, mutations, state } = instance
const commit = jest.fn()
mutations.setDelegates(state, [
{
operator_address: `foo`,
consensus_pubkey: `bar`,
tokens: `10`
}
])
expect(state.delegates).not.toContainEqual(
expect.objectContaining({ signing_info: expect.anything() })
)
await actions.updateSigningInfo(
{ state, commit, getters: { lastHeader: { height: `43` } } },
state.delegates
)

expect(commit).toHaveBeenCalledWith(`setSigningInfos`, {
foo: {
index_offset: 1,
jailed_until: `1970-01-01T00:00:42.000Z`,
missed_blocks_counter: 1,
start_height: 2
}
})
})

it(`should query for delegates on reconnection if was loading before`, async () => {
const { actions } = delegatesModule({})
const instance = {
Expand Down
15 changes: 10 additions & 5 deletions tests/unit/specs/store/json/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default [
uptime_percentage: "0.9962",
userName: "mr_mounty",
voting_power: "0.0014",
website: "www.monty.ca"
website: "www.monty.ca",
start_height: 10
},
{
avatarUrl: "https://s3.amazonaws.com/img/path.jpg",
Expand All @@ -51,7 +52,8 @@ export default [
uptime_percentage: "0.9962",
userName: "mr_mounty",
voting_power: 0.014,
website: "www.greg.com"
website: "www.greg.com",
start_height: 15
},
{
avatarUrl: "https://s3.amazonaws.com/img/path.jpg",
Expand All @@ -78,7 +80,8 @@ export default [
uptime_percentage: "0.9962",
userName: "mr_mounty",
voting_power: 0.014,
website: "www.schmidt.de"
website: "www.schmidt.de",
start_height: 12
},
{
avatarUrl: "https://s3.amazonaws.com/img/path.jpg",
Expand All @@ -105,7 +108,8 @@ export default [
uptime_percentage: "0.9962",
userName: "mr_mounty jailed",
voting_power: 0.014,
website: "www.schmidt.de"
website: "www.schmidt.de",
start_height: 100
},
{
avatarUrl: "https://s3.amazonaws.com/img/path.jpg",
Expand All @@ -132,6 +136,7 @@ export default [
uptime_percentage: "0.9962",
userName: "mr_mounty inactive",
voting_power: 0.014,
website: "www.schmidt.de"
website: "www.schmidt.de",
start_height: 1000
}
]

0 comments on commit 7f7d0a1

Please sign in to comment.