You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- fix: hw account abstraction migration (#30114)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until this PR meets the canonical
Definition of Ready For Review in `docs/readme/ready-for-review.md`.
In short: the template must be materially complete (not just section
titles
present), all status checks must be currently passing, and the only
expected
follow-up commits must be reviewer-driven.
-->
## **Description**
This PR prevents Perps from triggering browsing-time signing flows for
hardware wallet users while the screen is idle.
Previously, Unified Account setup only deferred the `dexAbstraction`
migration when user signing was not allowed. Other signing-backed
HyperLiquid abstraction modes could still attempt setup during passive
Perps initialization, which could surface repeated hardware wallet
prompts without an explicit user action.
The fix adds a shared helper for deciding when Unified Account setup
must be deferred, applies it during HyperLiquid provider initialization,
and expands hardware wallet detection to cover MetaMask's hardware
keyring types: Ledger, Trezor, OneKey, Lattice, and QR hardware wallets.
Software wallets can still complete setup during initialization so the
first trade sees unified collateral, while hardware wallets defer setup
until an explicit trading or withdrawal action.
## **Changelog**
CHANGELOG entry: Fixed a bug that could repeatedly prompt hardware
wallet users while Perps was idle.
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Perps hardware wallet idle setup
Scenario: Hardware wallet user opens Perps and leaves it idle
Given the user has selected a Ledger, Trezor, OneKey, Lattice, or QR hardware wallet account
And Perps is enabled and available
When the user opens the Perps screen
And leaves the Perps screen idle without placing an order, withdrawing, or otherwise starting a signing action
Then the app does not repeatedly show hardware wallet signing prompts
```
```gherkin
Feature: Perps software wallet setup
Scenario: Software wallet user opens Perps
Given the user has selected a software wallet account that needs Unified Account setup
When the user opens the Perps screen
Then Perps can complete the setup flow during initialization
And the first trade can use unified collateral without an extra setup step
```
## **Screenshots/Recordings**
N/A. This is a controller behavior change with no intended UI changes.
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
<!--
Every checklist item must be consciously assessed before marking this PR
as
"Ready for review". A checked box means you deliberately considered that
responsibility, not that you literally performed every action listed.
Unchecked boxes are ambiguous: they are not an implicit "N/A" and they
are not
a silent "skip". See `docs/readme/ready-for-review.md` for the full
checklist
semantics.
-->
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
<!--
Reviewer checklist items follow the same semantics as the author
checklist: an
unchecked box is ambiguous, a checked box means the reviewer consciously
assessed that responsibility. See `docs/readme/ready-for-review.md`.
-->
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes when unified-account migration and other signing-backed setup
runs, which can affect Perps initialization and migration behavior for
hardware wallet users. Risk is moderated by added unit tests and a
narrow decision helper, but incorrect deferral could delay required
setup until action time.
>
> **Overview**
> Prevents browsing-time hardware wallet signing prompts by deferring
HyperLiquid unified-account migration during Perps initialization
whenever the current abstraction mode would require a signing-backed
transition and user signing is not allowed.
>
> Adds `shouldDeferUnifiedAccountSetup` to centralize this decision
(with new unit tests), updates `HyperLiquidProvider` to use it, and
expands `HyperLiquidWalletService.isSelectedHardwareWallet()` to
recognize additional MetaMask hardware keyring types (Ledger, Trezor,
OneKey, Lattice, QR). Also updates related tests and log/comment wording
from *QR popup spam* to *hardware wallet signing prompt spam*.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6f8cfe2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[4669b3a](4669b3a)
---------
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>
Co-authored-by: Nicholas Gambino <nicholas.gambino@consensys.net>
0 commit comments