diff --git a/.changeset/slow-dingos-destroy.md b/.changeset/slow-dingos-destroy.md new file mode 100644 index 000000000000..93f3e2a4871e --- /dev/null +++ b/.changeset/slow-dingos-destroy.md @@ -0,0 +1,9 @@ +--- +"ledger-live-desktop": patch +"live-mobile": patch +"@ledgerhq/live-common": patch +--- + +fix(LLM): allow wallet-connect live-app to open a deep-link at any time + +Refactor by sharing a single constant for wallet-connect live-app manifest id diff --git a/apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts b/apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts index 0834195f8231..ba0631a9d6c5 100644 --- a/apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts +++ b/apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.ts @@ -19,6 +19,7 @@ import { useStorylyContext } from "~/storyly/StorylyProvider"; import { useNavigateToPostOnboardingHubCallback } from "~/renderer/components/PostOnboardingHub/logic/useNavigateToPostOnboardingHubCallback"; import { usePostOnboardingDeeplinkHandler } from "@ledgerhq/live-common/postOnboarding/hooks/index"; import { setDrawerVisibility as setLedgerSyncDrawerVisibility } from "../actions/walletSync"; +import { WC_ID } from "@ledgerhq/live-common/wallet-api/constants"; const getAccountsOrSubAccountsByCurrency = ( currency: CryptoOrTokenCurrency, @@ -315,8 +316,9 @@ export function useDeepLinkHandler() { } break; case "wc": { + const wcPathname = `/platform/${WC_ID}`; // Only prevent requests if already on the wallet connect live-app - if (location.pathname === "/platform/ledger-wallet-connect") { + if (location.pathname === wcPathname) { try { // Prevent a request from updating the live-app url and reloading it if (!query.uri || new URL(query.uri).searchParams.get("requestId")) { @@ -327,7 +329,7 @@ export function useDeepLinkHandler() { } } setTrackingSource("deeplink"); - navigate("/platform/ledger-wallet-connect", query); + navigate(wcPathname, query); break; } diff --git a/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx b/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx index d2e25a7714e0..4b90d1f8761b 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/account/AccountHeaderActions.tsx @@ -39,6 +39,7 @@ import { ManageAction } from "~/renderer/families/types"; import { getAvailableProviders } from "@ledgerhq/live-common/exchange/swap/index"; import { useFetchCurrencyAll } from "@ledgerhq/live-common/exchange/swap/hooks/index"; import { isWalletConnectSupported } from "@ledgerhq/live-common/walletConnect/index"; +import { WC_ID } from "@ledgerhq/live-common/wallet-api/constants"; type RenderActionParams = { label: React.ReactNode; @@ -137,7 +138,7 @@ const AccountHeaderSettingsButtonComponent = ({ account, parentAccount, openModa initialAccountId: mainAccount.id, }; history.push({ - pathname: "/platform/ledger-wallet-connect", + pathname: `/platform/${WC_ID}`, state: params, }); }, [mainAccount.id, history]); diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/WalletConnectLiveAppNavigator.tsx b/apps/ledger-live-mobile/src/components/RootNavigator/WalletConnectLiveAppNavigator.tsx index cd476c7839bc..4790d3b9e1f2 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/WalletConnectLiveAppNavigator.tsx +++ b/apps/ledger-live-mobile/src/components/RootNavigator/WalletConnectLiveAppNavigator.tsx @@ -10,8 +10,7 @@ import { LiveApp } from "~/screens/Platform"; import { uriSelector } from "~/reducers/walletconnect"; import { setWallectConnectUri } from "~/actions/walletconnect"; import { WalletConnectLiveAppNavigatorParamList } from "./types/WalletConnectLiveAppNavigator"; - -const PLATFORM = "ledger-wallet-connect"; +import { WC_ID } from "@ledgerhq/live-common/wallet-api/constants"; const options = { headerBackImage: () => ( @@ -48,7 +47,7 @@ export default function WalletConnectLiveAppNavigator() { key: _props.route.key, name: ScreenName.PlatformApp, params: { - platform: PLATFORM, + platform: WC_ID, uri: uri || _props.route.params?.uri, requestId: _props.route.params?.requestId, sessionTopic: _props.route.params?.sessionTopic, diff --git a/apps/ledger-live-mobile/src/components/Web3AppWebview/WalletAPIWebview.tsx b/apps/ledger-live-mobile/src/components/Web3AppWebview/WalletAPIWebview.tsx index 136d825b3783..d5d69a1a0ee2 100644 --- a/apps/ledger-live-mobile/src/components/Web3AppWebview/WalletAPIWebview.tsx +++ b/apps/ledger-live-mobile/src/components/Web3AppWebview/WalletAPIWebview.tsx @@ -5,7 +5,7 @@ import Config from "react-native-config"; import { WebviewAPI, WebviewProps } from "./types"; import { useWebView } from "./helpers"; import { NetworkError } from "./NetworkError"; -import { INTERNAL_APP_IDS } from "@ledgerhq/live-common/wallet-api/constants"; +import { INTERNAL_APP_IDS, WC_ID } from "@ledgerhq/live-common/wallet-api/constants"; import { useInternalAppIds } from "@ledgerhq/live-common/hooks/useInternalAppIds"; import { INJECTED_JAVASCRIPT } from "./dappInject"; import { NoAccountScreen } from "./NoAccountScreen"; @@ -41,7 +41,8 @@ export const WalletAPIWebview = forwardRef( const internalAppIds = useInternalAppIds() || INTERNAL_APP_IDS; - const javaScriptCanOpenWindowsAutomatically = internalAppIds.includes(manifest.id); + const javaScriptCanOpenWindowsAutomatically = + internalAppIds.includes(manifest.id) || manifest.id === WC_ID; if (!!manifest.dapp && noAccounts) { return ; diff --git a/apps/ledger-live-mobile/src/screens/Platform/v2/hooks.ts b/apps/ledger-live-mobile/src/screens/Platform/v2/hooks.ts index 58d7b6e67e7b..0653d7aad098 100644 --- a/apps/ledger-live-mobile/src/screens/Platform/v2/hooks.ts +++ b/apps/ledger-live-mobile/src/screens/Platform/v2/hooks.ts @@ -14,6 +14,7 @@ import { DAPP_DISCLAIMER_ID, DISCOVER_STORE_KEY, BROWSE_SEARCH_OPTIONS, + WC_ID, } from "@ledgerhq/live-common/wallet-api/constants"; import { DiscoverDB, AppManifest } from "@ledgerhq/live-common/wallet-api/types"; import { useNavigation, useRoute } from "@react-navigation/native"; @@ -100,8 +101,6 @@ export type Disclaimer = DisclaimerRaw & { openApp: (manifest: AppManifest) => void; }; -const WALLET_CONNECT_LIVE_APP = "ledger-wallet-connect"; - function useDisclaimer(appendRecentlyUsed: (manifest: AppManifest) => void): Disclaimer { const isReadOnly = useSelector(readOnlyModeEnabledSelector); const [isDismissed, dismiss] = useBanner(DAPP_DISCLAIMER_ID); @@ -117,7 +116,7 @@ function useDisclaimer(appendRecentlyUsed: (manifest: AppManifest) => void): Dis (manifest: AppManifest) => { // Navigate to the WalletConnect navigator screen instead of the discover one // In order to avoid issue with deeplinks opening wallet-connect multiple times - if (manifest.id === WALLET_CONNECT_LIVE_APP) { + if (manifest.id === WC_ID) { navigation.navigate(NavigatorName.WalletConnect, { screen: ScreenName.WalletConnectConnect, params: {}, diff --git a/libs/ledger-live-common/src/wallet-api/constants.ts b/libs/ledger-live-common/src/wallet-api/constants.ts index dec4009fd284..d5cf195b1f53 100644 --- a/libs/ledger-live-common/src/wallet-api/constants.ts +++ b/libs/ledger-live-common/src/wallet-api/constants.ts @@ -49,4 +49,6 @@ export const BUY_SELL_UI_APP_ID = "buy-sell-ui"; export const CARD_APP_ID = "card-program"; +export const WC_ID = "ledger-wallet-connect"; + export const INTERNAL_APP_IDS = [DEFAULT_MULTIBUY_APP_ID, BUY_SELL_UI_APP_ID, CARD_APP_ID];