Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poquito requests #2289

Merged
merged 24 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- [\#2267](https://github.com/cosmos/voyager/issues/2267) fixed sorting on validator table @jbibla
- [\#2278](https://github.com/cosmos/voyager/issues/2278) fixed commission calculation on validator table @jbibla
- [\#2289](https://github.com/cosmos/voyager/pull/2289) reduced amount of requests to full node @fedekunze
13 changes: 13 additions & 0 deletions app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default {
`connected`,
`session`,
`liquidAtoms`,
`lastHeader`,
`totalAtoms`,
`bondDenom`,
`distribution`
Expand All @@ -70,6 +71,18 @@ export default {
)
}
},
watch: {
lastHeader: {
immediate: true,
handler(newHeader) {
const waitTenBlocks = Number(newHeader.height) % 10 === 0
if (this.session.signedIn && waitTenBlocks) {
this.$store.dispatch(`getTotalRewards`)
this.$store.dispatch(`queryWalletBalances`)
}
}
}
},
methods: {
onWithdrawal() {
this.$refs.modalWithdrawAllRewards.open()
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/staking/LiValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
validator: {
type: Object,
required: true
},
}
},
data: () => ({ num }),
computed: {
Expand Down Expand Up @@ -111,7 +111,7 @@ export default {

// status: active
return `green`
},
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,26 @@ export default {
TmFormGroup
},
computed: {
...mapGetters([`bondDenom`, `distribution`]),
...mapGetters([`bondDenom`, `distribution`, `lastHeader`, `session`]),
totalRewards({ bondDenom, distribution } = this) {
const rewards = distribution.totalRewards[bondDenom]
return (rewards && atoms(rewards)) || 0
}
},
watch: {
lastHeader: {
immediate: true,
handler() {
if (
this.session.signedIn &&
this.$refs.actionModal &&
this.$refs.actionModal.show
) {
this.$store.dispatch(`getTotalRewards`)
}
}
}
},
methods: {
open() {
this.$refs.actionModal.open()
Expand Down
12 changes: 9 additions & 3 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,14 @@ export default {
},
lastHeader: {
immediate: true,
handler() {
if (this.session.signedIn) {
handler(newHeader) {
const waitTwentyBlocks = Number(newHeader.height) % 20 === 0
if (
this.session.signedIn &&
waitTwentyBlocks &&
this.$route.name === `validator` &&
Number(this.myBond) > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you load this page first and the bond has not been loaded yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run into that issue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.$route.params.validator
Expand All @@ -326,7 +332,7 @@ export default {
}
},
mounted() {
if (this.session.signedIn) {
if (this.session.signedIn && Number(this.myBond) > 0) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.$route.params.validator
Expand Down
34 changes: 30 additions & 4 deletions app/src/renderer/components/staking/TabMyDelegations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ export default {
`committedDelegations`,
`bondDenom`,
`connected`,
`session`
`session`,
`lastHeader`
]),
yourValidators({ committedDelegations, delegates: { delegates } } = this) {
return delegates.filter(
({ operator_address }) => operator_address in committedDelegations
yourValidators(
{
committedDelegations,
delegates: { delegates },
session: { signedIn }
} = this
) {
return (
signedIn &&
delegates.filter(
({ operator_address }) => operator_address in committedDelegations
)
)
},
unbondingTransactions: ({ transactions, delegation } = this) =>
Expand Down Expand Up @@ -117,6 +127,22 @@ export default {
watch: {
"session.signedIn": function() {
this.loadStakingTxs()
},
lastHeader: {
immediate: true,
handler(newHeader) {
const waitTwentyBlocks = Number(newHeader.height) % 20 === 0
if (
waitTwentyBlocks &&
this.yourValidators &&
this.yourValidators.length > 0
) {
this.$store.dispatch(
`getRewardsFromAllValidators`,
this.yourValidators
)
}
}
}
},
async mounted() {
Expand Down
41 changes: 40 additions & 1 deletion app/src/renderer/components/staking/TabValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,54 @@ export default {
TmDataConnecting
},
computed: {
...mapGetters([`delegates`, `connected`, `session`])
...mapGetters([
`lastHeader`,
`delegates`,
`committedDelegations`,
`connected`,
`session`
]),
yourValidators(
{
committedDelegations,
delegates: { delegates },
session: { signedIn }
} = this
) {
return (
signedIn &&
delegates.filter(
({ operator_address }) => operator_address in committedDelegations
)
)
}
},
watch: {
"session.signedIn": function(signedIn) {
signedIn && this.$store.dispatch(`updateDelegates`)
},
lastHeader: {
immediate: true,
handler(newHeader) {
const waitTwentyBlocks = Number(newHeader.height) % 20 === 0
if (
waitTwentyBlocks &&
this.yourValidators &&
this.yourValidators.length > 0
) {
this.$store.dispatch(
`getRewardsFromAllValidators`,
this.yourValidators
)
}
}
}
},
mounted() {
this.$store.dispatch(`updateDelegates`)
if (this.yourValidators) {
this.$store.dispatch(`getRewardsFromAllValidators`, this.yourValidators)
}
}
}
</script>
7 changes: 0 additions & 7 deletions app/src/renderer/components/staking/TableValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ export default {
watch: {
address: function() {
this.session.address && this.$store.dispatch(`updateDelegates`)
},
validators: function(validators) {
if (!validators || validators.length === 0 || !this.session.signedIn) {
return
}

this.$store.dispatch(`getRewardsFromAllValidators`, this.yourValidators)
}
},
mounted() {
Expand Down
11 changes: 1 addition & 10 deletions app/src/renderer/components/wallet/PageTransactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export default {
`session`,
`bondDenom`,
`delegation`,
`delegates`,
`lastHeader`
`delegates`
]),
orderedTransactions() {
return orderBy(
Expand All @@ -78,14 +77,6 @@ export default {
return this.orderedTransactions.length === 0
}
},
watch: {
lastHeader: {
immediate: true,
handler() {
this.refreshTransactions()
}
}
},
mounted() {
this.refreshTransactions()
},
Expand Down
10 changes: 0 additions & 10 deletions app/src/renderer/components/wallet/PageWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ export default {
)
}
},
watch: {
lastHeader: {
immediate: true,
handler() {
if (this.session.signedIn) {
this.queryWalletBalances()
}
}
}
},
async mounted() {
this.updateDelegates()
await this.queryWalletBalances()
Expand Down
6 changes: 1 addition & 5 deletions app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from "../../../config"

const NODE_HALTED_TIMEOUT = config.node_halted_timeout

export default function({ node }) {
export default function ({ node }) {
// get tendermint RPC client from basecoin client

const state = {
Expand Down Expand Up @@ -98,10 +98,6 @@ export default function({ node }) {
},
({ header }) => {
dispatch(`setLastHeader`, header)

if (rootState.session.signedIn) {
dispatch(`getTotalRewards`)
}
}
)
if (rootState.session.signedIn) {
Expand Down
8 changes: 6 additions & 2 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default ({ node }) => {
setUnbondingDelegations(state, unbondingDelegations) {
state.unbondingDelegations = unbondingDelegations
? unbondingDelegations
// building a dict from the array and taking out the validators with no undelegations
// building a dict from the array and taking out the validators with no undelegations
.reduce(
(dict, { validator_address, entries }) => ({
...dict,
Expand Down Expand Up @@ -137,7 +137,7 @@ export default ({ node }) => {
async updateDelegates({ dispatch, rootState }) {
const candidates = await dispatch(`getDelegates`)

if(rootState.session.signedIn) {
if (rootState.session.signedIn) {
dispatch(`getBondedDelegates`, candidates)
}
},
Expand Down Expand Up @@ -178,6 +178,7 @@ export default ({ node }) => {
value: state.committedDelegates[validator_address] + Number(amount)
})

await dispatch(`getAllTxs`)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
// load delegates after delegation to get new atom distribution on validators
dispatch(`updateDelegates`)
},
Expand All @@ -201,6 +202,7 @@ export default ({ node }) => {
password,
submitType
})
await dispatch(`getAllTxs`)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
},
async submitRedelegation(
{
Expand All @@ -223,6 +225,8 @@ export default ({ node }) => {
password,
submitType
})

await dispatch(`getAllTxs`)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/renderer/vuex/modules/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default ({ node }) => {
})
await dispatch(`getTotalRewards`)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
await dispatch(`queryWalletBalances`)
await dispatch(`getAllTxs`)
},
async getRewardsFromAllValidators({ state, dispatch }, validators) {
state.loading = true
Expand Down
1 change: 1 addition & 0 deletions app/src/renderer/vuex/modules/governance/deposits.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default ({ node }) => {

await dispatch(`getProposalDeposits`, proposal_id)
await dispatch(`getProposal`, proposal_id)
await dispatch(`getAllTxs`)
}
}
return {
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/vuex/modules/governance/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default ({ node }) => {
})

const latestId = Object.keys(state.proposals).reduce((latest, id) => {
return latest > Number(id) ? latest : Number(id)
return latest > Number(id) ? latest : Number(id)
}, 0)
commit(`setProposal`, {
proposal_id: String(latestId + 1),
Expand All @@ -115,6 +115,7 @@ export default ({ node }) => {
})

await dispatch(`getProposals`)
await dispatch(`getAllTxs`)
}
}
return {
Expand Down
1 change: 1 addition & 0 deletions app/src/renderer/vuex/modules/governance/votes.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default ({ node }) => {
})
await dispatch(`getProposalVotes`, proposal_id)
await dispatch(`getProposal`, proposal_id)
await dispatch(`getAllTxs`)
}
}
return {
Expand Down
1 change: 1 addition & 0 deletions app/src/renderer/vuex/modules/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export default ({ node }) => {
denom,
amount: oldBalance.amount - amount
})
await dispatch(`getAllTxs`)
},
loadDenoms({ state, commit }) {
commit(`setDenoms`, state.externals.config.denoms)
Expand Down
Loading