fix(unlock): personal_sign method does not bring up password prompt #36975
+729
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Context
When MetaMask is locked after a DApp has been granted permissions, signature requests (such as personal_sign, eth_signTypedData_v3/v4, eth_getEncryptionPublicKey, and eth_decrypt) hang indefinitely without showing any UI prompt or returning an error to the DApp. This leaves the request Promise in a pending state forever, and users have no way to complete or cancel the request.
The root cause is that the SignatureController, DecryptMessageController, and EncryptionPublicKeyController do not check the wallet's lock state before processing requests.
Created unlock-wrapper.ts - A new utility module containing:
withUnlockPrompt(): A generic wrapper function that adds unlock checking to any async function
createUnlockedMethodWrappers(): A factory function that creates wrapped methods bound to AppStateController and KeyringController
Flow after fix:
When a DApp calls a signature method while the wallet is locked
When the wallet is already unlocked:
Changelog
CHANGELOG entry: Fixed hanging signature requests by prompting for unlock when the wallet is locked.
CHANGELOG entry:
Related issues
Fixes: #36800, #36335
Manual testing steps
Screenshots/Recordings
Before
493838303-f5a9f054-af5f-4907-b24b-3590126426c1.mov
After
Screen.Recording.2025-10-18.at.14.04.31.mp4
Pre-merge author checklist
Pre-merge reviewer checklist