From 4bf9d211820b80fe6cb359ec162c584e77e1eb4d Mon Sep 17 00:00:00 2001 From: Tarek Awwad Date: Thu, 19 Nov 2020 18:16:13 +0100 Subject: [PATCH 01/23] Added "withdraw all" for pending rewards --- app/src/components/withdraw/total.card.vue | 80 +++++++ app/src/views/wallet/delegation/index.vue | 2 +- app/src/views/wallet/withdraw/index.vue | 41 +++- .../withdraw/modals/withdraw-all.modal.vue | 214 ++++++++++++++++++ .../wallet/withdraw/modals/withdraw.modal.vue | 4 +- 5 files changed, 331 insertions(+), 10 deletions(-) create mode 100644 app/src/components/withdraw/total.card.vue create mode 100644 app/src/views/wallet/withdraw/modals/withdraw-all.modal.vue diff --git a/app/src/components/withdraw/total.card.vue b/app/src/components/withdraw/total.card.vue new file mode 100644 index 0000000..a323eeb --- /dev/null +++ b/app/src/components/withdraw/total.card.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/app/src/views/wallet/delegation/index.vue b/app/src/views/wallet/delegation/index.vue index e3ea4a5..98ca5bf 100644 --- a/app/src/views/wallet/delegation/index.vue +++ b/app/src/views/wallet/delegation/index.vue @@ -167,7 +167,7 @@ export default { text: '', my_v_list: [], currentPage: 1, - perPage: 10, + perPage: 9, buttons: [ { caption: 'My', diff --git a/app/src/views/wallet/withdraw/index.vue b/app/src/views/wallet/withdraw/index.vue index 38d536f..79ab7a9 100644 --- a/app/src/views/wallet/withdraw/index.vue +++ b/app/src/views/wallet/withdraw/index.vue @@ -57,6 +57,18 @@ Withdraw + + + Withdraw all + +
+ @@ -100,33 +117,36 @@ import { mapActions, mapState } from 'vuex'; import { BRow, BCol, - BButton, - BButtonGroup, BPagination, BFormInput, } from 'bootstrap-vue'; import { FETCH_WALLET_VALIDATORS, FETCH_WALLET_REWARDS } from '@store/wallets'; import ValidatorCard from '@cmp/validator/validator.card'; +import TotalCard from '@cmp/withdraw/total.card'; import WithdrawModal from './modals/withdraw.modal'; +import WithdrawAllModal from './modals/withdraw-all.modal'; +import * as numeral from 'numeral'; +import { tokenUtil } from '@static/js/token'; export default { components: { + TotalCard, ValidatorCard, BPagination, BFormInput, WithdrawModal, + WithdrawAllModal, }, data() { return { selectedValidator: null, text: '', currentPage: 1, - perPage: 10, + perPage: 8, }; }, computed: { ...mapState({ - advanced: state => state.app.advanced, myValidators: state => state.wallets.current.validators, rewards: state => state.wallets.current.rewards, account: state => state.account, @@ -140,8 +160,16 @@ export default { }); return val }, - }, - created() { + + mergedRewards(){ + var pending = 0; + + for (var val in this.rewards){ + pending += numeral(this.rewards[val]).value() * Math.pow(10, 6) + } + return tokenUtil.format(pending) + } + }, mounted() { this.fetchRewards(); @@ -159,6 +187,7 @@ export default { await this.fetchMyValidators(); await this.fetchRewards(); this.$bvModal.hide('withdraw-modal'); + this.$bvModal.hide('withdraw-all-modal'); }, }, }; diff --git a/app/src/views/wallet/withdraw/modals/withdraw-all.modal.vue b/app/src/views/wallet/withdraw/modals/withdraw-all.modal.vue new file mode 100644 index 0000000..1d84e36 --- /dev/null +++ b/app/src/views/wallet/withdraw/modals/withdraw-all.modal.vue @@ -0,0 +1,214 @@ +