From 9296d6860d86c68fc8f0daa1a9c3443a95ec457e Mon Sep 17 00:00:00 2001 From: Alexandre Magaud Date: Thu, 9 Jun 2022 10:23:42 +0200 Subject: [PATCH] refactor(llc): SeedPhraseType in types/manager --- libs/ledger-live-common/src/hw/extractOnboardingState.ts | 8 ++------ .../src/hw/getOnboardingStatePolling.test.ts | 3 +-- .../onboarding/hooks/useOnboardingStatePolling.test.ts | 5 ++--- libs/ledger-live-common/src/types/manager.ts | 5 +++++ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libs/ledger-live-common/src/hw/extractOnboardingState.ts b/libs/ledger-live-common/src/hw/extractOnboardingState.ts index d9ffc6fc06a2..44d90385cda5 100644 --- a/libs/ledger-live-common/src/hw/extractOnboardingState.ts +++ b/libs/ledger-live-common/src/hw/extractOnboardingState.ts @@ -1,4 +1,6 @@ import { DeviceExtractOnboardingStateError } from "@ledgerhq/errors"; +import { SeedPhraseType } from "../types/manager"; + const onboardingFlagsBytesLength = 4; const onboardedMask = 0x04; @@ -7,12 +9,6 @@ const seedPhraseTypeMask = 0x60; const seedPhraseTypeFlagOffset = 5; const currentSeedWordIndexMask = 0x1f; -export enum SeedPhraseType { - Twelve = "12-words", - Eighteen = "18-words", - TwentyFour = "24-words", -} - const fromBitsToSeedPhraseType = new Map([ [0, SeedPhraseType.TwentyFour], [1, SeedPhraseType.Eighteen], diff --git a/libs/ledger-live-common/src/hw/getOnboardingStatePolling.test.ts b/libs/ledger-live-common/src/hw/getOnboardingStatePolling.test.ts index 5c9d8cb7815a..b7aac327f46a 100644 --- a/libs/ledger-live-common/src/hw/getOnboardingStatePolling.test.ts +++ b/libs/ledger-live-common/src/hw/getOnboardingStatePolling.test.ts @@ -4,7 +4,6 @@ import * as rxjsOperators from "rxjs/operators"; import { DeviceModelId } from "@ledgerhq/devices"; import Transport from "@ledgerhq/hw-transport"; import { - DeviceOnboardingStatePollingError, DeviceExtractOnboardingStateError, DisconnectedDevice, } from "@ledgerhq/errors"; @@ -13,9 +12,9 @@ import getVersion from "./getVersion"; import { extractOnboardingState, OnboardingState, - SeedPhraseType, OnboardingStep, } from "./extractOnboardingState"; +import { SeedPhraseType } from "../types/manager"; jest.mock("./deviceAccess"); jest.mock("./getVersion"); diff --git a/libs/ledger-live-common/src/onboarding/hooks/useOnboardingStatePolling.test.ts b/libs/ledger-live-common/src/onboarding/hooks/useOnboardingStatePolling.test.ts index d02f7f7f2339..ebb3063c437a 100644 --- a/libs/ledger-live-common/src/onboarding/hooks/useOnboardingStatePolling.test.ts +++ b/libs/ledger-live-common/src/onboarding/hooks/useOnboardingStatePolling.test.ts @@ -2,14 +2,13 @@ import { timer, of } from "rxjs"; import { map, delayWhen } from "rxjs/operators"; import { renderHook, act } from "@testing-library/react-hooks"; import { DeviceModelId } from "@ledgerhq/devices"; +import { DisconnectedDevice } from "@ledgerhq/errors"; import { useOnboardingStatePolling } from "./useOnboardingStatePolling"; import { - extractOnboardingState, OnboardingState, - SeedPhraseType, OnboardingStep, } from "../../hw/extractOnboardingState"; -import { DisconnectedDevice } from "@ledgerhq/errors"; +import { SeedPhraseType } from "../../types/manager"; import { getOnboardingStatePolling } from "../../hw/getOnboardingStatePolling"; jest.mock("../../hw/getOnboardingStatePolling"); diff --git a/libs/ledger-live-common/src/types/manager.ts b/libs/ledger-live-common/src/types/manager.ts index 68f8f1f332c8..36edb237a255 100644 --- a/libs/ledger-live-common/src/types/manager.ts +++ b/libs/ledger-live-common/src/types/manager.ts @@ -68,6 +68,11 @@ export type McuVersion = { date_creation: string; date_last_modified: string; }; +export enum SeedPhraseType { + Twelve = "12-words", + Eighteen = "18-words", + TwentyFour = "24-words", +} export type FirmwareInfo = { isBootloader: boolean; rawVersion: string; // if SE seVersion, if BL blVersion