Skip to content

Commit

Permalink
feat: add better error for sol
Browse files Browse the repository at this point in the history
  • Loading branch information
Justkant committed Jan 10, 2025
1 parent e7b3400 commit a6cee81
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ManagerNotEnoughSpaceError, UpdateYourApp } from "@ledgerhq/errors";
import { LatestFirmwareVersionRequired, OutdatedApp } from "@ledgerhq/live-common/errors";
import { useTranslation } from "react-i18next";
import { renderError } from "~/renderer/components/DeviceAction/rendering";

Expand All @@ -22,7 +24,25 @@ const ErrorDisplay = ({
}: ErrorDisplayProps) => {
const { t } = useTranslation();

return renderError({ t, error, onRetry, withExportLogs, list, supportLink, warning, Icon });
const managerAppName =
error instanceof ManagerNotEnoughSpaceError ||
(error as unknown) instanceof OutdatedApp ||
(error as unknown) instanceof UpdateYourApp
? (error as unknown as { managerAppName: string }).managerAppName
: undefined;

return renderError({
t,
error,
onRetry,
managerAppName,
requireFirmwareUpdate: error instanceof LatestFirmwareVersionRequired,
withExportLogs,
list,
supportLink,
warning,
Icon,
});
};

export default ErrorDisplay;
10 changes: 7 additions & 3 deletions libs/ledger-live-common/src/families/solana/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ import { DeviceModelId } from "@ledgerhq/devices";
import { loadPKI } from "@ledgerhq/hw-bolos";
import calService from "@ledgerhq/ledger-cal-service";
import trustService from "@ledgerhq/ledger-trust-service";
import { FirmwareOrAppUpdateRequired, TransportStatusError } from "@ledgerhq/errors";
import { TransportStatusError, UpdateYourApp } from "@ledgerhq/errors";
import { CreateSigner, createResolver, executeWithSigner } from "../../bridge/setup";
import { LatestFirmwareVersionRequired } from "../../errors";
import type { Resolver } from "../../hw/getAddress/types";

const TRUSTED_NAME_MIN_VERSION = "1.6.1";
const MANAGER_APP_NAME = "Solana";

async function checkVersion(app: Solana) {
const { version } = await app.getAppConfiguration();
if (semver.lt(version, TRUSTED_NAME_MIN_VERSION)) {
throw new FirmwareOrAppUpdateRequired();
throw new UpdateYourApp(undefined, {
managerAppName: MANAGER_APP_NAME,
});
}
}

Expand All @@ -49,7 +53,7 @@ const createSigner: CreateSigner<SolanaSigner> = (transport: Transport) => {
await loadPKI(transport, "TRUSTED_NAME", descriptor, signature);
} catch (err) {
if (isPKIUnsupportedError(err)) {
throw new FirmwareOrAppUpdateRequired();
throw new LatestFirmwareVersionRequired("LatestFirmwareVersionRequired");
}
}

Expand Down

0 comments on commit a6cee81

Please sign in to comment.