Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruPislariu committed Feb 12, 2024
2 parents e67ce29 + 0f9a0be commit 9b47297
Show file tree
Hide file tree
Showing 69 changed files with 1,425 additions and 503 deletions.
6 changes: 6 additions & 0 deletions .changeset/fast-bananas-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

Add stakingProvidersEnabled A/B test trait to analytics identify for eth staking modal on both llm and lld.
5 changes: 5 additions & 0 deletions .changeset/hip-beers-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/hw-app-btc": patch
---

update hw-app-btc doc
5 changes: 5 additions & 0 deletions .changeset/old-timers-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Add codeowner hw-app-exchange
7 changes: 7 additions & 0 deletions .changeset/sharp-crews-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ledgerhq/hw-app-exchange": patch
"ledger-live-desktop": patch
"@ledgerhq/live-common": patch
---

Support base64 encodng for swap_ng type swaps
11 changes: 11 additions & 0 deletions .changeset/young-books-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@ledgerhq/live-common": patch
---

Refactor list apps v2:
- move entrypoint to `live-common/src/device/use-cases/listAppsUseCase.ts`
- move more of the `manager/api.ts` logic to `ManagerApiRepository`
- create `StubManagerApiRepository` for mocks
- implement some unit tests for `listApps/v2.ts`

Implement `getProviderIdUseCase` that takes `forceProvider: number` as a parameter
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ apps/ledger-live-mobile/src/screens/PTX/ @ledgerhq/ptx
apps/ledger-live-mobile/src/screens/Swap/ @ledgerhq/ptx
libs/ledger-live-common/src/exchange/ @ledgerhq/ptx
libs/exchange-module/ @ledgerhq/ptx
libs/ledgerjs/packages/hw-app-exchange/ @ledgerhq/ptx

# Wallet API team
**/PlatformAppProviderWrapper.tsx @ledgerhq/wallet-api
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/commands/appUninstallAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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 { listApps, execWithTransport } from "@ledgerhq/live-common/apps/hw";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { command as uninstallAllApps } from "@ledgerhq/live-common/hw/uninstallAllApps";
import { deviceOpt } from "../scan";

Expand All @@ -25,7 +28,7 @@ export default {
} else {
return from(getDeviceInfo(t)).pipe(
mergeMap(deviceInfo =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter(e => e.type === "result"),
map((e: any) =>
reducer(e.result, {
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/commands/appsCheckAllAppVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ 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 { listApps, execWithTransport } from "@ledgerhq/live-common/apps/hw";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { delay } from "@ledgerhq/live-common/promise";
import { getEnv } from "@ledgerhq/live-env";
import { getDependencies } from "@ledgerhq/live-common/apps/polyfill";
Expand Down Expand Up @@ -274,7 +277,7 @@ const checkInstalled = (installed, candidate: Candidate) => {
};

const wipeAll = (t, deviceInfo) =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter(e => e.type === "result"),
map((e: any) => e.result),
mergeMap(listAppsResult => {
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/commands/appsInstallAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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 { listApps, execWithTransport } from "@ledgerhq/live-common/apps/hw";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { deviceOpt } from "../scan";
export default {
description: "test script to install and uninstall all apps",
Expand All @@ -18,7 +21,7 @@ export default {
const exec = execWithTransport(t);
return from(getDeviceInfo(t)).pipe(
mergeMap(deviceInfo =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter(e => e.type === "result"),
map((e: any) =>
e.result.appsListNames.reduce(
Expand Down
9 changes: 6 additions & 3 deletions apps/cli/src/commands/appsUpdateTestAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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 { listApps, execWithTransport } from "@ledgerhq/live-common/apps/hw";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import type { AppOp } from "@ledgerhq/live-common/apps/types";
import { deviceOpt } from "../scan";

Expand Down Expand Up @@ -34,7 +37,7 @@ export default {
// FIXME: mergeMap deprecated, using map inside pipe should do the work
map(
deviceInfo =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter(e => e.type === "result"),
map((e: any) => e.result),
mergeMap(listAppsResult => {
Expand Down Expand Up @@ -82,7 +85,7 @@ export default {
new Observable(o => {
let sub;
const timeout = setTimeout(() => {
sub = listApps(t, deviceInfo).subscribe(o);
sub = listAppsUseCase(t, deviceInfo).subscribe(o);
}, 4000);
return () => {
clearTimeout(timeout);
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/commands/devDeviceAppsScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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 { listApps, execWithTransport } from "@ledgerhq/live-common/apps/hw";
import {
listAppsUseCase,
execWithTransport,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import installApp from "@ledgerhq/live-common/hw/installApp";
import { deviceOpt } from "../scan";
import { Application } from "@ledgerhq/types-live";
Expand Down Expand Up @@ -64,7 +67,7 @@ export default {
// $FlowFixMe
return from(getDeviceInfo(t)).pipe(
mergeMap(deviceInfo =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter<any>(e => e.type === "result"),
map<{ type: "result"; result: ListAppsResult }, ListAppsResult>(e => e.result),
mergeMap<ListAppsResult, Observable<Application[]>>(listAppsResult => {
Expand Down
7 changes: 5 additions & 2 deletions apps/cli/src/commands/managerListApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { from } from "rxjs";
import { filter, map, mergeMap, repeat } from "rxjs/operators";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { enableListAppsV2, listApps } from "@ledgerhq/live-common/apps/hw";
import {
enableListAppsV2,
listAppsUseCase,
} from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { deviceOpt } from "../scan";
export default {
description: "List apps that can be installed on the device",
Expand Down Expand Up @@ -44,7 +47,7 @@ export default {
return withDevice(device || "")(t =>
from(getDeviceInfo(t)).pipe(
mergeMap(deviceInfo =>
listApps(t, deviceInfo).pipe(
listAppsUseCase(t, deviceInfo).pipe(
filter(e => e.type === "result"),
// @ts-expect-error we need better typings and safe guard to infer types
map(e => e.result),
Expand Down
5 changes: 5 additions & 0 deletions apps/ledger-live-desktop/src/config/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export const urls = {
tos: "https://criptointercambio.com/terms-of-use",
support: "https://criptointercambio.com/en/about",
},
moonpay: {
main: "https://www.moonpay.com/",
tos: "https://www.moonpay.com/legal/terms_of_use",
support: "https://support.moonpay.com",
},
},
},
exchange: {
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/src/renderer/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import VaultSignerBanner from "~/renderer/components/VaultSignerBanner";
import { hasCompletedOnboardingSelector } from "~/renderer/reducers/settings";
import { updateIdentify } from "./analytics/segment";
import { useFeature, FeatureToggle } from "@ledgerhq/live-common/featureFlags/index";
import { enableListAppsV2 } from "@ledgerhq/live-common/apps/hw";
import { enableListAppsV2 } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import {
useFetchCurrencyAll,
useFetchCurrencyFrom,
Expand Down
8 changes: 8 additions & 0 deletions apps/ledger-live-desktop/src/renderer/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ const getFeatureFlagProperties = () => {
const analytics = getAnalytics();
const ptxEarnFeatureFlag = analyticsFeatureFlagMethod("ptxEarn");
const fetchAdditionalCoins = analyticsFeatureFlagMethod("fetchAdditionalCoins");
const stakingProviders = analyticsFeatureFlagMethod("ethStakingProviders");

const isBatch1Enabled =
!!fetchAdditionalCoins?.enabled && fetchAdditionalCoins?.params?.batch === 1;
const isBatch2Enabled =
!!fetchAdditionalCoins?.enabled && fetchAdditionalCoins?.params?.batch === 2;
const isBatch3Enabled =
!!fetchAdditionalCoins?.enabled && fetchAdditionalCoins?.params?.batch === 3;
const stakingProvidersEnabled =
stakingProviders?.enabled && stakingProviders?.params?.listProvider.length;

analytics.identify(
id,
Expand All @@ -77,6 +80,7 @@ const getFeatureFlagProperties = () => {
isBatch1Enabled,
isBatch2Enabled,
isBatch3Enabled,
stakingProvidersEnabled,
},
{
context: getContext(),
Expand All @@ -95,6 +99,9 @@ const extraProperties = (store: ReduxStore) => {
const device = lastSeenDeviceSelector(state);
const devices = devicesModelListSelector(state);
const accounts = accountsSelector(state);
const stakingProviders =
analyticsFeatureFlagMethod &&
analyticsFeatureFlagMethod("ethStakingProviders")?.params?.listProvider;

const deviceInfo = device
? {
Expand Down Expand Up @@ -145,6 +152,7 @@ const extraProperties = (store: ReduxStore) => {
hasGenesisPass,
hasInfinityPass,
modelIdList: devices,
stakingProvidersEnabled: stakingProviders?.length || "flag not loaded",
...deviceInfo,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Props = {

const StakingModal = ({ account, hasCheckbox, singleProviderRedirectMode, source }: Props) => {
const ethStakingProviders = useFeature("ethStakingProviders");
const providers = ethStakingProviders?.params?.listProvider;

if (!ethStakingProviders?.enabled) {
return null;
Expand All @@ -39,7 +40,7 @@ const StakingModal = ({ account, hasCheckbox, singleProviderRedirectMode, source
hasCheckbox={hasCheckbox}
singleProviderRedirectMode={singleProviderRedirectMode}
source={source}
listProviders={ethStakingProviders.params?.listProvider}
listProviders={providers}
/>
</Flex>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const Terms = styled(Text).attrs({
`;

export function DrawerFooter({ provider }: { provider: string }) {
const swapProvider = urls.swap.providers[provider as keyof typeof urls.swap.providers];
const url = ("tos" in swapProvider && swapProvider?.tos) || undefined;
const swapProvider =
urls.swap.providers?.[provider as keyof typeof urls.swap.providers] ?? undefined;
const url = (swapProvider && "tos" in swapProvider && swapProvider?.tos) || undefined;
const onLinkClick = useCallback(() => openURL(url!), [url]);
if (!url) {
return null;
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/apps/hw";
import { execWithTransport } from "@ledgerhq/live-common/device/use-cases/listAppsUseCase";
import { App, DeviceInfo, FirmwareUpdateContext } from "@ledgerhq/types-live";
import { AppOp, ListAppsResult } from "@ledgerhq/live-common/apps/types";
import { distribute, initState } from "@ledgerhq/live-common/apps/logic";
Expand Down
21 changes: 6 additions & 15 deletions apps/ledger-live-mobile/.unimportedrc.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"entry": [
"index.js"
],
"extensions": [
".ts",
".js",
".jsx",
".tsx",
".d.ts"
],
"ignorePatterns": [
"**/node_modules/**"
],
"entry": ["index.js"],
"extensions": [".ts", ".js", ".jsx", ".tsx", ".d.ts"],
"ignorePatterns": ["**/node_modules/**"],
"ignoreUnresolved": [],
"ignoreUnimported": [
"**/*.test.*",
Expand All @@ -24,7 +14,8 @@
"src/**/*.ios.*",
"src/components/RootNavigator/types.ts",
"src/logic/keyboardVisible.ts",
"src/contentCards/cards/vertical/*"
"src/contentCards/cards/vertical/*",
"src/**/__integrations__/*.tsx"
],
"ignoreUnused": [
"@ledgerhq/react-native-passcode-auth",
Expand All @@ -46,4 +37,4 @@
"react-native-tcp-socket",
"react-native-udp"
]
}
}
13 changes: 8 additions & 5 deletions apps/ledger-live-mobile/__tests__/test-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { I18nextProvider } from "react-i18next";
import { Provider } from "react-redux";
import { NavigationContainer } from "@react-navigation/native";
import { AnalyticsContextProvider } from "~/analytics/AnalyticsContext";
import NotificationsProvider from "~/screens/NotificationCenter/NotificationsProvider";
import { FirebaseFeatureFlagsProvider } from "~/components/FirebaseFeatureFlags";
import { getFeature } from "./featureFlags";
import { i18n } from "~/context/Locale";
Expand Down Expand Up @@ -35,7 +34,11 @@ const customRender = (
getDefaultMiddleware({ serializableCheck: false, immutableCheck: false }),
preloadedState: {
...initialState,
settings: { ...SETTINGS_INITIAL_STATE, overriddenFeatureFlags: featureFlags },
settings: {
...SETTINGS_INITIAL_STATE,
...(initialState.settings || {}),
overriddenFeatureFlags: featureFlags,
},
},
devTools: false,
});
Expand All @@ -47,9 +50,7 @@ const customRender = (
<FirebaseFeatureFlagsProvider getFeature={getFeature}>
<AnalyticsContextProvider>
<I18nextProvider i18n={i18n}>
<NotificationsProvider>
<NavigationContainer>{children}</NavigationContainer>
</NotificationsProvider>
<NavigationContainer>{children}</NavigationContainer>
</I18nextProvider>
</AnalyticsContextProvider>
</FirebaseFeatureFlagsProvider>
Expand All @@ -64,6 +65,8 @@ const customRender = (
};
};

export const LONG_TIMEOUT = 30000;

// re-export everything
export * from "@testing-library/react-native";

Expand Down
Loading

0 comments on commit 9b47297

Please sign in to comment.