Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'ledgerhq/develop' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
hakim-adamik committed Apr 5, 2022
2 parents dafb389 + e9bc7f2 commit 4f5cf98
Show file tree
Hide file tree
Showing 206 changed files with 473,191 additions and 91,155 deletions.
82 changes: 70 additions & 12 deletions cryptoassets.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "MIT",
"private": true,
"main": "./.webpack/main.bundle.js",
"version": "2.39.2",
"version": "2.40.2",
"scripts": {
"start:prod": "electron ./.webpack/main.bundle.js",
"start": "cross-env NODE_ENV=development node ./tools/main.js",
Expand Down
1 change: 1 addition & 0 deletions src/live-common-set-supported-currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ setSupportedCurrencies([
"dogecoin",
"cosmos",
"crypto_org",
"celo",
"dash",
"tron",
"tezos",
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import MarketCoinScreen from "~/renderer/screens/market/MarketCoinScreen";
// $FlowFixMe
import Learn from "~/renderer/screens/learn";

import { useProviders } from "~/renderer/screens/exchange/Swap2/Form";

export const TopBannerContainer: ThemedComponent<{}> = styled.div`
position: sticky;
top: 0;
Expand Down Expand Up @@ -120,6 +122,8 @@ export default function Default() {
useDeeplink();
useUSBTroubleshooting();

useProviders(); // prefetch data from swap providers here

// every time location changes, scroll back up
useEffect(() => {
if (ref && ref.current) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/1PlugAndPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/1PlugAndPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/2FirmwareUpdating/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/2FirmwareUpdating/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/3EnterPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/3EnterPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/4QuitApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/4QuitApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/5AllowManager/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/5AllowManager/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/6OpenApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/6OpenApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/7Validate/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoS/7Validate/light.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoS/8InstallLoading/dark.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoS/8InstallLoading/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/1PlugAndPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/1PlugAndPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/2FirmwareUpdating/dark.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/3EnterPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/3EnterPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/4QuitApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/4QuitApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/5AllowManager/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/5AllowManager/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/6OpenApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/6OpenApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/7Validate/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoSP/7Validate/light.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoSP/8InstallLoading/dark.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoSP/8InstallLoading/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/1PlugAndPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/1PlugAndPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/2FirmwareUpdating/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/2FirmwareUpdating/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/3EnterPinCode/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/3EnterPinCode/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/4QuitApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/4QuitApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/5AllowManager/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/5AllowManager/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/6OpenApp/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/6OpenApp/light.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/7Validate/dark.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/renderer/animations/nanoX/7Validate/light.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoX/8InstallLoading/dark.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/renderer/animations/nanoX/8InstallLoading/light.json

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion src/renderer/components/BalanceInfos/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import React from "react";
import React, { useCallback } from "react";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import type { Unit, AccountLike } from "@ledgerhq/live-common/lib/types";
Expand All @@ -10,6 +10,11 @@ import PillsDaysCount from "~/renderer/components/PillsDaysCount";
import TransactionsPendingConfirmationWarning from "~/renderer/components/TransactionsPendingConfirmationWarning";
import { PlaceholderLine } from "./Placeholder";

// $FlowFixMe
import Button from "~/renderer/components/Button.ui.tsx";
import { setTrackingSource } from "~/renderer/analytics/TrackPage";
import { useHistory } from "react-router-dom";

type BalanceSinceProps = {
valueChange: ValueChange,
totalBalance: number,
Expand Down Expand Up @@ -101,6 +106,22 @@ export function BalanceTotal({

export default function BalanceInfos({ totalBalance, valueChange, isAvailable, unit }: Props) {
const { t } = useTranslation();
const history = useHistory();

const onBuy = useCallback(() => {
setTrackingSource("Page Portfolio");
history.push({
pathname: "/exchange",
});
}, [history]);

const onSwap = useCallback(() => {
setTrackingSource("Page Market");

history.push({
pathname: "/swap",
});
}, [history]);

return (
<Box flow={5}>
Expand All @@ -113,6 +134,13 @@ export default function BalanceInfos({ totalBalance, valueChange, isAvailable, u
>
<Sub>{t("dashboard.totalBalance")}</Sub>
</BalanceTotal>
<Button data-test-id="portfolio-buy-button" variant="color" mr={1} onClick={onBuy}>
{t("accounts.contextMenu.buy")}
</Button>

<Button data-test-id="portfolio-swap-button" variant="color" onClick={onSwap}>
{t("accounts.contextMenu.swap")}
</Button>
</Box>
<Box horizontal alignItems="center" justifyContent="space-between">
<BalanceDiff
Expand Down
55 changes: 55 additions & 0 deletions src/renderer/components/Button.ui.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// @flow
import React from "react";
import { Button as BaseButton, InvertTheme } from "@ledgerhq/react-ui";
import { ButtonProps as BaseButtonProps } from "@ledgerhq/react-ui/components/cta/Button";
import { track } from "~/renderer/analytics/segment";
import styled from "styled-components";

export const Base = styled(BaseButton)<{ big?: boolean }>`
border-radius: 44px;
font-size: 12px;
height: 40px;
line-height: 40px;
padding: 0 24px;
${p =>
p.variant === "shade"
? `background-color: transparent!important;border-color: currentColor;`
: ``}
`;

export type Props = BaseButtonProps & {
inverted?: boolean;
disabled?: boolean;
isLoading?: boolean;
event?: string;
eventProperties?: Record<string, unknown>;
};

export default function Button({
onClick,
inverted,
disabled,
children,
isLoading,
event,
eventProperties,
...rest
}: Props) {
const isClickDisabled = disabled || isLoading;
const onClickHandler = (e: React.SyntheticEvent<HTMLButtonElement, Event>) => {
if (onClick) {
if (event) {
track(event, eventProperties || {});
}
onClick(e);
}
};
const inner = (
<Base {...rest} onClick={isClickDisabled ? undefined : onClickHandler}>
{children}
</Base>
);
return inverted ? <InvertTheme>{inner} </InvertTheme> : inner;
}
16 changes: 16 additions & 0 deletions src/renderer/components/DeviceAction/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const nanoS = {
light: require("~/renderer/animations/nanoS/2FirmwareUpdating/light.json"),
dark: require("~/renderer/animations/nanoS/2FirmwareUpdating/dark.json"),
},
installLoading: {
light: require("~/renderer/animations/nanoS/8InstallLoading/light.json"),
dark: require("~/renderer/animations/nanoS/8InstallLoading/dark.json"),
},
};
const nanoX = {
plugAndPinCode: {
Expand Down Expand Up @@ -60,6 +64,10 @@ const nanoX = {
light: require("~/renderer/animations/nanoX/2FirmwareUpdating/light.json"),
dark: require("~/renderer/animations/nanoX/2FirmwareUpdating/dark.json"),
},
installLoading: {
light: require("~/renderer/animations/nanoX/8InstallLoading/light.json"),
dark: require("~/renderer/animations/nanoX/8InstallLoading/dark.json"),
},
};

const nanoSP = {
Expand Down Expand Up @@ -91,6 +99,10 @@ const nanoSP = {
light: require("~/renderer/animations/nanoSP/2FirmwareUpdating/light.json"),
dark: require("~/renderer/animations/nanoSP/2FirmwareUpdating/dark.json"),
},
installLoading: {
light: require("~/renderer/animations/nanoSP/8InstallLoading/light.json"),
dark: require("~/renderer/animations/nanoSP/8InstallLoading/dark.json"),
},
};

const blue = {
Expand All @@ -117,6 +129,10 @@ const blue = {
light: require("~/renderer/animations/nanoS/2FirmwareUpdating/light.json"),
dark: require("~/renderer/animations/nanoS/2FirmwareUpdating/dark.json"),
},
installLoading: {
light: require("~/renderer/animations/nanoS/8InstallLoading/light.json"),
dark: require("~/renderer/animations/nanoS/8InstallLoading/dark.json"),
},
};

const animations = { nanoX, nanoS, nanoSP, blue };
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/DeviceAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const DeviceAction = <R, H, P>({

if (installingApp) {
const appName = requestOpenApp;
const props = { appName, progress, request, analyticsPropertyFlow };
const props = { type, modelId, appName, progress, request, analyticsPropertyFlow };
return <InstallingApp {...props} />;
}

Expand Down
21 changes: 10 additions & 11 deletions src/renderer/components/DeviceAction/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ import { relaunchOnboarding } from "~/renderer/actions/onboarding";
export const AnimationWrapper: ThemedComponent<{ modelId?: DeviceModelId }> = styled.div`
width: 600px;
max-width: 100%;
height: ${p => (p.modelId === "blue" ? 300 : 200)}px;
padding-bottom: ${p => (p.modelId === "blue" ? 20 : 0)}px;
padding-bottom: 20px;
align-self: center;
display: flex;
align-items: center;
Expand Down Expand Up @@ -283,18 +282,23 @@ export const renderRequiresAppInstallation = ({ appNames }: { appNames: string[]
};

export const InstallingApp = ({
modelId,
type,
appName,
progress,
request,
analyticsPropertyFlow = "unknown",
}: {
modelId: DeviceModelId,
type: "light" | "dark",
appName: string,
progress: number,
request: any,
analyticsPropertyFlow?: string,
}) => {
const currency = request?.currency || request?.account?.currency;
const appNameToTrack = appName || request?.appName || currency?.managerAppName;
const cleanProgress = progress ? Math.round(progress * 100) : null;
useEffect(() => {
const trackingArgs = [
"In-line app install",
Expand All @@ -305,22 +309,17 @@ export const InstallingApp = ({
return (
<Wrapper id="deviceAction-loading">
<Header />
<ProgressWrapper>
{progress ? (
<ProgressCircle size={58} progress={progress} />
) : (
<Rotating size={58}>
<ProgressCircle hideProgress size={58} progress={0.06} />
</Rotating>
)}
</ProgressWrapper>
<AnimationWrapper modelId={modelId}>
<Animation animation={getDeviceAnimation(modelId, type, "installLoading")} />
</AnimationWrapper>
<Footer>
<Title>
<Trans i18nKey="DeviceAction.installApp" values={{ appName }} />
</Title>
<SubTitle>
<Trans i18nKey="DeviceAction.installAppDescription" />
</SubTitle>
{cleanProgress ? <Title>{`${cleanProgress}%`}</Title> : null}
</Footer>
</Wrapper>
);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/FirebaseRemoteConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { initializeApp } from "firebase/app";
import { getRemoteConfig, fetchAndActivate, RemoteConfig } from "firebase/remote-config";
import { defaultFeatures } from "@ledgerhq/live-common/lib/featureFlags";
import { DefaultFeatures } from "@ledgerhq/live-common/lib/types";
import { reduce } from "lodash";
import { reduce, snakeCase } from "lodash";

import { getFirebaseConfig } from "~/firebase-setup";

export const FirebaseRemoteConfigContext = React.createContext<RemoteConfig | null>(null);

export const useFirebaseRemoteConfig = () => useContext(FirebaseRemoteConfigContext);

export const formatFeatureId = (id: string) => `feature_${id}`;
export const formatFeatureId = (id: string) => `feature_${snakeCase(id)}`;

// Firebase SDK treat JSON values as strings
const formatDefaultFeatures = (config: DefaultFeatures) =>
Expand Down

This file was deleted.

Loading

0 comments on commit 4f5cf98

Please sign in to comment.