From 2b1af01dc4d183bfe99a7840ccaf605b4d187abc Mon Sep 17 00:00:00 2001 From: katspaugh Date: Wed, 1 Nov 2023 12:04:35 +0100 Subject: [PATCH] Redirect WC Safe App to open popup --- src/pages/apps/open.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/apps/open.tsx b/src/pages/apps/open.tsx index 1c83cdd96b..1c669c9ab5 100644 --- a/src/pages/apps/open.tsx +++ b/src/pages/apps/open.tsx @@ -1,6 +1,6 @@ import type { NextPage } from 'next' import { useRouter } from 'next/router' -import { useCallback } from 'react' +import { useCallback, useContext } from 'react' import { Box, CircularProgress } from '@mui/material' import { useSafeAppUrl } from '@/hooks/safe-apps/useSafeAppUrl' @@ -15,6 +15,10 @@ import { useBrowserPermissions } from '@/hooks/safe-apps/permissions' import useChainId from '@/hooks/useChainId' import { AppRoutes } from '@/config/routes' import { getOrigin } from '@/components/safe-apps/utils' +import { WalletConnectContext } from '@/services/walletconnect/WalletConnectContext' + +// TODO: Remove this once we properly deprecate the WC app +const WC_SAFE_APP = /wallet-connect/ const SafeApps: NextPage = () => { const chainId = useChainId() @@ -42,6 +46,8 @@ const SafeApps: NextPage = () => { remoteSafeAppsLoading, }) + const { setOpen } = useContext(WalletConnectContext) + const goToList = useCallback(() => { router.push({ pathname: AppRoutes.apps.index, @@ -52,6 +58,12 @@ const SafeApps: NextPage = () => { // appUrl is required to be present if (!appUrl || !router.isReady) return null + if (WC_SAFE_APP.test(appUrl)) { + setOpen(true) + goToList() + return null + } + if (isModalVisible) { return (