Skip to content

Commit

Permalink
feat: Uniswap's term's of use (#8842)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CremaFR authored Jan 13, 2025
1 parent 30415c3 commit eb948eb
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-falcons-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

feat: Uniswap's term's of use
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,36 @@ 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;
background: ${p => p.theme.colors.palette.text.shade20};
width: 100%;
`;

const termsOfUse = new Map<string, string>([
["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 (
<>
Expand All @@ -37,20 +42,45 @@ const ConfirmFooter = ({ footer, manifestId, manifestName }: Props) => {
footer
) : (
<Text marginTop={30} data-testid="confirm-footer-toc">
<Trans
i18nKey="TransactionConfirm.termsAndConditions"
values={{ appName: manifestName || manifestId }}
components={[
<Text
key={manifestId}
onClick={() => openURL(termsOfUseUrl)}
style={{
cursor: "pointer",
textDecoration: "underline",
}}
/>,
]}
/>
{privacyUrl ? (
<Trans
i18nKey="TransactionConfirm.termsAndConditionsWithPrivacy"
values={{ appName: appNameByAddr || manifestName || manifestId }}
components={[
<Text
key={manifestId}
onClick={handleUrlClick(termsOfUseUrl)}
style={{
cursor: "pointer",
textDecoration: "underline",
}}
/>,
<Text
key={manifestId + "1"}
onClick={handleUrlClick(privacyUrl)}
style={{
cursor: "pointer",
textDecoration: "underline",
}}
/>,
]}
/>
) : (
<Trans
i18nKey="TransactionConfirm.termsAndConditions"
values={{ appName: appNameByAddr || manifestName || manifestId }}
components={[
<Text
key={manifestId}
onClick={handleUrlClick(termsOfUseUrl)}
style={{
cursor: "pointer",
textDecoration: "underline",
}}
/>,
]}
/>
)}
</Text>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const TransactionConfirm = ({
</Container>
<ConfirmFooter
footer={Footer ? <Footer transaction={transaction} /> : null}
transaction={transaction}
manifestId={manifestId}
manifestName={manifestName}
/>
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.</0>",
"termsAndConditionsWithPrivacy": "By signing this transaction, you accept <0>{{appName}}'s terms of use.</0> and <1>Privacy Policy.</1>",
"warningWording": {},
"titleWording": {
"send": "Please confirm on your device to finalize the operation",
Expand Down
14 changes: 14 additions & 0 deletions libs/ledger-live-common/src/exchange/providers/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ const DEFAULT_SWAP_PROVIDERS: Record<string, ProviderConfig & Partial<Additional
},
};

export const dexProvidersContractAddress: { [key: string]: string } = {
"0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD": "Uniswap",
};

export const termsOfUse: { [key: string]: string } = {
paraswap: "https://paraswap.io/tos",
"1inch": "https://1inch.io/assets/1inch_network_terms_of_use.pdf",
Uniswap: "https://uniswap.org/terms-of-service",
};

export const privacyPolicy: { [key: string]: string } = {
Uniswap: "https://uniswap.org/privacy-policy",
};

type CurrencyData = {
id: string;
config: string;
Expand Down

0 comments on commit eb948eb

Please sign in to comment.