select the default address

This commit is contained in:
liangping 2022-03-31 23:39:47 +08:00
parent d5c0f26666
commit ae9bf25abf

View File

@ -222,7 +222,6 @@ export default {
return { return {
modalTitle: '', modalTitle: '',
historyName: '', historyName: '',
selectedAddress: this.address,
selectedValidator: null, selectedValidator: null,
selectedChain: null, selectedChain: null,
token: '', token: '',
@ -238,7 +237,7 @@ export default {
wallet: 'ledgerUSB', wallet: 'ledgerUSB',
gas: '200000', gas: '200000',
memo: '', memo: '',
blockingMsg: 'No available account found.', blockingMsg: this.address ? 'You are not the owner' : 'No available account found.',
actionName: 'Send', actionName: 'Send',
required, required,
@ -259,22 +258,27 @@ export default {
if (!this.balance) return [] if (!this.balance) return []
return this.balance.filter(item => !item.denom.startsWith('ibc')) return this.balance.filter(item => !item.denom.startsWith('ibc'))
}, },
isOwner() { accounts() {
const accounts = getLocalAccounts() const accounts = getLocalAccounts()
const selectedWallet = this.$store.state.chains.defaultWallet const selectedWallet = this.$store.state.chains.defaultWallet
if (!this.address) { return accounts[selectedWallet]
const chain = this.$store.state.chains.selected.chain_name },
// eslint-disable-next-line vue/no-side-effects-in-computed-properties isOwner() {
this.selectedAddress = accounts[selectedWallet].address.find(x => x.chain === chain) if (this.accounts) {
} if (this.accounts.address.findIndex(x => x.addr === this.selectedAddress) > -1) {
if (accounts && accounts[selectedWallet]) {
if (accounts[selectedWallet].address.findIndex(x => x.addr === this.selectedAddress) > -1) {
return false return false
} }
} }
return true 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: { methods: {
initialize() { initialize() {