Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
LIVE-1469 Handle onboarded devices in device actions
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-cortes committed Feb 24, 2022
1 parent d8de802 commit 673d94a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LowerThanMinimumRelayFee = createCustomErrorClass(
export const TransactionRefusedOnDevice = createCustomErrorClass(
"TransactionRefusedOnDevice"
);
export const DeviceNotOnboarded = createCustomErrorClass("DeviceNotOnboarded");
export const InvalidAddressBecauseAlreadyDelegated = createCustomErrorClass(
"InvalidAddressBecauseAlreadyDelegated"
);
Expand Down
17 changes: 15 additions & 2 deletions src/hw/getAppAndVersion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { GetAppAndVersionUnsupportedFormat } from "../errors";
import { TransportStatusError } from "@ledgerhq/errors";
import {
GetAppAndVersionUnsupportedFormat,
DeviceNotOnboarded,
} from "../errors";
import Transport from "@ledgerhq/hw-transport";
export default async (
transport: Transport
Expand All @@ -7,7 +11,16 @@ export default async (
version: string;
flags: number | Buffer;
}> => {
const r = await transport.send(0xb0, 0x01, 0x00, 0x00);
const r = await transport.send(0xb0, 0x01, 0x00, 0x00).catch((e) => {
if (e instanceof TransportStatusError) {
// @ts-expect-error typescript not checking agains the instanceof
if (e.statusCode === 0x6d06) {
throw new DeviceNotOnboarded();
}
}

throw e;
});
let i = 0;
const format = r[i++];

Expand Down

1 comment on commit 673d94a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.
To be able to merge in develop branch, you need to:

  • pass the CI
  • have a dev review
  • have a QA review

Please sign in to comment.