Skip to content

Commit f581837

Browse files
fix: Consider client active once it is open and unlocked (#37607)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** We recently changed it so `onActive` fires once the client has been unlocked. This PR adjusts the hook that provides the `active` flag to the same behavior. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37607?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates client activity to require both UI open and wallet unlocked, and adjusts Snap client-status E2E test expectations. > > - **Snaps / Controller**: > - Update `getIsActive` in `app/scripts/metamask-controller.js` to return `this._isClientOpen && isUnlocked` (was only `this._isClientOpen`). > - **Tests**: > - Adjust `test/e2e/snaps/test-snap-clientstatus.spec.ts` to expect `active: false` when `locked: true`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 29c0bf4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent f638960 commit f581837

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/scripts/metamask-controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7151,7 +7151,11 @@ export default class MetamaskController extends EventEmitter {
71517151
return !isUnlocked;
71527152
},
71537153
getIsActive: () => {
7154-
return this._isClientOpen;
7154+
const { isUnlocked } = this.controllerMessenger.call(
7155+
'KeyringController:getState',
7156+
);
7157+
7158+
return this._isClientOpen && isUnlocked;
71557159
},
71567160
getInterfaceState: (...args) =>
71577161
this.controllerMessenger.call(

test/e2e/snaps/test-snap-clientstatus.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Test Snap Client Status', function () {
4545

4646
// Validate the client status is accurate
4747
await testSnaps.checkClientStatus(
48-
JSON.stringify({ locked: true, active: true }, null, 2),
48+
JSON.stringify({ locked: true, active: false }, null, 2),
4949
);
5050
},
5151
);

0 commit comments

Comments
 (0)