From ae9bf25abf2a9abd73a77b67d0c9672eb82c66ec Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 31 Mar 2022 23:39:47 +0800 Subject: [PATCH] select the default address --- src/views/components/OperationModal/index.vue | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/views/components/OperationModal/index.vue b/src/views/components/OperationModal/index.vue index ef276136..af0b1af0 100644 --- a/src/views/components/OperationModal/index.vue +++ b/src/views/components/OperationModal/index.vue @@ -222,7 +222,6 @@ export default { return { modalTitle: '', historyName: '', - selectedAddress: this.address, selectedValidator: null, selectedChain: null, token: '', @@ -238,7 +237,7 @@ export default { wallet: 'ledgerUSB', gas: '200000', memo: '', - blockingMsg: 'No available account found.', + blockingMsg: this.address ? 'You are not the owner' : 'No available account found.', actionName: 'Send', required, @@ -259,22 +258,27 @@ export default { if (!this.balance) return [] return this.balance.filter(item => !item.denom.startsWith('ibc')) }, - isOwner() { + accounts() { const accounts = getLocalAccounts() const selectedWallet = this.$store.state.chains.defaultWallet - if (!this.address) { - const chain = this.$store.state.chains.selected.chain_name - // eslint-disable-next-line vue/no-side-effects-in-computed-properties - this.selectedAddress = accounts[selectedWallet].address.find(x => x.chain === chain) - } - - if (accounts && accounts[selectedWallet]) { - if (accounts[selectedWallet].address.findIndex(x => x.addr === this.selectedAddress) > -1) { + return accounts[selectedWallet] + }, + isOwner() { + if (this.accounts) { + if (this.accounts.address.findIndex(x => x.addr === this.selectedAddress) > -1) { return false } } return true }, + selectedAddress() { + if (this.address) { + return this.address + } + const chain = this.$store.state.chains.selected.chain_name + const selectedAddress = this.accounts.address.find(x => x.chain === chain) + return selectedAddress?.addr + }, }, methods: { initialize() {