Skip to content

Commit

Permalink
chore: terminate on 'ACCOUNTS_CHANGED' event when accounts are zero (#…
Browse files Browse the repository at this point in the history
…909)

* chore: terminate on 'ACCOUNTS_CHANGED' event when accounts is zero

* chore: fix lint issue

* chore: update '.change' files
  • Loading branch information
omridan159 authored Jun 21, 2024
1 parent e3d10c4 commit 99e41b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-react-ui/.change
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.26.0
0.26.2
2 changes: 1 addition & 1 deletion packages/sdk-react/.change
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.26.0
0.26.2
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,22 @@ export async function setupExtensionPreferences(instance: MetaMaskSDK) {

const hasMobileProvider = Boolean(instance.sdkProvider);

const isExtensionActive = Boolean(instance.extensionActive);

if (hasMobileProvider) {
instance
.getMobileProvider()
.emit(EXTENSION_EVENTS.ACCOUNTS_CHANGED, accounts);
}

if (isExtensionActive && (accounts as string[])?.length === 0) {
instance.terminate().catch((error) => {
logger(
`[MetaMaskSDK: setupExtensionPreferences()] Error terminating`,
error,
);
});
}
},
);

Expand Down

0 comments on commit 99e41b0

Please sign in to comment.