From eb948ebab5339d6b7ff97e8590e1cea032ad4f67 Mon Sep 17 00:00:00 2001 From: Thomas Brillard Date: Mon, 13 Jan 2025 15:38:21 +0100 Subject: [PATCH] feat: Uniswap's term's of use (#8842) * feat: Uniswap's term's of use * feat: privacy policy * chore: generic solution * chore: moved all data to LLC and removed Maps * chore: tests * chore: use a common click handler to avoid arrows in jsx * chore: use a common click handler to avoid arrows in jsx 2 --- .changeset/afraid-falcons-eat.md | 5 ++ .../TransactionConfirm/ConfirmFooter.tsx | 74 +++++++++++++------ .../components/TransactionConfirm/index.tsx | 1 + .../static/i18n/en/app.json | 1 + .../src/exchange/providers/swap.ts | 14 ++++ 5 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 .changeset/afraid-falcons-eat.md diff --git a/.changeset/afraid-falcons-eat.md b/.changeset/afraid-falcons-eat.md new file mode 100644 index 000000000000..355db78c8acc --- /dev/null +++ b/.changeset/afraid-falcons-eat.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +feat: Uniswap's term's of use diff --git a/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/ConfirmFooter.tsx b/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/ConfirmFooter.tsx index 7b6113cb73b9..2bec780c6ebe 100644 --- a/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/ConfirmFooter.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/ConfirmFooter.tsx @@ -4,6 +4,11 @@ import { Trans, withTranslation } from "react-i18next"; import { getEnv } from "@ledgerhq/live-env"; import Text from "~/renderer/components/Text"; import { openURL } from "~/renderer/linking"; +import { + dexProvidersContractAddress, + privacyPolicy, + termsOfUse, +} from "@ledgerhq/live-common/exchange/providers/swap"; const HorizontalSeparator = styled.div` height: 1px; @@ -11,24 +16,24 @@ const HorizontalSeparator = styled.div` width: 100%; `; -const termsOfUse = new Map([ - ["paraswap", "https://paraswap.io/tos"], - ["1inch", "https://1inch.io/assets/1inch_network_terms_of_use.pdf"], -]); - if (getEnv("PLAYWRIGHT_RUN")) { - termsOfUse.set("dummy-live-app", "https://localhost.io/testtos"); + termsOfUse["dummy-live-app"] = "https://localhost.io/testtos"; } type Props = { footer: React.ReactNode | undefined; manifestId?: string | null; + transaction?: Transaction | null; manifestName?: string | null; }; -const ConfirmFooter = ({ footer, manifestId, manifestName }: Props) => { +const handleUrlClick = (url?: string) => () => url && openURL(url); + +const ConfirmFooter = ({ footer, transaction, manifestId, manifestName }: Props) => { if (!manifestId) return; - const termsOfUseUrl = termsOfUse.get(manifestId); + const appNameByAddr = dexProvidersContractAddress[transaction?.recipient || ""]; + const termsOfUseUrl = termsOfUse[appNameByAddr || manifestId]; + const privacyUrl = privacyPolicy[appNameByAddr || manifestId]; if (!termsOfUseUrl) return; return ( <> @@ -37,20 +42,45 @@ const ConfirmFooter = ({ footer, manifestId, manifestName }: Props) => { footer ) : ( - openURL(termsOfUseUrl)} - style={{ - cursor: "pointer", - textDecoration: "underline", - }} - />, - ]} - /> + {privacyUrl ? ( + , + , + ]} + /> + ) : ( + , + ]} + /> + )} )} diff --git a/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/index.tsx b/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/index.tsx index 0a23acfe4f4c..61effb690704 100644 --- a/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/TransactionConfirm/index.tsx @@ -208,6 +208,7 @@ const TransactionConfirm = ({ : null} + transaction={transaction} manifestId={manifestId} manifestName={manifestName} /> diff --git a/apps/ledger-live-desktop/static/i18n/en/app.json b/apps/ledger-live-desktop/static/i18n/en/app.json index d8a229d56ee5..bd32885fced4 100644 --- a/apps/ledger-live-desktop/static/i18n/en/app.json +++ b/apps/ledger-live-desktop/static/i18n/en/app.json @@ -5317,6 +5317,7 @@ "verifyData": "Always verify the operation details on your device.", "doubleCheck": "Double-check the transaction details on your Ledger device before signing.", "termsAndConditions": "By signing this transaction, you accept <0>{{appName}}'s terms of use.", + "termsAndConditionsWithPrivacy": "By signing this transaction, you accept <0>{{appName}}'s terms of use. and <1>Privacy Policy.", "warningWording": {}, "titleWording": { "send": "Please confirm on your device to finalize the operation", diff --git a/libs/ledger-live-common/src/exchange/providers/swap.ts b/libs/ledger-live-common/src/exchange/providers/swap.ts index e0a74c4bb671..84f66ef9182f 100644 --- a/libs/ledger-live-common/src/exchange/providers/swap.ts +++ b/libs/ledger-live-common/src/exchange/providers/swap.ts @@ -143,6 +143,20 @@ const DEFAULT_SWAP_PROVIDERS: Record