diff --git a/svelte/src/helpers/metamask.ts b/svelte/src/helpers/metamask.ts index fe332723..d4ed7b35 100644 --- a/svelte/src/helpers/metamask.ts +++ b/svelte/src/helpers/metamask.ts @@ -34,11 +34,15 @@ const _handleChainId = (_chainId: string): void => { }; const _handleAccounts = (accounts: Array): void => { - if (accounts?.length === 0) return; // console.log("_handleAccounts:", accounts); - metamaskSigner.set(get(metamaskProvider).getSigner(0)); - metamaskSignerAddress.set(getChecksumAddress(accounts[0])); + if (accounts.length >= 1) { + metamaskSigner.set(get(metamaskProvider).getSigner(0)); + metamaskSignerAddress.set(getChecksumAddress(accounts[0])); + } else { + metamaskSigner.set(undefined); + metamaskSignerAddress.set(undefined); + } }; const metamaskConnect = async (): Promise => { diff --git a/svelte/src/stores/metamask.ts b/svelte/src/stores/metamask.ts index 69f695c1..9b387cdb 100644 --- a/svelte/src/stores/metamask.ts +++ b/svelte/src/stores/metamask.ts @@ -4,8 +4,8 @@ import type { JsonRpcProvider, JsonRpcSigner } from "@ethersproject/providers"; // Metamask chainId and account const metamaskChainId: Writable = writable(); -const metamaskSignerAddress: Writable = writable(); const metamaskProvider: Writable = writable(); -const metamaskSigner: Writable = writable(); +const metamaskSignerAddress: Writable = writable(); +const metamaskSigner: Writable = writable(); export { metamaskChainId, metamaskSignerAddress, metamaskProvider, metamaskSigner };