Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/live 5056 error mapping not found entity #5315

Merged
7 changes: 7 additions & 0 deletions .changeset/swift-pianos-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
"@ledgerhq/live-common": patch
---

Improve wording of "not found entity" error
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5165,8 +5165,8 @@
"description": "Please update your devices Firmware to the latest version to access this feature"
},
"FirmwareNotRecognized": {
"title": "Device firmware is not recognized",
"description": "Please contact Ledger Support"
"title": "Invalid Provider",
"description": "You have to change \"My Ledger provider\" setting. To change it, open Ledger Live \"Settings\", select \"Experimental features\", and then select a different provider."
},
"HardResetFail": {
"title": "Sorry, could not reset",
Expand Down
4 changes: 4 additions & 0 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,10 @@
},
"InvalidMemoICP": {
"title": "Memo is required to be a number"
},
"FirmwareNotRecognized": {
"title": "Invalid Provider",
"description": "You have to change \"My Ledger provider\" setting. To change it, open Ledger Live \"Settings\", select \"Experimental features\", and then select a different provider."
}
},
"crash": {
Expand Down
17 changes: 7 additions & 10 deletions apps/ledger-live-mobile/src/screens/PairDevices/RenderError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
HwTransportError,
HwTransportErrorType,
PeerRemovedPairing,
FirmwareNotRecognized,
} from "@ledgerhq/errors";
import { Flex, Button, IconsLegacy } from "@ledgerhq/native-ui";
import { useTheme } from "@react-navigation/native";
Expand Down Expand Up @@ -38,7 +39,9 @@ const hitSlop = {
function RenderError({ error, status, onBypassGenuine, onRetry }: Props) {
const { colors } = useTheme();
const isPairingStatus = status === "pairing";
const isFirmwareNotRecognized = error instanceof FirmwareNotRecognized;
const isGenuineCheckStatus = status === "genuinecheck";
const isGenuineCheckSkippableError = isGenuineCheckStatus && !isFirmwareNotRecognized;
const isBrokenPairing = error instanceof PeerRemovedPairing;

const url = isBrokenPairing
Expand Down Expand Up @@ -74,7 +77,7 @@ function RenderError({ error, status, onBypassGenuine, onRetry }: Props) {
const outerError =
isPairingStatus && !isBrokenPairing
? new PairingFailed()
: isGenuineCheckStatus
: isGenuineCheckSkippableError
? new GenuineCheckFailed()
: null;

Expand Down Expand Up @@ -107,18 +110,12 @@ function RenderError({ error, status, onBypassGenuine, onRetry }: Props) {
) : (
<>
<Flex mt={30} flexDirection={"row"}>
<Button
flex={1}
iconPosition="left"
Icon={IconsLegacy.ExternalLinkMedium}
type="main"
onPress={onRetry}
>
<Button flex={1} iconPosition="left" type="main" onPress={onRetry}>
<Trans i18nKey="common.retry" />
</Button>
</Flex>

{isGenuineCheckStatus ? (
{isGenuineCheckSkippableError ? (
<Touchable
event="PairDevicesBypassGenuine"
onPress={onBypassGenuine}
Expand All @@ -136,7 +133,7 @@ function RenderError({ error, status, onBypassGenuine, onRetry }: Props) {
</>
)}
</Flex>
{isGenuineCheckStatus ? (
{isGenuineCheckSkippableError ? (
<Flex height={48}>
<HelpLink style={styles.linkContainerGenuine} />
</Flex>
Expand Down
11 changes: 8 additions & 3 deletions libs/ledger-live-common/src/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ const getCurrentFirmware: (input: {
version_name: input.version,
provider: input.provider,
},
}).catch(error => {
const status = error?.status || error?.response?.status;

if (status === 404) throw new FirmwareNotRecognized();

throw error;
});
return data;
},
Expand Down Expand Up @@ -457,13 +463,12 @@ const getDeviceVersion: (targetId: string | number, provider: number) => Promise
target_id: targetId,
},
}).catch(error => {
const status = error && (error.status || (error.response && error.response.status)); // FIXME LLD is doing error remapping already. we probably need to move the remapping in live-common
const status = error?.status || error?.response?.status;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah cleaner :)


if (status === 404) {
if (status === 404)
throw new FirmwareNotRecognized("manager api did not recognize targetId=" + targetId, {
targetId,
});
}

throw error;
});
Expand Down