From a29d9608b5f8afd596134ae5633673510e737585 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 29 Nov 2022 09:33:41 +0800 Subject: [PATCH] add tx event lisenter to update data --- src/views/Dashboard.vue | 66 +++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 97e2399d..72f1bb43 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -333,6 +333,7 @@ + + + + Redelegate + + + Unbond + + + + Widthdraw Rewards + - - - - Widthdraw Rewards - - @@ -459,6 +483,7 @@ :proposal-id="selectedProposalId" :proposal-title="selectedTitle" /> +
@@ -466,6 +491,7 @@ import { BRow, BCol, BAlert, BCard, BTable, BFormCheckbox, BCardHeader, BCardTitle, BMedia, BMediaAside, BMediaBody, BAvatar, BCardBody, BLink, BButtonGroup, BButton, BTooltip, VBModal, VBTooltip, BCardFooter, BProgress, BProgressBar, BBadge, + BDropdown, BDropdownItem, } from 'bootstrap-vue' import { formatNumber, formatTokenAmount, isToken, percent, timeIn, toDay, toDuration, tokenFormatter, getLocalAccounts, @@ -487,6 +513,8 @@ export default { BButtonGroup, BTooltip, BButton, + BDropdown, + BDropdownItem, BRow, BCol, BAlert, @@ -646,6 +674,22 @@ export default { }) } }, + mounted() { + const elem = document.getElementById('txevent') + elem.addEventListener('txcompleted', () => { + const key = this.$store?.state?.chains?.defaultWallet + if (key) { + const accounts = getLocalAccounts() || {} + const account = Object.entries(accounts) + .map(v => ({ wallet: v[0], address: v[1].address.find(x => x.chain === this.$store.state.chains.selected.chain_name) })) + .filter(v => v.address) + .find(x => x.wallet === key) + if (account) { + this.fetchAccount(account.address.addr) + } + } + }) + }, methods: { caculateTallyResult(tally) { if (this.tallyParam && tally && this.totalPower > 0) { @@ -699,8 +743,6 @@ export default { return '-' }, fetchAccount(address) { - const conf = this.$http.getSelectedConfig() - const decimal = conf.assets[0].exponent || '6' this.address = address this.$http.getBankAccountBalance(address).then(bal => { this.walletBalances = this.formatToken(bal)