Skip to content

Commit

Permalink
🐛 fix(llm): improve error message when an unauthorized member tries t…
Browse files Browse the repository at this point in the history
…o delete a backup
  • Loading branch information
cgrellard-ledger committed Nov 25, 2024
1 parent 08e1fa9 commit 306dec6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silly-cougars-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

LLM - Ledger Sync improved error message when an unauthorized member tries to delete a backup
7 changes: 7 additions & 0 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -6919,6 +6919,13 @@
"title": "Sync with another Ledger Live app",
"description": "Sync your Ledger Live crypto accounts across different phones and computers."
},
"unauthorizeMember": {
"error": {
"title": "This app is no longer synced",
"description": "Turn on Ledger Sync on either this Ledger Live or the one you're syncing with.",
"cta": "Turn on Ledger Sync"
}
},
"manageKey": {
"title": "Delete Sync",
"description": "Your crypto accounts across different phones and computers will stop synching.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum ErrorReason {
NO_BACKUP_ONBOARDING_DEVICE = "no-backup-onboarding-device",
NO_BACKUP_ONBOARDING_QRCODE = "no-backup-onboarding-qrcode",
NO_TRUSTCHAIN = "no-trustchain",
UNAUTHORIZED_MEMBER = "unauthorized-member",
}

export interface ErrorConfig {
Expand Down Expand Up @@ -238,6 +239,18 @@ export function useSpecificError({ primaryAction, secondaryAction }: SpecificPro
onCreate({ page: AnalyticsPage.DeleteBackupError, hasFlow: false });
},
},
[ErrorReason.UNAUTHORIZED_MEMBER]: {
icon: <Icons.DeleteCircleFill size={"L"} color={colors.error.c60} />,
title: t("walletSync.walletSyncActivated.unauthorizeMember.error.title"),
description: t("walletSync.walletSyncActivated.unauthorizeMember.error.description"),
cta: t("walletSync.walletSyncActivated.unauthorizeMember.error.cta"),
analyticsPage: AnalyticsPage.DeleteBackupError,
buttonType: "main" as ButtonProps["type"],
primaryAction: () => {
primaryAction();
onCreate({ page: AnalyticsPage.DeleteBackupError, hasFlow: false });
},
},
};

const getErrorConfig = (error: ErrorReason) => errorConfig[error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Flex, InfiniteLoader } from "@ledgerhq/native-ui";

import { ConfirmManageKey } from "../../components/ManageKey/Confirm";
import { HookResult } from "./useManageKeyDrawer";
import { isNoTrustchainError } from "../../utils/errors";
import { isNoTrustchainError, isUnauthorizedMemberError } from "../../utils/errors";
import { SpecificError } from "../../components/Error/SpecificError";
import { ErrorReason } from "../../hooks/useSpecificError";

Expand All @@ -23,6 +23,11 @@ const ManageKeyDrawer = ({
if (isNoTrustchainError(deleteMutation.error)) {
return <SpecificError error={ErrorReason.NO_TRUSTCHAIN} primaryAction={onCreateKey} />;
}
if (isUnauthorizedMemberError(deleteMutation.error)) {
return (
<SpecificError error={ErrorReason.UNAUTHORIZED_MEMBER} primaryAction={onCreateKey} />
);
}
return (
<GenericErrorView
error={deleteMutation.error}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { LedgerAPI4xx } from "@ledgerhq/errors";
import { ErrorType } from "../hooks/type.hooks";

export const isNoTrustchainError = (error: Error) =>
error.message.includes(ErrorType.NO_TRUSTCHAIN);

export const isUnauthorizedMemberError = (error: Error) =>
error instanceof LedgerAPI4xx &&
(error.message.includes("Not a member of trustchain") ||
error.message.includes("You are not member"));

0 comments on commit 306dec6

Please sign in to comment.