Commit 2998fd8
authored
feat: add QR hardware wallet adapter (#28036)
<!--
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**
This pr adds a new QRWalletAdapter for QR code-based hardware wallet
support
This adapter provides a unified interface so the HardwareWalletContext
can treat QR wallets the same way as other hardware wallets like Ledger.
There is no visual change for this pr. It will be enabled in subsequent
prs.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **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
## **Related issues**
Fixes:
https://consensyssoftware.atlassian.net/browse/MUL-1507?atlOrigin=eyJpIjoiNDYyMTkzYzkzMDM4NDcwMmEyNTViMzc0NWFmM2EzZWIiLCJwIjoiaiJ9
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
It is not wired because there are 2 follow on prs.
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [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.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] 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**
> Adds a new hardware wallet adapter with camera-permission handling and
changes transport-monitoring behavior to support adapters that opt out,
plus upgrades `@metamask/hw-wallet-sdk`; issues would primarily surface
as connection/permission flow regressions.
>
> **Overview**
> Adds a new `QRWalletAdapter` implementing the hardware-wallet adapter
interface for QR-based wallets, modeling “connection” as storing a QR
device/account id and gating readiness on camera permission (emitting
`DeviceEvent.ConnectionFailed` with `CameraPermissionDenied` when
denied).
>
> Updates transport monitoring to **skip preflight/error UI** for
adapters that return `null` from `getTransportDisabledErrorCode()` (used
by QR to opt out of persistent transport checks), and extends error-name
mappings with QR-related error names.
>
> Updates test infrastructure by enhancing the
`react-native-vision-camera` mock with static permission methods, and
adds unit tests for the new adapter and the transport-monitoring opt-out
behavior. Also bumps `@metamask/hw-wallet-sdk` from `^0.4.0` to
`^0.7.0`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
faee546. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 31512e8 commit 2998fd8
File tree
9 files changed
+877
-8
lines changed- app
- __mocks__
- core/HardwareWallet
- adapters
- errors
- hooks
9 files changed
+877
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
0 commit comments