Skip to content

Commit

Permalink
fix(llm): fix device setup flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyuzhuang committed Jul 23, 2024
1 parent c4c9113 commit af3d126
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-steaks-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/types-devices": patch
---

Rename QRCodeDevices by DevicesWithTouchScreen
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ import { ErrorBody } from "../ErrorBody";
import LinkWithExternalIcon from "../LinkWithExternalIcon";
import { closePlatformAppDrawer } from "~/renderer/actions/UI";
import { CompleteExchangeError } from "@ledgerhq/live-common/exchange/error";
import { SettingsState, currencySettingsLocaleSelector } from "~/renderer/reducers/settings";
import { WalletState, accountNameSelector } from "@ledgerhq/live-wallet/store";
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;
Expand Down Expand Up @@ -636,7 +637,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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -70,7 +70,7 @@ export const BleDevicePairingFlow: React.FC<Props> = ({ navigation }) => {
<Flex px={6} flex={1}>
<BleDevicePairingFlowComponent
key={keyToReset}
filterByDeviceModelId={QRCodeDevices}
filterByDeviceModelId={DevicesWithTouchScreen}
onPairingSuccess={onPairingSuccess}
requestToSetHeaderOptions={requestToSetHeaderOptions}
/>
Expand Down
6 changes: 3 additions & 3 deletions libs/ledgerjs/packages/types-devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)>

Expand Down
4 changes: 2 additions & 2 deletions libs/ledgerjs/packages/types-devices/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit af3d126

Please sign in to comment.