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 all 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 @@ -6,3 +6,4 @@

- [\#2301](https://github.com/cosmos/voyager/issues/2301) throttle requests for keybase identities @faboweb
- [\#2272](https://github.com/cosmos/voyager/issues/2272) fixed showing uatoms instead of atoms @faboweb
- [\#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 @@ -53,6 +53,7 @@ export default {
`connected`,
`session`,
`liquidAtoms`,
`lastHeader`,
`totalAtoms`,
`bondDenom`,
`distribution`
Expand All @@ -67,6 +68,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
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,26 @@ export default {
num
}),
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
42 changes: 25 additions & 17 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
</template>

<script>
import BigNumber from "bignumber.js"
import moment from "moment"
import { calculateTokens } from "scripts/common"
import { mapGetters } from "vuex"
Expand Down Expand Up @@ -207,6 +206,7 @@ export default {
`lastHeader`,
`bondDenom`,
`delegates`,
`delegation`,
`distribution`,
`committedDelegations`,
`keybase`,
Expand Down Expand Up @@ -238,12 +238,11 @@ export default {
return String(uptime).substring(0, 4) + `%`
},
myBond() {
return BigNumber(
atoms(
calculateTokens(
this.validator,
this.committedDelegations[this.validator.operator_address] || 0
)
if (!this.validator) return 0
return atoms(
calculateTokens(
this.validator,
this.committedDelegations[this.validator.operator_address] || 0
)
)
},
Expand Down Expand Up @@ -307,6 +306,16 @@ export default {
}
},
watch: {
myBond: {
handler(myBond) {
if (myBond > 0) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.$route.params.validator
)
}
}
},
validator: {
immediate: true,
handler(validator) {
Expand All @@ -316,8 +325,15 @@ 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` &&
this.delegation.loaded &&
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,14 +342,6 @@ export default {
}
}
},
mounted() {
if (this.session.signedIn) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.$route.params.validator
)
}
},
methods: {
onDelegation() {
this.$refs.delegationModal.open()
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 @@ -85,11 +85,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 @@ -119,6 +129,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 @@ -62,8 +62,7 @@ export default {
`session`,
`bondDenom`,
`delegation`,
`delegates`,
`lastHeader`
`delegates`
]),
orderedTransactions() {
return orderBy(
Expand All @@ -79,14 +78,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 @@ -65,16 +65,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
Loading