Skip to content

Commit

Permalink
fix: Disconnect not being called (#447)
Browse files Browse the repository at this point in the history
* fix: Disconnect not being called

* fix: Update
  • Loading branch information
fzavalia authored Jan 12, 2024
1 parent 148e408 commit 30a1a72
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/eth/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ export async function restoreConnection(): Promise<ConnectionResponse | null> {

export async function disconnect(): Promise<void> {
try {
const requestManager = new RequestManager(await connection.getProvider())
const account = (await requestManager.eth_accounts())[0]
await connection.disconnect()
if (account) {
localStorageClearIdentity(account)
try {
const requestManager = new RequestManager(await connection.getProvider())
const account = (await requestManager.eth_accounts())[0]
if (account) {
localStorageClearIdentity(account)
}
} catch (err) {
// Ignore the error if for some reason the account could not be obtained.
}

await connection.disconnect()
window.location.reload()
} catch (err) {
defaultWebsiteErrorTracker(err)
Expand Down

0 comments on commit 30a1a72

Please sign in to comment.