Skip to content

Commit

Permalink
Merge branch 'develop' into fix/fix-sell-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
sarneijim committed Oct 7, 2024
2 parents ffda9b9 + 51e227e commit 5e0adcb
Show file tree
Hide file tree
Showing 89 changed files with 2,608 additions and 542 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-bats-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/coin-tezos": patch
---

Tezos send full balance
13 changes: 13 additions & 0 deletions .changeset/curvy-hornets-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"ledger-live-desktop": minor
"live-mobile": minor
"@ledgerhq/icons-ui": minor
"@ledgerhq/types-live": patch
"@ledgerhq/native-ui": patch
---

ledger-live-desktop: Updated staking modal. Filtering per category. New copy and design
live-mobile: Updated staking modal. Filtering per category. New copy and design
@ledgerhq/icons-ui: Add book-graduation icon
@ledgerhq/types-live: Update schema of ethStakingProviders flag
@ledgerhq/native-ui: Add `xs` size to Button
6 changes: 6 additions & 0 deletions .changeset/fifty-rats-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/coin-algorand": patch
"@ledgerhq/coin-tezos": patch
---

Tezos send full balance and fix algorand format issue
6 changes: 6 additions & 0 deletions .changeset/heavy-peas-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

Add the platform OS to the params passed to earn to enable the correct braze environment
6 changes: 6 additions & 0 deletions .changeset/nice-plants-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"live-mobile": minor
"@ledgerhq/native-ui": minor
---

Add the receive flow `NeedMemoTagModal`
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 @@ -168,6 +168,11 @@ export const urls = {
editEvmTx: {
learnMore: "https://support.ledger.com/article/9756122596765-zd",
},
ledgerAcademy: {
whatIsEthereumRestaking: "https://www.ledger.com/academy/what-is-ethereum-restaking",
ethereumStakingHowToStakeEth:
"https://www.ledger.com/academy/ethereum-staking-how-to-stake-eth",
},
ledgerByFigmentTC:
"https://cdn.figment.io/legal/Current%20Ledger_Online%20Staking%20Delgation%20Services%20Agreement.pdf",
ens: "https://support.ledger.com/article/9710787581469-zd",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { getMainAccount } from "@ledgerhq/live-common/account/index";

import { useTranslation } from "react-i18next";
import { useHistory } from "react-router";
import { track } from "~/renderer/analytics/segment";
import { stakeDefaultTrack } from "~/renderer/screens/stake/constants";
import { BitcoinAccount } from "@ledgerhq/coin-bitcoin/lib/types";
import { TokenAccount } from "@ledgerhq/types-live";
import IconCoins from "~/renderer/icons/Coins";

type Props = {
account: BitcoinAccount | TokenAccount;
parentAccount: BitcoinAccount | undefined | null;
};

const AccountHeaderActions = ({ account, parentAccount }: Props) => {
const history = useHistory();
const { t } = useTranslation();
const mainAccount = getMainAccount(account, parentAccount);
const {
bitcoinResources,
currency: { id: currencyId },
} = mainAccount;
if (!bitcoinResources || parentAccount || currencyId !== "bitcoin") return null;

const stakeOnClick = () => {
const value = "/platform/acre";

track("button_clicked2", {
...stakeDefaultTrack,
delegation: "stake",
page: "Page Account",
button: "delegate",
provider: "Acre",
currency: "BTC",
});
history.push({
pathname: value,
state: {
accountId: account.id,
returnTo: `/account/${account.id}`,
},
});
};

return [
{
key: "Stake",
icon: IconCoins,
label: t("accounts.contextMenu.yield"),
event: "button_clicked2",
eventProperties: {
button: "stake",
},
onClick: stakeOnClick,
},
];
};

export default AccountHeaderActions;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import "./live-common-setup";
import sendAmountFields from "./SendAmountFields";
import sendRecipientFields from "./SendRecipientFields";
import StepReceiveFundsPostAlert from "./StepReceiveFundsPostAlert";
import accountHeaderManageActions from "./AccountHeaderManageActions";
import { BitcoinFamily } from "./types";

const family: BitcoinFamily = {
sendAmountFields,
sendRecipientFields,
StepReceiveFundsPostAlert,
accountHeaderManageActions,
};

export default family;
Original file line number Diff line number Diff line change
@@ -1,59 +1,26 @@
import { Flex, Text } from "@ledgerhq/react-ui";
import { Account } from "@ledgerhq/types-live";
import React, { useCallback, useState } from "react";
import { useHistory } from "react-router-dom";
import BigNumber from "bignumber.js";
import { useTranslation } from "react-i18next";

import { appendQueryParamsToDappURL } from "@ledgerhq/live-common/platform/utils/appendQueryParamsToDappURL";
import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
import { LiveAppManifest } from "@ledgerhq/live-common/platform/types";
import { appendQueryParamsToDappURL } from "@ledgerhq/live-common/platform/utils/appendQueryParamsToDappURL";
import { Flex } from "@ledgerhq/react-ui";
import { Account, EthStakingProvider } from "@ledgerhq/types-live";
import React, { useCallback } from "react";
import { useHistory } from "react-router-dom";
import { track } from "~/renderer/analytics/segment";
import CheckBox from "~/renderer/components/CheckBox";
import EthStakeIllustration from "~/renderer/icons/EthStakeIllustration";

import {
CheckBoxContainer,
LOCAL_STORAGE_KEY_PREFIX,
} from "~/renderer/modals/Receive/steps/StepReceiveStakingFlow";
import { ListProvider, ListProviders } from "./types";
import { ProviderItem } from "./component/ProviderItem";
import { getTrackProperties } from "./utils/getTrackProperties";

import ProviderItem from "./component/ProviderItem";

const ethMagnitude = getCryptoCurrencyById("ethereum").units[0].magnitude;

const ETH_LIMIT = BigNumber(32).times(BigNumber(10).pow(ethMagnitude));

// Comparison fns for sorting providers by minimum ETH required
const ascending = (a: ListProvider, b: ListProvider) => (a?.min || 0) - (b?.min || 0);
const descending = (a: ListProvider, b: ListProvider) => (b?.min || 0) - (a?.min || 0);

type Props = {
account: Account;
singleProviderRedirectMode?: boolean;
onClose?: () => void;
hasCheckbox?: boolean;
source?: string;
listProviders?: ListProviders;
providers: EthStakingProvider[];
};

export type StakeOnClickProps = {
provider: ListProvider;
provider: EthStakingProvider;
manifest: LiveAppManifest;
};

export function EthStakingModalBody({
hasCheckbox = false,
singleProviderRedirectMode = true,
source,
onClose,
account,
listProviders = [],
}: Props) {
const { t } = useTranslation();
export function EthStakingModalBody({ source, onClose, account, providers }: Props) {
const history = useHistory();
const [doNotShowAgain, setDoNotShowAgain] = useState<boolean>(false);

const stakeOnClick = useCallback(
({
Expand All @@ -66,6 +33,7 @@ export function EthStakingModalBody({
button: providerConfigID,
...getTrackProperties({ value, modal: source }),
});

history.push({
pathname: value,
...(customDappUrl ? { customDappUrl } : {}),
Expand All @@ -78,69 +46,13 @@ export function EthStakingModalBody({
[history, account.id, onClose, source],
);

const redirectIfOnlyProvider = useCallback(
(stakeOnClickProps: StakeOnClickProps) => {
if (singleProviderRedirectMode && listProviders.length === 1) {
stakeOnClick(stakeOnClickProps);
}
},
[singleProviderRedirectMode, listProviders.length, stakeOnClick],
);

const checkBoxOnChange = useCallback(() => {
const value = !doNotShowAgain;
global.localStorage.setItem(`${LOCAL_STORAGE_KEY_PREFIX}${account?.currency?.id}`, `${value}`);
setDoNotShowAgain(value);
track("button_clicked2", {
button: "not_show",
...getTrackProperties({ value, modal: source }),
});
}, [doNotShowAgain, account?.currency?.id, source]);

const hasMinValidatorEth = account.spendableBalance.isGreaterThan(ETH_LIMIT);

const listProvidersSorted = listProviders.sort(hasMinValidatorEth ? descending : ascending);

return (
<Flex flexDirection={"column"} alignItems="center" width={"100%"}>
<Flex flexDirection="column" alignItems="center" rowGap={16}>
<Text ff="Inter|SemiBold" fontSize="24px" lineHeight="32px">
{t("ethereum.stake.title")}
</Text>
{listProviders.length <= 1 && (
<Flex justifyContent="center" py={20} width="100%">
<EthStakeIllustration size={140} />
</Flex>
)}
<Text textAlign="center" color="neutral.c70" fontSize={14} maxWidth={360}>
{t("ethereum.stake.subTitle")}
</Text>
</Flex>
<Flex flexDirection={"column"} mt={5} px={20} width="100%">
<Flex flexDirection={"column"} width="100%">
{listProvidersSorted.map(item => (
<Flex key={item.id} width="100%" flexDirection={"column"}>
<ProviderItem
provider={item}
stakeOnClick={stakeOnClick}
redirectIfOnlyProvider={redirectIfOnlyProvider}
/>
</Flex>
))}
<Flex flexDirection="column" rowGap={2} width="100%">
{providers.map(x => (
<Flex key={x.id} flexDirection="column">
<ProviderItem provider={x} stakeOnClick={stakeOnClick} />
</Flex>
{hasCheckbox && (
<CheckBoxContainer
p={3}
borderRadius={8}
borderWidth={0}
width={"100%"}
onClick={checkBoxOnChange}
mt={15}
>
<CheckBox isChecked={doNotShowAgain} label={t("receive.steps.staking.notShow")} />
</CheckBoxContainer>
)}
</Flex>
))}
</Flex>
);
}
Loading

0 comments on commit 5e0adcb

Please sign in to comment.