Skip to content

Commit

Permalink
fix: fix currentWallet and currentNetwork retrieving in unsafe contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
0Lilian committed Sep 2, 2022
1 parent 3b02971 commit 7078cab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/provider/SelectNetworkDropdown.vue
Expand Up @@ -8,6 +8,10 @@ let availableNetworks = ref([])
let isDropdownOpened = ref(false);
dapp.onSafe(async function () {
availableNetworks.value = dapp.config.networks.getAvailable()
})
dapp.provider.onSafe(async function () {
currentNetwork.value = await dapp.config.networks.getCurrent()
availableNetworks.value = dapp.config.networks.getAvailable().filter(n => n.id !== currentNetwork.value.id);
})
Expand Down
8 changes: 6 additions & 2 deletions src/components/signer/SelectWalletDropdown.vue
Expand Up @@ -7,8 +7,12 @@ let availableWallets = ref([])
let isDropdownOpened = ref(false);
dapp.onSafe(async function () {
availableWallets.value = dapp.config.wallets.getAvailable()
})
dapp.signer.onSafe(async function () {
currentWallet.value = await dapp.config.wallets.getCurrent()
availableWallets.value = dapp.config.wallets.getAvailable().filter(w => w !== currentWallet.value);
availableWallets.value = dapp.config.wallets.getAvailable().filter(w => w.id !== currentWallet.value.id);
})
function toggle () {
Expand All @@ -22,7 +26,7 @@ function toggle () {
<ul @click="toggle">
<li v-if="currentWallet">
<img width="40" :src="currentWallet.icon ? currentWallet.icon : dapp.config.defaults.wallets.icon" :alt="currentWallet.displayName + ' logo'"/>
<p>cur{{ currentWallet.displayName }}</p>
<p>{{ currentWallet.displayName }}</p>
</li>
<li v-else>
<p>Select a wallet</p>
Expand Down

0 comments on commit 7078cab

Please sign in to comment.