Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Uniswap's term's of use #8842

Merged
merged 7 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading