Skip to content

Commit

Permalink
Feat/llm cex deposit entry points (#4680)
Browse files Browse the repository at this point in the history
* chore(release): 🚀 prepare release [skip ci]

* chore(prerelease): 🚀 entering prerelease mode

* fix: add changeset

* chore(prerelease): 🚀 release prerelease [LLD(2.68.1-next.0), LLM(3.31.0)]

* Smartling on-demand translation delivery from release (#4651)

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to ar-AE locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to zh-CN locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to fr-FR locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to de-DE locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to ja-JP locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to ko-KR locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to pt-BR locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to ru-RU locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to es-ES locale

* File apps/ledger-live-desktop/static/i18n/en/app.json was translated to tr-TR locale

* chore: update RELEASE_NOTES

* chore(release): 🚀 prepare release [skip ci]

* feat(llm/llc/native-ui): added deposit from cex entry point on the select crypto screen

* undo some changes

* fixed type issues

* lint fixed

* lint fixed

* Add changeset

---------

Co-authored-by: live-github-bot[bot] <105061298+live-github-bot[bot]@users.noreply.github.com>
Co-authored-by: hzheng-ledger <[email protected]>
Co-authored-by: ldg-smartling-sa <[email protected]>
  • Loading branch information
4 people authored Sep 18, 2023
1 parent 6eea7de commit 8c1de2f
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-monkeys-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Add Entry point to CEX with feature flag
23 changes: 23 additions & 0 deletions apps/ledger-live-mobile/src/icons/Coinbase.tsx

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,8 @@
"account": "{{count}} account",
"account_plural": "{{count}} accounts",
"subtitle": "This must match the network chosen on the wallet or exchange transferring the crypto.",
"bannerTitle": "Make sure to select the right network. Learn how."
"bannerTitle": "Make sure to select the right network. Learn how.",
"depositFromCexBannerTitle": "Deposit crypto from your Coinbase account"
},
"stepperHeader": {
"range": "Step {{currentStep}} of {{totalSteps}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { getEnv } from "@ledgerhq/live-env";
import { findAccountByCurrency } from "../../logic/deposit";

import { useGroupedCurrenciesByProvider } from "@ledgerhq/live-common/deposit/index";
import DepositFromCoinbaseButton from "./DepositFromCoinbaseButton";
import { CexDepositEntryPointsLocationsMobile } from "@ledgerhq/types-live/lib/cexDeposit";

const SEARCH_KEYS = getEnv("CRYPTO_ASSET_SEARCH_KEYS");

Expand Down Expand Up @@ -114,6 +116,12 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
keyExtractor={keyExtractor}
showsVerticalScrollIndicator={false}
keyboardDismissMode="on-drag"
ListHeaderComponent={
<DepositFromCoinbaseButton
location={CexDepositEntryPointsLocationsMobile.selectCrypto}
source="Choose a crypto to secure"
/>
}
/>
),
[onPressItem],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";
import { Linking } from "react-native";
import { useTranslation } from "react-i18next";
import { Flex, BannerCard } from "@ledgerhq/native-ui";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { CexDepositEntryPointsLocationsMobile } from "@ledgerhq/types-live/lib/cexDeposit";
import { track } from "../../analytics";
import CoinbaseIcon from "../../icons/Coinbase";

type Props = {
location: CexDepositEntryPointsLocationsMobile;
source: string;
};
const DepositFromCoinbaseButton = ({ location, source }: Props) => {
const { t } = useTranslation();
const cexDepositEntryPointsMobile = useFeature("cexDepositEntryPointsMobile");

const onPressDepositFromCex = () => {
const path = cexDepositEntryPointsMobile?.params?.path;

if (path) {
Linking.canOpenURL(path).then(() => Linking.openURL(path));
track("button_clicked", {
button: "deposit from coinbase",
page: source,
});
}
};

if (
!cexDepositEntryPointsMobile?.enabled ||
!cexDepositEntryPointsMobile?.params?.locations?.[location] ||
!cexDepositEntryPointsMobile?.params?.path
) {
return null;
}

return (
<Flex mx={6} mb={3}>
<BannerCard
typeOfRightIcon="arrow"
title={t("transfer.receive.selectNetwork.depositFromCexBannerTitle")}
LeftElement={<CoinbaseIcon />}
hideLeftElementContainer
onPress={onPressDepositFromCex}
/>
</Flex>
);
};

export default DepositFromCoinbaseButton;
20 changes: 20 additions & 0 deletions libs/ledger-live-common/src/featureFlags/defaultFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,24 @@ export const DEFAULT_FEATURES: Features = {
"https://form.typeform.com/to/Jo7gqcB4?typeform-medium=embed-sdk&typeform-medium-version=next&typeform-embed=popup-blank",
},
},

cexDepositEntryPointsDesktop: {
enabled: false,
params: {
path: "/discover/ledger-cex-deposit",
locations: {
selectCrypto: true,
},
},
},

cexDepositEntryPointsMobile: {
enabled: false,
params: {
path: "/discover/ledger-cex-deposit",
locations: {
selectCrypto: true,
},
},
},
};
7 changes: 7 additions & 0 deletions libs/ledgerjs/packages/types-live/src/cexDeposit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum CexDepositEntryPointsLocationsDesktop {
selectCrypto = "selectCrypto",
}

export enum CexDepositEntryPointsLocationsMobile {
selectCrypto = "selectCrypto",
}
20 changes: 20 additions & 0 deletions libs/ledgerjs/packages/types-live/src/feature.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
CexDepositEntryPointsLocationsDesktop,
CexDepositEntryPointsLocationsMobile,
} from "./cexDeposit";
import { ChainwatchNetwork } from "./chainwatch";
import { StorylyInstanceID } from "./storyly";

Expand Down Expand Up @@ -169,6 +173,8 @@ export type Features = CurrencyFeatures & {
transactionsAlerts: Feature_TransactionsAlerts;
listAppsV2: Feature_ListAppsV2;
llmWalletQuickActions: Feature_LlmWalletQuickActions;
cexDepositEntryPointsDesktop: Feature_CexDepositEntryPointsDesktop;
cexDepositEntryPointsMobile: Feature_CexDepositEntryPointsMobile;
};

/**
Expand Down Expand Up @@ -415,6 +421,20 @@ export type Feature_RatingsPrompt = Feature<{
typeform_url: string;
}>;

export type Feature_CexDepositEntryPointsDesktop = Feature<{
path: string;
locations: {
[key in CexDepositEntryPointsLocationsDesktop]: boolean;
};
}>;

export type Feature_CexDepositEntryPointsMobile = Feature<{
path: string;
locations: {
[key in CexDepositEntryPointsLocationsMobile]: boolean;
};
}>;

export type Feature_LlmNewFirmwareUpdateUx = DefaultFeature;
export type Feature_CounterValue = DefaultFeature;
export type Feature_MockFeature = DefaultFeature;
Expand Down
1 change: 1 addition & 0 deletions libs/ledgerjs/packages/types-live/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from "./postOnboarding";
export * from "./storyly";
export * from "./chainwatch";
export * from "./messages";
export * from "./cexDeposit";
27 changes: 16 additions & 11 deletions libs/ui/packages/native/src/components/Cards/BannerCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type CardProps = TouchableOpacityProps & {
title?: string;
onPressDismiss?: () => void;
LeftElement?: JSX.Element;
hideLeftElementContainer?: boolean;
typeOfRightIcon: "arrow" | "close";
};

Expand Down Expand Up @@ -57,20 +58,24 @@ export const CloseButton = ({ onPressDismiss }: CloseProps) => {
};

const CardContainer = (props: CardProps): React.ReactElement => {
const { onPressDismiss, LeftElement, title, typeOfRightIcon } = props;
const { onPressDismiss, LeftElement, hideLeftElementContainer, title, typeOfRightIcon } = props;

return (
<Container {...props}>
<Flex
borderRadius={50}
height={40}
width={40}
alignItems="center"
justifyContent="center"
bg={"opacityDefault.c05"}
>
{LeftElement}
</Flex>
{hideLeftElementContainer ? (
<Flex
borderRadius={50}
height={40}
width={40}
alignItems="center"
justifyContent="center"
bg={"opacityDefault.c05"}
>
{LeftElement}
</Flex>
) : (
LeftElement
)}

<Text
mx={4}
Expand Down

1 comment on commit 8c1de2f

@vercel
Copy link

@vercel vercel bot commented on 8c1de2f Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.