From 5ce7fe72a98d2c939ac1340232aca989cd8d8297 Mon Sep 17 00:00:00 2001 From: jz_ Date: Fri, 12 Jul 2024 16:21:39 +0200 Subject: [PATCH 1/2] fix(lld): onboarding error when device connected --- .changeset/selfish-experts-double.md | 5 +++++ .../SyncOnboarding/DeviceConnection/Searching.tsx | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/selfish-experts-double.md diff --git a/.changeset/selfish-experts-double.md b/.changeset/selfish-experts-double.md new file mode 100644 index 000000000000..73a82a62c3ee --- /dev/null +++ b/.changeset/selfish-experts-double.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": patch +--- + +Fix onboarding error when device connected. diff --git a/apps/ledger-live-desktop/src/renderer/components/SyncOnboarding/DeviceConnection/Searching.tsx b/apps/ledger-live-desktop/src/renderer/components/SyncOnboarding/DeviceConnection/Searching.tsx index 24b6fbb2eb76..b27a42cbde6c 100644 --- a/apps/ledger-live-desktop/src/renderer/components/SyncOnboarding/DeviceConnection/Searching.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/SyncOnboarding/DeviceConnection/Searching.tsx @@ -10,6 +10,7 @@ import Animation from "~/renderer/animations"; import useTheme from "~/renderer/hooks/useTheme"; import { useSelector } from "react-redux"; import { getCurrentDevice } from "~/renderer/reducers/devices"; +import { isSyncOnboardingSupported } from "@ledgerhq/live-common/device/use-cases/isSyncOnboardingSupported"; export type SyncOnboardingDeviceConnectionSearchingProps = { deviceModelId: DeviceModelId; @@ -26,7 +27,11 @@ const SyncOnboardingDeviceConnectionSearching = ({ const currentDevice = useSelector(getCurrentDevice); useEffect(() => { - if (currentDevice && currentDevice.modelId !== deviceModelId) { + if ( + currentDevice && + currentDevice.modelId !== deviceModelId && + !isSyncOnboardingSupported(deviceModelId) + ) { setDeviceModelId(currentDevice.modelId); history.replace("/onboarding/select-use-case"); } From 8dd0fb195525eef4600a8ecbca2a80a1899de321 Mon Sep 17 00:00:00 2001 From: jz_ Date: Mon, 15 Jul 2024 14:57:11 +0200 Subject: [PATCH 2/2] fix(llm): fix device setup flow error --- .changeset/tricky-steaks-hope.md | 5 +++++ .../renderer/components/DeviceAction/rendering.tsx | 11 ++++++++++- .../tests/specs/syncOnboarding/manual.spec.ts | 8 ++++---- .../src/components/DeviceAction/rendering.tsx | 5 +++-- .../src/components/ValidateOnDevice.tsx | 4 ++-- .../src/screens/BleDevicePairingFlow/index.tsx | 4 ++-- libs/ledgerjs/packages/types-devices/README.md | 6 +++--- libs/ledgerjs/packages/types-devices/src/index.ts | 4 ++-- 8 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 .changeset/tricky-steaks-hope.md diff --git a/.changeset/tricky-steaks-hope.md b/.changeset/tricky-steaks-hope.md new file mode 100644 index 000000000000..f3749f999dd2 --- /dev/null +++ b/.changeset/tricky-steaks-hope.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/types-devices": patch +--- + +Rename QRCodeDevices by DevicesWithTouchScreen diff --git a/apps/ledger-live-desktop/src/renderer/components/DeviceAction/rendering.tsx b/apps/ledger-live-desktop/src/renderer/components/DeviceAction/rendering.tsx index 9d698572b05c..b4affff2cb33 100644 --- a/apps/ledger-live-desktop/src/renderer/components/DeviceAction/rendering.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/DeviceAction/rendering.tsx @@ -68,6 +68,7 @@ import { closePlatformAppDrawer } from "~/renderer/actions/UI"; import { CompleteExchangeError } from "@ledgerhq/live-common/exchange/error"; import { currencySettingsLocaleSelector, SettingsState } from "~/renderer/reducers/settings"; import { accountNameSelector, WalletState } from "@ledgerhq/live-wallet/store"; +import { isSyncOnboardingSupported } from "@ledgerhq/live-common/device/use-cases/screenSpecs"; export const AnimationWrapper = styled.div` width: 600px; @@ -663,7 +664,15 @@ export const DeviceNotOnboardedErrorComponent = withV3StyleProvider( setTrackingSource("device action open onboarding button"); dispatch(closeAllModal()); setDrawer(undefined); - history.push(device?.modelId === "stax" ? "/sync-onboarding/manual" : "/onboarding"); + if (!device?.modelId) { + history.push("/onboarding"); + } else { + history.push( + isSyncOnboardingSupported(device.modelId) + ? `/sync-onboarding/${device.modelId}` + : "/onboarding", + ); + } }, [device?.modelId, dispatch, history, setDrawer]); return ( diff --git a/apps/ledger-live-desktop/tests/specs/syncOnboarding/manual.spec.ts b/apps/ledger-live-desktop/tests/specs/syncOnboarding/manual.spec.ts index f13b721da7bd..65096a066b47 100644 --- a/apps/ledger-live-desktop/tests/specs/syncOnboarding/manual.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/syncOnboarding/manual.spec.ts @@ -14,15 +14,15 @@ const modelIds = [ ]; for (const modelId of modelIds) { - test.describe.parallel(`[${modelId}] SyncOnboarding with stax selected`, () => { + test.describe.parallel(`[${modelId}] SyncOnboarding`, () => { test(`[${modelId}] Manual @smoke`, async ({ page }) => { const onboardingPage = new OnboardingPage(page); - await page.evaluate(id => { + await page.evaluate((id: DeviceModelId) => { window.ledger.addDevice({ deviceId: "42", deviceName: `Ledger test ${id}`, - modelId: id as DeviceModelId, + modelId: id, wired: true, }); }, modelId); @@ -32,7 +32,7 @@ for (const modelId of modelIds) { }); await test.step(`[${modelId}] Select stax device`, async () => { - await onboardingPage.selectDevice("stax"); + await onboardingPage.selectDevice(modelId as "nanoS" | "nanoX" | "nanoSP" | "stax"); }); await test.step(`[${modelId}] Take screenshot of main screen`, async () => { diff --git a/apps/ledger-live-mobile/src/components/DeviceAction/rendering.tsx b/apps/ledger-live-mobile/src/components/DeviceAction/rendering.tsx index 05f948d0bb46..b74a80663e04 100644 --- a/apps/ledger-live-mobile/src/components/DeviceAction/rendering.tsx +++ b/apps/ledger-live-mobile/src/components/DeviceAction/rendering.tsx @@ -35,7 +35,7 @@ import { getFeesUnit, } from "@ledgerhq/live-common/account/index"; import { TFunction } from "react-i18next"; -import { DeviceModelId, QRCodeDevices } from "@ledgerhq/types-devices"; +import { DeviceModelId } from "@ledgerhq/types-devices"; import type { DeviceModelInfo } from "@ledgerhq/types-live"; import { StackNavigationProp } from "@react-navigation/stack"; import { ParamListBase } from "@react-navigation/native"; @@ -63,6 +63,7 @@ import Config from "react-native-config"; import { WalletState, accountNameWithDefaultSelector } from "@ledgerhq/live-wallet/store"; import { SettingsState } from "~/reducers/types"; import { RootStackParamList } from "../RootNavigator/types/RootNavigator"; +import { isSyncOnboardingSupported } from "@ledgerhq/live-common/device/use-cases/screenSpecs"; export const Wrapper = styled(Flex).attrs({ flex: 1, @@ -773,7 +774,7 @@ export function renderDeviceNotOnboarded({ navigation: StackNavigationProp; }) { const navigateToOnboarding = () => { - if (QRCodeDevices.includes(device.modelId)) { + if (isSyncOnboardingSupported(device.modelId)) { // On pairing success, navigate to the Sync Onboarding Companion navigation.navigate(NavigatorName.BaseOnboarding, { screen: NavigatorName.SyncOnboarding, diff --git a/apps/ledger-live-mobile/src/components/ValidateOnDevice.tsx b/apps/ledger-live-mobile/src/components/ValidateOnDevice.tsx index a8a6e896b940..64ed5b81948a 100644 --- a/apps/ledger-live-mobile/src/components/ValidateOnDevice.tsx +++ b/apps/ledger-live-mobile/src/components/ValidateOnDevice.tsx @@ -16,7 +16,7 @@ import { getDeviceModel } from "@ledgerhq/devices"; import { useTheme } from "@react-navigation/native"; import styled from "styled-components/native"; import { Flex } from "@ledgerhq/native-ui"; -import { QRCodeDevices } from "@ledgerhq/types-devices"; +import { DevicesWithTouchScreen } from "@ledgerhq/types-devices"; import Alert from "./Alert"; import perFamilyTransactionConfirmFields from "../generated/TransactionConfirmFields"; import { DataRowUnitValue, TextValueField } from "./ValidateOnDeviceDataRow"; @@ -170,7 +170,7 @@ export default function ValidateOnDevice({ {Title ? ( diff --git a/apps/ledger-live-mobile/src/screens/BleDevicePairingFlow/index.tsx b/apps/ledger-live-mobile/src/screens/BleDevicePairingFlow/index.tsx index 59c651d27a49..292f47f63969 100644 --- a/apps/ledger-live-mobile/src/screens/BleDevicePairingFlow/index.tsx +++ b/apps/ledger-live-mobile/src/screens/BleDevicePairingFlow/index.tsx @@ -1,4 +1,4 @@ -import { Device, QRCodeDevices } from "@ledgerhq/types-devices"; +import { Device, DevicesWithTouchScreen } from "@ledgerhq/types-devices"; import React, { useCallback } from "react"; import { Flex } from "@ledgerhq/native-ui"; import { SafeAreaView } from "react-native-safe-area-context"; @@ -70,7 +70,7 @@ export const BleDevicePairingFlow: React.FC = ({ navigation }) => { diff --git a/libs/ledgerjs/packages/types-devices/README.md b/libs/ledgerjs/packages/types-devices/README.md index a1661854b154..a28d41962d27 100644 --- a/libs/ledgerjs/packages/types-devices/README.md +++ b/libs/ledgerjs/packages/types-devices/README.md @@ -11,7 +11,7 @@ Ledger types for devices and transport. #### Table of Contents * [DeviceModelId](#devicemodelid) -* [QRCodeDevices](#qrcodedevices) +* [DevicesWithTouchScreen](#deviceswithtouchscreen) * [DeviceModel](#devicemodel) * [ChargingModes](#chargingmodes) * [BatteryStatusFlags](#batterystatusflags) @@ -31,9 +31,9 @@ Ledger types for devices and transport. DeviceModelId is a unique identifier to identify the model of a Ledger hardware wallet. -### QRCodeDevices +### DevicesWithTouchScreen -QRCodeDevices is a list of DeviceModelId of whom the Ledger device can present a QR code. +DevicesWithTouchScreen is a list of DeviceModelId of whom the Ledger device can present a QR code. Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[DeviceModelId](#devicemodelid)> diff --git a/libs/ledgerjs/packages/types-devices/src/index.ts b/libs/ledgerjs/packages/types-devices/src/index.ts index ef7ab3b876df..d5eba3458cc7 100644 --- a/libs/ledgerjs/packages/types-devices/src/index.ts +++ b/libs/ledgerjs/packages/types-devices/src/index.ts @@ -11,9 +11,9 @@ export enum DeviceModelId { } /** - * QRCodeDevices is a list of DeviceModelId of whom the Ledger device can present a QR code. + * DevicesWithTouchScreen is a list of DeviceModelId of whom the Ledger device can present a QR code. */ -export const QRCodeDevices: DeviceModelId[] = [DeviceModelId.stax, DeviceModelId.europa]; +export const DevicesWithTouchScreen: DeviceModelId[] = [DeviceModelId.stax, DeviceModelId.europa]; /** * a DeviceModel contains all the information of a specific Ledger hardware wallet model.