Skip to content

Commit 3322acf

Browse files
authored
feat: add camera permission error (#485)
<!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? Are there any issues or other links reviewers should consult to understand this pull request better? For instance: * Fixes #12345 * See: #67890 --> This PR adds a new camera permission error code. ## Examples <!-- Are there any examples of this change being used in another repository? When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: adds a new error enum value and a corresponding mobile mapping plus tests/changelog, without altering existing mapping behavior. > > **Overview** > Adds a new `ErrorCode.PermissionCameraDenied` (value `7301`) to represent mobile camera permission failures. > > Extends `MOBILE_ERROR_MAPPINGS` with `CAMERA_PERMISSION_DENIED`, including severity/category and a user-facing message for QR scanning, and adds a unit test to assert the new mapping. Updates the `CHANGELOG` to document the addition. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 11200d0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 62aece4 commit 3322acf

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

packages/hw-wallet-sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `PermissionCameraDenied` error code and `CAMERA_PERMISSION_DENIED` mapping for mobile camera permission handling
13+
1014
## [0.6.0]
1115

1216
### Added

packages/hw-wallet-sdk/src/hardware-error-mappings.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ describe('HARDWARE_ERROR_MAPPINGS', () => {
228228
expect(mapping.category).toBe(Category.DeviceState);
229229
});
230230

231+
it('maps CAMERA_PERMISSION_DENIED correctly', () => {
232+
const mapping = errorMappings.CAMERA_PERMISSION_DENIED;
233+
expect(mapping.code).toBe(ErrorCode.PermissionCameraDenied);
234+
expect(mapping.severity).toBe(Severity.Err);
235+
expect(mapping.category).toBe(Category.Configuration);
236+
expect(mapping.userMessage).toContain('Camera');
237+
});
238+
231239
it('has valid structure for all mappings', () => {
232240
Object.values(errorMappings).forEach((mapping) => {
233241
expect(mapping).toHaveProperty('code');

packages/hw-wallet-sdk/src/hardware-error-mappings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ export const BLE_ERROR_MAPPINGS = {
212212
};
213213

214214
export const MOBILE_ERROR_MAPPINGS = {
215+
CAMERA_PERMISSION_DENIED: {
216+
code: ErrorCode.PermissionCameraDenied,
217+
message: 'Camera permission denied',
218+
severity: Severity.Err,
219+
category: Category.Configuration,
220+
userMessage:
221+
'Camera permission is required to scan QR codes. Please enable it in your device settings.',
222+
},
215223
NOT_SUPPORTED: {
216224
code: ErrorCode.MobileNotSupported,
217225
message: 'Operation not supported on mobile',

packages/hw-wallet-sdk/src/hardware-errors-enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export enum ErrorCode {
5757
BluetoothScanFailed = 7101,
5858
BluetoothConnectionFailed = 7102,
5959
MobileNotSupported = 7300,
60+
PermissionCameraDenied = 7301,
6061

6162
// Transaction
6263
TxInsufficientFunds = 10000,

0 commit comments

Comments
 (0)