fix: this.connectedWallet.cosmosAddress undefined

This commit is contained in:
Alisa | Side.one 2023-05-10 13:23:00 +08:00
parent 3b3cd95e69
commit e419bd1e34

View File

@ -11,27 +11,30 @@ export const useWalletStore = defineStore('walletStore', {
return useBlockchain(); return useBlockchain();
}, },
connectedWallet() { connectedWallet() {
const chainStore = useBlockchain() const chainStore = useBlockchain();
const key = chainStore.defaultHDPath const key = chainStore.defaultHDPath;
const connected = JSON.parse(localStorage.getItem(key)||"{}") const connected = JSON.parse(localStorage.getItem(key) || '{}');
return connected return connected;
}, },
currentAddress() { currentAddress() {
const {prefix, data} = fromBech32(this.connectedWallet.cosmosAddress); if (!this.connectedWallet?.cosmosAddress) return '';
const chainStore = useBlockchain() const { prefix, data } = fromBech32(this.connectedWallet.cosmosAddress);
return toBech32(chainStore.current?.bech32Prefix || prefix, data) const chainStore = useBlockchain();
} return toBech32(chainStore.current?.bech32Prefix || prefix, data);
},
}, },
actions: { actions: {
myBalance() { myBalance() {
return this.blockchain.rpc.getBankBalances(this.currentAddress) return this.blockchain.rpc.getBankBalances(this.currentAddress);
}, },
myDelegations() { myDelegations() {
return this.blockchain.rpc.getStakingDelegations(this.currentAddress) return this.blockchain.rpc.getStakingDelegations(this.currentAddress);
}, },
myUnbonding() { myUnbonding() {
return this.blockchain.rpc.getStakingDelegatorUnbonding(this.currentAddress) return this.blockchain.rpc.getStakingDelegatorUnbonding(
} this.currentAddress
);
},
}, },
}); });