From 44fb7b64887d59cad1330d286012164238a78e83 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Fri, 24 Jan 2025 16:03:23 +0200 Subject: [PATCH 1/7] feat: fix llm screen --- .../src/locales/en/common.json | 4 +- .../Settings/Developer/CustomManifest.tsx | 92 +++++++++++++------ 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/apps/ledger-live-mobile/src/locales/en/common.json b/apps/ledger-live-mobile/src/locales/en/common.json index 49b7e3e03f9..5f95d167f70 100644 --- a/apps/ledger-live-mobile/src/locales/en/common.json +++ b/apps/ledger-live-mobile/src/locales/en/common.json @@ -3112,7 +3112,7 @@ "title": "Developer", "desc": "Try out the Developer features and let us know what you think.", "customManifest": { - "title": "Load Custom Platform Manifest" + "title": "Load Manifest" }, "exchangeDeveloperMode": { "title": "Exchange Dev Mode", @@ -7162,4 +7162,4 @@ "title": "Select the blockchain network the asset belongs to" } } -} +} \ No newline at end of file diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx index a0ddb431bfa..42f43e33e90 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx @@ -1,9 +1,14 @@ import React, { useState, useCallback, useLayoutEffect } from "react"; -import { TextInput, StyleSheet, TouchableOpacity, TouchableOpacityProps } from "react-native"; +import { + TextInput, + StyleSheet, + TouchableOpacity, + TouchableOpacityProps, + Alert, +} from "react-native"; import { useTheme, CompositeScreenProps } from "@react-navigation/native"; import { useLocalLiveAppContext } from "@ledgerhq/live-common/wallet-api/LocalLiveAppProvider/index"; import { Box, Text } from "@ledgerhq/native-ui"; -import NavigationScrollView from "~/components/NavigationScrollView"; import { ScreenName } from "~/const"; import KeyboardView from "~/components/KeyboardView"; import ImportIcon from "~/icons/Import"; @@ -13,7 +18,6 @@ import type { StackNavigatorProps } from "~/components/RootNavigator/types/helpe import AppCard from "~/screens/Platform/Catalog/AppCard"; import Plus from "~/icons/Plus"; import Trash from "~/icons/Trash"; -import { DEFAULT_MANIFEST } from "./manifests/metamask"; import { LAGADO_MANIFEST, LAGADO_MANIFEST_BUST, LAGADO_MANIFEST_NOCACHE } from "./manifests/lagado"; import { ONEINCH_MANIFEST, @@ -26,6 +30,8 @@ import { HEADERS_MANIFEST_BUST, HEADERS_MANIFEST_NOCACHE, } from "./manifests/headerSniffer"; +import { ScrollView } from "react-native-gesture-handler"; +import Close from "~/icons/Close"; const DebuggerButton: React.ComponentType<{ onPress: TouchableOpacityProps["onPress"]; @@ -33,7 +39,7 @@ const DebuggerButton: React.ComponentType<{ }> = ({ onPress, text }) => { const { colors } = useTheme(); return ( - <> + {text && ( {text} @@ -42,7 +48,7 @@ const DebuggerButton: React.ComponentType<{ - + ); }; @@ -53,7 +59,19 @@ const AddButton: React.ComponentType<{ const { colors } = useTheme(); return ( - + + + ); +}; + +const DeleteTextButton: React.ComponentType<{ + onPress: TouchableOpacityProps["onPress"]; + disabled: boolean; +}> = ({ onPress, disabled }) => { + const { colors } = useTheme(); + return ( + + ); }; @@ -92,15 +110,24 @@ export default function CustomManifest({ navigation }: Props) { useLayoutEffect(() => { navigation.setOptions({ headerRight: () => ( - - onChange(JSON.stringify(JSON.parse(DEFAULT_MANIFEST)))} /> - + { - manifest !== null && addLocalManifest(JSON.parse(manifest)); setManifest(null); }} /> + { + try { + manifest !== null && addLocalManifest(JSON.parse(manifest)); + setManifest(null); + } catch (e) { + Alert.alert("Invalid JSON"); + } + }} + /> ), }); @@ -108,12 +135,13 @@ export default function CustomManifest({ navigation }: Props) { return ( - + <> - { - manifest !== null && addLocalManifest(JSON.parse(manifest)); - setManifest(null); - }} - /> - + + {"Example Manifests"} + + + <> + onChange(JSON.stringify(JSON.parse(LAGADO_MANIFEST)))} text="Lagado" @@ -140,16 +166,19 @@ export default function CustomManifest({ navigation }: Props) { onPress={() => onChange(JSON.stringify(JSON.parse(LAGADO_MANIFEST_BUST)))} text="Lagado cachebust" /> + + onChange(JSON.stringify(JSON.parse(LAGADO_MANIFEST_NOCACHE)))} text="Lagado nocache" /> - - + onChange(JSON.stringify(JSON.parse(ONEINCH_MANIFEST)))} text="1inch" /> + + onChange(JSON.stringify(JSON.parse(ONEINCH_MANIFEST_V3)))} text="1inch v3" @@ -158,16 +187,19 @@ export default function CustomManifest({ navigation }: Props) { onPress={() => onChange(JSON.stringify(JSON.parse(ONEINCH_MANIFEST_BUST)))} text="1inch cachebust" /> + + onChange(JSON.stringify(JSON.parse(ONEINCH_MANIFEST_NOCACHE)))} text="1inch nocache" /> - - + onChange(JSON.stringify(JSON.parse(HEADERS_MANIFEST)))} text="Headers Sniffer" /> + + onChange(JSON.stringify(JSON.parse(HEADERS_MANIFEST_BUST)))} text="Headers Sniffer cachebust" @@ -180,6 +212,11 @@ export default function CustomManifest({ navigation }: Props) { <> + {list.length > 0 && ( + + {"Loaded Manifests"} + + )} {list.map(m => { return ( @@ -208,7 +245,7 @@ export default function CustomManifest({ navigation }: Props) { ); })} - + ); } @@ -231,9 +268,12 @@ const styles = StyleSheet.create({ flex: 1, borderWidth: 1, marginBottom: 16, + height: 60, + marginHorizontal: 10, + padding: 5, }, buttons: { - paddingVertical: 8, - paddingHorizontal: 8, + paddingVertical: 12, + paddingHorizontal: 12, }, }); From 8b62628defde7d66fa29d2ac0bf9fcdb87437d8e Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Fri, 24 Jan 2025 16:14:57 +0200 Subject: [PATCH 2/7] chore: changeset --- .changeset/orange-drinks-explode.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/orange-drinks-explode.md diff --git a/.changeset/orange-drinks-explode.md b/.changeset/orange-drinks-explode.md new file mode 100644 index 00000000000..0a2fc1b54c3 --- /dev/null +++ b/.changeset/orange-drinks-explode.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +Fixes Add Custom Manifest screen From cd4a9f1e87047de8ce0431db7b6a259b75bdba39 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Mon, 27 Jan 2025 13:36:11 +0200 Subject: [PATCH 3/7] feat: add paste button --- apps/ledger-live-mobile/src/icons/Paste.tsx | 22 +++++++++++++++++++ .../Settings/Developer/CustomManifest.tsx | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 apps/ledger-live-mobile/src/icons/Paste.tsx diff --git a/apps/ledger-live-mobile/src/icons/Paste.tsx b/apps/ledger-live-mobile/src/icons/Paste.tsx new file mode 100644 index 00000000000..96972b1af65 --- /dev/null +++ b/apps/ledger-live-mobile/src/icons/Paste.tsx @@ -0,0 +1,22 @@ +import { props } from "lodash/fp"; +import * as React from "react"; +import Svg, { Path } from "react-native-svg"; + +interface PasteProps { + color: string; +} + +export default function Paste({ color }: PasteProps) { + return ( + + + + ); +} diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx index 42f43e33e90..79859c85b7e 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx @@ -32,6 +32,8 @@ import { } from "./manifests/headerSniffer"; import { ScrollView } from "react-native-gesture-handler"; import Close from "~/icons/Close"; +import Clipboard from "@react-native-clipboard/clipboard"; +import Paste from "~/icons/Paste"; const DebuggerButton: React.ComponentType<{ onPress: TouchableOpacityProps["onPress"]; @@ -76,6 +78,17 @@ const DeleteTextButton: React.ComponentType<{ ); }; +const PasteButton: React.ComponentType<{ + onPress: TouchableOpacityProps["onPress"]; +}> = ({ onPress }) => { + const { colors } = useTheme(); + return ( + + + + ); +}; + type Props = CompositeScreenProps< StackNavigatorProps, StackNavigatorProps @@ -111,6 +124,13 @@ export default function CustomManifest({ navigation }: Props) { navigation.setOptions({ headerRight: () => ( + { + const text = await Clipboard.getString(); + + setManifest(text); + }} + /> { From 27ecd582589e9dabcb26cbed3102669728cd2814 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Mon, 27 Jan 2025 14:08:06 +0200 Subject: [PATCH 4/7] chore: unused lib --- apps/ledger-live-mobile/src/icons/Paste.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/ledger-live-mobile/src/icons/Paste.tsx b/apps/ledger-live-mobile/src/icons/Paste.tsx index 96972b1af65..7b15622bc26 100644 --- a/apps/ledger-live-mobile/src/icons/Paste.tsx +++ b/apps/ledger-live-mobile/src/icons/Paste.tsx @@ -1,4 +1,3 @@ -import { props } from "lodash/fp"; import * as React from "react"; import Svg, { Path } from "react-native-svg"; From 30ccbb4095a3ec37426d08ed9aff7cd8218e2c0e Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Mon, 27 Jan 2025 15:40:29 +0200 Subject: [PATCH 5/7] chore: color --- .../src/screens/Settings/Developer/CustomManifest.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx index 79859c85b7e..573e3ad722d 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx @@ -167,6 +167,7 @@ export default function CustomManifest({ navigation }: Props) { value={manifest === null ? "" : manifest} onChangeText={onChange} placeholder="Paste your manifest json" + placeholderTextColor={"#a3a7ad"} multiline autoCorrect={false} scrollEnabled={false} From 55c948df5279b022a2728f88c4879f6dd7ab7088 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Wed, 29 Jan 2025 12:54:55 +0200 Subject: [PATCH 6/7] chore: code review --- apps/ledger-live-mobile/src/icons/Paste.tsx | 21 ------------------- .../Settings/Developer/CustomManifest.tsx | 11 ++++------ 2 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 apps/ledger-live-mobile/src/icons/Paste.tsx diff --git a/apps/ledger-live-mobile/src/icons/Paste.tsx b/apps/ledger-live-mobile/src/icons/Paste.tsx deleted file mode 100644 index 7b15622bc26..00000000000 --- a/apps/ledger-live-mobile/src/icons/Paste.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as React from "react"; -import Svg, { Path } from "react-native-svg"; - -interface PasteProps { - color: string; -} - -export default function Paste({ color }: PasteProps) { - return ( - - - - ); -} diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx index 573e3ad722d..bedf4eb9c5c 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx @@ -8,7 +8,7 @@ import { } from "react-native"; import { useTheme, CompositeScreenProps } from "@react-navigation/native"; import { useLocalLiveAppContext } from "@ledgerhq/live-common/wallet-api/LocalLiveAppProvider/index"; -import { Box, Text } from "@ledgerhq/native-ui"; +import { Box, Icons, Text } from "@ledgerhq/native-ui"; import { ScreenName } from "~/const"; import KeyboardView from "~/components/KeyboardView"; import ImportIcon from "~/icons/Import"; @@ -16,7 +16,6 @@ import type { SettingsNavigatorStackParamList } from "~/components/RootNavigator import type { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator"; import type { StackNavigatorProps } from "~/components/RootNavigator/types/helpers"; import AppCard from "~/screens/Platform/Catalog/AppCard"; -import Plus from "~/icons/Plus"; import Trash from "~/icons/Trash"; import { LAGADO_MANIFEST, LAGADO_MANIFEST_BUST, LAGADO_MANIFEST_NOCACHE } from "./manifests/lagado"; import { @@ -31,9 +30,7 @@ import { HEADERS_MANIFEST_NOCACHE, } from "./manifests/headerSniffer"; import { ScrollView } from "react-native-gesture-handler"; -import Close from "~/icons/Close"; import Clipboard from "@react-native-clipboard/clipboard"; -import Paste from "~/icons/Paste"; const DebuggerButton: React.ComponentType<{ onPress: TouchableOpacityProps["onPress"]; @@ -61,7 +58,7 @@ const AddButton: React.ComponentType<{ const { colors } = useTheme(); return ( - + ); }; @@ -73,7 +70,7 @@ const DeleteTextButton: React.ComponentType<{ const { colors } = useTheme(); return ( - + ); }; @@ -84,7 +81,7 @@ const PasteButton: React.ComponentType<{ const { colors } = useTheme(); return ( - + ); }; From 6a07b07f15d8ad58e301c7bf7e62083c5bf0442e Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Wed, 29 Jan 2025 14:04:03 +0200 Subject: [PATCH 7/7] chore: review --- .changeset/orange-drinks-explode.md | 2 +- .../Settings/Developer/manifests/metamask.ts | 54 ------------------- 2 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 apps/ledger-live-mobile/src/screens/Settings/Developer/manifests/metamask.ts diff --git a/.changeset/orange-drinks-explode.md b/.changeset/orange-drinks-explode.md index 0a2fc1b54c3..431d693f1c2 100644 --- a/.changeset/orange-drinks-explode.md +++ b/.changeset/orange-drinks-explode.md @@ -1,5 +1,5 @@ --- -"live-mobile": patch +"live-mobile": minor --- Fixes Add Custom Manifest screen diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/manifests/metamask.ts b/apps/ledger-live-mobile/src/screens/Settings/Developer/manifests/metamask.ts deleted file mode 100644 index 8f6b5ffa412..00000000000 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/manifests/metamask.ts +++ /dev/null @@ -1,54 +0,0 @@ -export const DEFAULT_MANIFEST = `{ - "id": "metamask-test-dapsp", - "name": "Metamask Test Dapp", - "private": false, - "url": "https://metamask.github.io/test-dapp/", - "dapp": { - "networks": [ - { - "currency": "ethereum", - "chainID": 1, - "nodeURL": "https://eth-dapps.api.live.ledger.com" - }, - { - "currency": "bsc", - "chainID": 56, - "nodeURL": "https://bsc-dataseed.binance.org/" - }, - { - "currency": "polygon", - "chainID": 137, - "nodeURL": "https://polygon-mainnet.g.alchemy.com/v2/oPIxZM7kXsPVVY1Sk0kOQwkoIOpSu8PE" - }, - { - "currency": "arbitrum", - "chainID": 42161, - "nodeURL": "https://arb1.arbitrum.io/rpc" - }, - { - "currency": "optimism", - "chainID": 10, - "nodeURL": "https://mainnet.optimism.io" - } - ] - }, - "homepageUrl": "https://metamask.github.io/test-dapp/", - "icon": "https://cdn.live.ledger.com/icons/platform/1inch.png", - "platforms": ["android", "ios", "desktop"], - "apiVersion": "^2.0.0", - "manifestVersion": "1", - "branch": "stable", - "categories": ["tools"], - "currencies": ["ethereum", "bsc", "polygon", "arbitrum", "optimism"], - "content": { - "shortDescription": { - "en": "Metamask Test Dapp" - }, - "description": { - "en": "Metamask Test Dapp" - } - }, - "permissions": [], - "domains": ["http://", "https://"], - "visibility": "complete" -}`;