Skip to content

Commit

Permalink
Fix: a more accurate WC app detection (#3155)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Jan 29, 2024
1 parent 4cd8a3d commit d7e5365
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/pages/apps/open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import { getOrigin } from '@/components/safe-apps/utils'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'
import { openWalletConnect } from '@/features/walletconnect/components'

// TODO: Remove this once we properly deprecate the WC app
const WC_SAFE_APP = /wallet-connect/
import { isWalletConnectSafeApp } from '@/utils/gateway'

const SafeApps: NextPage = () => {
const chainId = useChainId()
Expand Down Expand Up @@ -60,7 +58,7 @@ const SafeApps: NextPage = () => {
// appUrl is required to be present
if (!isSafeAppsEnabled || !appUrl || !router.isReady) return null

if (isWalletConnectEnabled && WC_SAFE_APP.test(appUrl)) {
if (isWalletConnectEnabled && isWalletConnectSafeApp(appUrl)) {
openWalletConnect()
goToList()
return null
Expand Down
2 changes: 1 addition & 1 deletion src/services/analytics/__tests__/tx-tracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('getTransactionTrackingType', () => {
type: TransactionInfoType.CUSTOM,
},
safeAppInfo: {
url: 'https://safe-apps.safe.global/wallet-connect',
url: 'https://apps-portal.safe.global/wallet-connect',
},
} as unknown)

Expand Down
7 changes: 5 additions & 2 deletions src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const getExplorerLink = (
}

export const isWalletConnectSafeApp = (url: string): boolean => {
const WALLET_CONNECT = /wallet-connect/
return WALLET_CONNECT.test(url)
const WC_APP_URLS = [
'https://apps-portal.safe.global/wallet-connect',
'https://safe-apps.dev.5afe.dev/wallet-connect',
]
return WC_APP_URLS.includes(url)
}

0 comments on commit d7e5365

Please sign in to comment.