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

πŸ› LLM - Improve Ledger Sync error when an unauthorized member tries to delete backup #8477

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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") ||
themooneer marked this conversation as resolved.
Show resolved Hide resolved
error.message.includes("You are not member"));
Loading