Skip to content

Commit

Permalink
Merge pull request #175 from vu3th/fix/disconnect-when-no-account-in-…
Browse files Browse the repository at this point in the history
…accounts

fix(core): disconnect when onAccountsChanged emits empty accounts
  • Loading branch information
johnson86tw authored Apr 30, 2024
2 parents d448091 + 123dcba commit ecde823
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const hideConnectingModal = computed(() => {

<NuxtPage />

<VueDappModal :hideConnectingModal="hideConnectingModal"> </VueDappModal>
<VueDappModal auto-connect :hideConnectingModal="hideConnectingModal"> </VueDappModal>
</NuxtLayout>
</n-config-provider>
</template>
2 changes: 0 additions & 2 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ onMounted(() => {
})
onWalletUpdated((wallet: ConnWallet) => {
console.log('wallet', wallet)
fetchENSName(wallet.address)
fetchBalance(wallet)
})
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/services/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export function useConnect(pinia?: any) {

walletStore.wallet.connector.onAccountsChanged(async (accounts: string[]) => {
walletStore.onAccountsChangedCallback && walletStore.onAccountsChangedCallback(accounts)

if (!accounts.length) {
disconnect()
return
}

walletStore.wallet.address = accounts[0]
})

Expand Down

0 comments on commit ecde823

Please sign in to comment.