Skip to content

Commit

Permalink
Merge branch 'develop' into feature/llm-card
Browse files Browse the repository at this point in the history
  • Loading branch information
sarneijim committed Sep 9, 2024
2 parents e63eb3b + 1e0eece commit d3da002
Show file tree
Hide file tree
Showing 37 changed files with 586 additions and 245 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-feet-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/web-tools": minor
---

Update Next & react version to latest to ensure to be up to date with security fixes
5 changes: 5 additions & 0 deletions .changeset/green-years-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Delete local app data when uninstalling apps
5 changes: 5 additions & 0 deletions .changeset/happy-onions-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

fix: remove error from btc fee drawer
5 changes: 5 additions & 0 deletions .changeset/khaki-deers-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

add forgetten param demo 3 to live app
6 changes: 6 additions & 0 deletions .changeset/light-camels-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/live-common": minor
"ledger-live-desktop": patch
---

Delete local app data when uninstalling apps
5 changes: 5 additions & 0 deletions .changeset/tame-years-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/hw-app-eth": patch
---

Fix `destructTypeFromString` not splitting types correctly when they contained a number and weren't native types (Struct with numbers in the name)
6 changes: 2 additions & 4 deletions apps/cli/src/commands/device/appUninstallAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { mergeMap, filter, map } from "rxjs/operators";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { reducer, runAll } from "@ledgerhq/live-common/apps/index";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import { command as uninstallAllApps } from "@ledgerhq/live-common/hw/uninstallAllApps";
import { deviceOpt } from "../../scan";

Expand Down
6 changes: 2 additions & 4 deletions apps/cli/src/commands/device/appsCheckAllAppVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import network from "@ledgerhq/live-network/network";
import installApp from "@ledgerhq/live-common/hw/installApp";
import uninstallApp from "@ledgerhq/live-common/hw/uninstallApp";
import { initState, reducer, runAll } from "@ledgerhq/live-common/apps/index";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import { delay } from "@ledgerhq/live-common/promise";
import { getEnv } from "@ledgerhq/live-env";
import { getDependencies } from "@ledgerhq/live-common/apps/polyfill";
Expand Down
6 changes: 2 additions & 4 deletions apps/cli/src/commands/device/appsInstallAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { mergeMap, filter, map } from "rxjs/operators";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { initState, reducer, runAll } from "@ledgerhq/live-common/apps/index";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import { deviceOpt } from "../../scan";
export default {
description: "test script to install and uninstall all apps",
Expand Down
6 changes: 2 additions & 4 deletions apps/cli/src/commands/device/appsUpdateTestAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { mergeMap, ignoreElements, filter, map } from "rxjs/operators";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { initState, reducer, runAll, getActionPlan } from "@ledgerhq/live-common/apps/index";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import type { AppOp } from "@ledgerhq/live-common/apps/types";
import { deviceOpt } from "../../scan";

Expand Down
6 changes: 2 additions & 4 deletions apps/cli/src/commands/device/devDeviceAppsScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { initState, ListAppsResult, reducer, runAll } from "@ledgerhq/live-common/apps/index";
import ManagerAPI from "@ledgerhq/live-common/manager/api";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import installApp from "@ledgerhq/live-common/hw/installApp";
import { deviceOpt } from "../../scan";
import { Application } from "@ledgerhq/types-live";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ import CoinControlModal from "./CoinControlModal";
import { FeesField } from "./FeesField";
import { BitcoinFamily } from "./types";
import useBitcoinPickingStrategy from "./useBitcoinPickingStrategy";
import Alert from "~/renderer/components/Alert";
import TranslatedError from "~/renderer/components/TranslatedError";
import { useDispatch } from "react-redux";
import { useHistory } from "react-router";
import { closeAllModal } from "~/renderer/actions/modals";
import { setTrackingSource } from "~/renderer/analytics/TrackPage";
import { Flex } from "@ledgerhq/react-ui";

type Props = NonNullable<BitcoinFamily["sendAmountFields"]>["component"];

Expand Down Expand Up @@ -53,25 +46,6 @@ const Fields: Props = ({
const { item } = useBitcoinPickingStrategy(transaction.utxoStrategy.strategy);
const canNext = account.bitcoinResources?.utxos?.length;

const dispatch = useDispatch();
const history = useHistory();

const onBuyClick = useCallback(() => {
dispatch(closeAllModal());
setTrackingSource("send flow");
history.push({
pathname: "/exchange",
state: {
currency: account.currency.id,
account: account.id,
mode: "buy", // buy or sell
},
});
}, [account.currency.id, account.id, dispatch, history]);

const { errors } = status;
const { amount: messageAmount } = errors;

/* TODO: How do we set default RBF to be true ? (@gre)
* Meanwhile, using this trick (please don't kill me)
*/
Expand Down Expand Up @@ -183,13 +157,6 @@ const Fields: Props = ({
mapStrategies={mapStrategies}
status={status}
/>
{messageAmount && (
<Flex onClick={onBuyClick}>
<Alert type="warning">
<TranslatedError error={messageAmount} />
</Alert>
</Flex>
)}
</>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ const StepPrepare = ({
// the firmware update payload to the device whereas now we are backing up the CLS too
// but only for stax or europa.
const deviceId = device?.deviceId ?? "";

// Back app data for installed apps before initiating the firmware update.
// TODO:

// This is the backup of the CLS for stax or flex devices.
const maybeCLSBackup =
deviceInfo.onboarded && isCustomLockScreenSupported(deviceModelId)
? customLockScreenFetch({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ const SwapWebView = ({
hasError: swapState?.error ? "true" : undefined, // append param only if error is true
isMaxEnabled: isMaxEnabled,
loading: swapState?.loading,
fromParentAccountId: swapState?.fromParentAccountId,
swapApiBase: process.env.SWAP_API_BASE,
networkFees: swapState?.estimatedFees,
networkFeesCurrency: fromCurrency,
provider: swapState?.provider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useMemo, useState, useEffect, useRef, useContext } from "react";
import { useSelector } from "react-redux";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import { DeviceInfo, FirmwareUpdateContext } from "@ledgerhq/types-live";
import { ExecArgs, ListAppsResult } from "@ledgerhq/live-common/apps/types";
import { distribute, initState } from "@ledgerhq/live-common/apps/logic";
Expand Down Expand Up @@ -79,7 +79,7 @@ const Dashboard = ({
() =>
getEnv("MOCK")
? mockExecWithInstalledContext(result?.installed || [])
: ({ app, appOp, targetId }: ExecArgs) =>
: ({ app, appOp, targetId, skipAppDataBackup }: ExecArgs) =>
withDevice(device.deviceId)(transport =>
execWithTransport(
transport,
Expand All @@ -90,6 +90,7 @@ const Dashboard = ({
app,
modelId: device.modelId,
storage,
skipAppDataBackup,
}),
),
[device, result, appsBackupEnabled, storage],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const DeviceDashboard = ({
const reduxDispatch = useDispatch();
const lastSeenCustomImage = useSelector(lastSeenCustomImageSelector);
const isFirstCustomImageUpdate = useRef<boolean>(true);

useEffect(() => {
if (isFirstCustomImageUpdate.current) {
isFirstCustomImageUpdate.current = false;
Expand All @@ -111,8 +112,10 @@ const DeviceDashboard = ({
});
}
}, [dispatch, lastSeenCustomImage]);

const { installQueue, uninstallQueue, currentError } = state;
const jobInProgress = installQueue.length > 0 || uninstallQueue.length > 0;

const distribution = useMemo(() => {
const newState = installQueue.length
? predictOptimisticState(
Expand All @@ -124,21 +127,26 @@ const DeviceDashboard = ({
: state;
return distribute(newState);
}, [state, installQueue]);

const onCloseDepsInstallModal = useCallback(
() => setAppInstallDep(undefined),
[setAppInstallDep],
);

const onCloseDepsUninstallModal = useCallback(
() => setAppUninstallDep(undefined),
[setAppUninstallDep],
);

const installState =
installQueue.length > 0 ? (uninstallQueue.length > 0 ? "update" : "install") : "uninstall";

const onCloseError = useCallback(() => {
dispatch({
type: "recover",
});
}, [dispatch]);

useEffect(() => {
if (state.installed.length && !hasInstalledApps) {
reduxDispatch(setHasInstalledApps(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type FirmwareUpdateParams = {
export type UpdateStep =
| "start"
| "appsBackup"
// | "appsDataBackup"
| "imageBackup"
| "firmwareUpdate"
| "languageRestore"
Expand Down Expand Up @@ -234,6 +235,10 @@ export const useUpdateFirmwareAndRestoreSettings = ({
}
break;

// TODO: Implement apps data backup
// case "appsDataBackup":
// break;

case "imageBackup":
hasUnrecoverableError =
staxFetchImageState.error &&
Expand Down
6 changes: 3 additions & 3 deletions apps/ledger-live-mobile/src/screens/MyLedgerDevice/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback } from "react";
import type { Exec, ListAppsResult } from "@ledgerhq/live-common/apps/index";
import { useAppsRunner } from "@ledgerhq/live-common/apps/react";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/execWithTransport";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import {
AppStorageType,
Expand All @@ -19,12 +19,12 @@ export function useApps(
const enableAppsBackup = useFeature("enableAppsBackup");

const exec: Exec = useCallback(
args =>
({ skipAppDataBackup, ...args }) =>
withDevice(device.deviceId)(transport =>
execWithTransport(
transport,
enableAppsBackup?.enabled,
)({ ...args, storage, modelId: device.modelId }),
)({ ...args, storage, modelId: device.modelId, skipAppDataBackup }),
),
[device, enableAppsBackup, storage],
);
Expand Down
10 changes: 5 additions & 5 deletions apps/web-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"eslint-config-next": "13.5.6",
"invariant": "^2.2.4",
"lodash": "^4.17.21",
"next": "14.2.3",
"next": "14.2.8",
"prop-types": "^15.8.1",
"qrcode": "^1.4.4",
"re-resizable": "^6.9.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-dropzone": "14",
"react-inspector": "^4.0.1",
"react-select": "^5.7.4",
Expand All @@ -65,8 +65,8 @@
"@types/lodash": "^4.14.198",
"@types/node": "20.8.10",
"@types/qrcode": "1",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.13",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react-inspector": "^4.0.2",
"@types/react-table": "^7.7.15",
"@types/semver": "^7.3.9"
Expand Down
4 changes: 2 additions & 2 deletions apps/web-tools/repl/components/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import FormField from "./FormField";
import { Form } from "../helpers/commands";
import { Form as FormType } from "../helpers/commands";

const Form = ({
form,
dependencies,
value,
onChange,
}: {
form: Form;
form: FormType;
dependencies: Object;
value: any;
onChange: (v: any) => void;
Expand Down
3 changes: 2 additions & 1 deletion libs/ledger-live-common/src/apps/inlineAppInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Transport from "@ledgerhq/hw-transport";
import { Observable, concat, of, from, EMPTY, defer } from "rxjs";
import { ConnectAppEvent } from "../hw/connectApp";
import getDeviceInfo from "../hw/getDeviceInfo";
import { listAppsUseCase, execWithTransport } from "../device/use-cases/listAppsUseCase";
import { listAppsUseCase } from "../device/use-cases/listAppsUseCase";
import { execWithTransport } from "../device/use-cases/execWithTransport";
import { reducer, initState, isOutOfMemoryState, predictOptimisticState } from "./logic";
import { runAllWithProgress } from "./runner";
import { InlineAppInstallEvent } from "./types";
Expand Down
13 changes: 11 additions & 2 deletions libs/ledger-live-common/src/apps/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const initState = (
currentError: null,
currentAppOp: null,
skippedAppOps: [],
skipAppDataBackup: false,
};

if (appsToRestore) {
Expand Down Expand Up @@ -103,7 +104,7 @@ export const reducer = (state: State, action: Action): State => {
state.currentProgressSubject.complete();
}

let nextState;
let nextState: State;

if (appOp.type === "install") {
const app = state.apps.find(a => a.name === appOp.name);
Expand Down Expand Up @@ -197,6 +198,7 @@ export const reducer = (state: State, action: Action): State => {
return {
...state,
installed: [],
skipAppDataBackup: false,
};
case "wipe":
return {
Expand All @@ -207,6 +209,7 @@ export const reducer = (state: State, action: Action): State => {
state.appByName,
state.installed.map(({ name }) => name),
),
skipAppDataBackup: true,
};

case "updateAll": {
Expand Down Expand Up @@ -371,7 +374,13 @@ export const reducer = (state: State, action: Action): State => {
);
}

return { ...state, currentError: null, installQueue, uninstallQueue };
return {
...state,
currentError: null,
installQueue,
uninstallQueue,
skipAppDataBackup: true,
};
}
}
};
Expand Down
Loading

0 comments on commit d3da002

Please sign in to comment.