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 047a9a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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
12 changes: 11 additions & 1 deletion src/hw/getDeviceInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import getAppAndVersion from "./getAppAndVersion";
import type { DeviceInfo } from "../types/manager";
import { PROVIDERS } from "../manager/provider";
import { isDashboardName } from "./isDashboardName";
import { DeviceNotOnboarded } from "../errors";
const ManagerAllowedFlag = 0x08;
const PinValidatedFlag = 0x80;
export default async function getDeviceInfo(
Expand Down Expand Up @@ -37,7 +38,16 @@ export default async function getDeviceInfo(
throw new DeviceOnDashboardExpected();
}

const res = await getVersion(transport);
const res = await getVersion(transport).catch((e) => {
if (e instanceof TransportStatusError) {
// @ts-expect-error typescript not checking agains the instanceof
if (e.statusCode === 0x6d06) {
throw new DeviceNotOnboarded();
}
}
throw e;
});

const {
isBootloader,
rawVersion,
Expand Down

0 comments on commit 047a9a0

Please sign in to comment.