diff --git a/store/onboard.ts b/store/onboard.ts index 99dc3eb4..389dfc72 100644 --- a/store/onboard.ts +++ b/store/onboard.ts @@ -50,6 +50,12 @@ export const useOnboardStore = defineStore("onboard", () => { ); web3modal.setDefaultChain(selectedEthereumNetwork.value); ethereumClient.watchAccount(async (updatedAccount) => { + // There is a bug in @wagmi/core@0.10.11 or @web3modal/ethereum@^2.3.7 + // On page update or after using `ethereumClient.disconnect` method + // the account state is replaced with "connecting" state + if (updatedAccount.status === "connecting" && !updatedAccount.connector) { + return; + } account.value = updatedAccount; connectorName.value = wagmiClient.connector?.name; walletName.value = getWalletName(); @@ -63,14 +69,7 @@ export const useOnboardStore = defineStore("onboard", () => { const openModal = () => web3modal.openModal(); const disconnect = () => { - ethereumClient.disconnect().then(() => { - // There is a bug in @wagmi/core@0.10.11 or @web3modal/ethereum@^2.3.7 - // After using `ethereumClient.disconnect` method the account state - // is replaced with "connecting" state - setTimeout(() => { - wagmiClient.clearState(); - }, 0); - }); + ethereumClient.disconnect(); }; const isCorrectNetworkSet = computed(() => {