From 3e5c9bfd60eb87e496468609707084d598033931 Mon Sep 17 00:00:00 2001 From: Lochie Axon Date: Sat, 15 Jun 2024 02:29:12 +1000 Subject: [PATCH 1/2] fix: blocked cbw mobile popup (#398) * raw connect button * direct connect in page * remove false * connect immediately * Update index.tsx * Update index.tsx * safari only * ios + safari --- .../testbench/src/components/Web3Provider.tsx | 1 - examples/testbench/src/pages/index.tsx | 2 +- .../components/Common/ConnectorList/index.tsx | 19 +++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/testbench/src/components/Web3Provider.tsx b/examples/testbench/src/components/Web3Provider.tsx index 6986a22c..82622c1e 100644 --- a/examples/testbench/src/components/Web3Provider.tsx +++ b/examples/testbench/src/components/Web3Provider.tsx @@ -41,7 +41,6 @@ export const ckConfig = getDefaultConfig({ appName: 'ConnectKit testbench', appIcon: '/app.png', walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!, - coinbaseWalletPreference: 'smartWalletOnly', }); const customConfig = { ...ckConfig, diff --git a/examples/testbench/src/pages/index.tsx b/examples/testbench/src/pages/index.tsx index 013784a5..86231e32 100644 --- a/examples/testbench/src/pages/index.tsx +++ b/examples/testbench/src/pages/index.tsx @@ -64,7 +64,7 @@ const languages: SelectProps[] = [ { label: 'Portuguese', value: 'pt-BR' }, { label: 'Russian', value: 'ru-RU' }, { label: 'Spanish', value: 'es-ES' }, - { label: 'Turkish', value: 'tr-TR'}, + { label: 'Turkish', value: 'tr-TR' }, { label: 'Vietnamese', value: 'vi-VN' }, ]; diff --git a/packages/connectkit/src/components/Common/ConnectorList/index.tsx b/packages/connectkit/src/components/Common/ConnectorList/index.tsx index 4af6e9af..9a0a7b49 100644 --- a/packages/connectkit/src/components/Common/ConnectorList/index.tsx +++ b/packages/connectkit/src/components/Common/ConnectorList/index.tsx @@ -15,8 +15,13 @@ import { ScrollArea } from '../../Common/ScrollArea'; import Alert from '../Alert'; import { WalletProps, useWallets } from '../../../wallets/useWallets'; -import { isWalletConnectConnector } from '../../../utils'; +import { + detectBrowser, + isCoinbaseWalletConnector, + isWalletConnectConnector, +} from '../../../utils'; import { useLastConnector } from '../../../hooks/useLastConnector'; +import { useConnect } from '../../../hooks/useConnect'; const ConnectorList = () => { const context = useContext(); @@ -78,6 +83,8 @@ const ConnectorItem = ({ const isMobile = useIsMobile(); const context = useContext(); + const { connect } = useConnect(); + /* const [ready, setReady] = useState(false); useEffect(() => { @@ -94,7 +101,12 @@ const ConnectorItem = ({ : undefined; const redirectToMoreWallets = isMobile && isWalletConnectConnector(wallet.id); - if (redirectToMoreWallets) deeplink = undefined; // mobile redirects to more wallets page + // Safari requires opening popup on user gesture, so we connect immediately here + const shouldConnectImmediately = + (detectBrowser() === 'safari' || detectBrowser() === 'ios') && + isCoinbaseWalletConnector(wallet.connector.id); + + if (redirectToMoreWallets || shouldConnectImmediately) deeplink = undefined; // mobile redirects to more wallets page return ( Date: Fri, 14 Jun 2024 13:36:40 -0300 Subject: [PATCH 2/2] fix: deeplinks for desktop apps (#392) Co-authored-by: Lochie Axon --- .../connectkit/src/components/Common/ConnectorList/index.tsx | 3 ++- packages/connectkit/src/wallets/walletConfigs.tsx | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/connectkit/src/components/Common/ConnectorList/index.tsx b/packages/connectkit/src/components/Common/ConnectorList/index.tsx index 9a0a7b49..436c21d5 100644 --- a/packages/connectkit/src/components/Common/ConnectorList/index.tsx +++ b/packages/connectkit/src/components/Common/ConnectorList/index.tsx @@ -96,7 +96,8 @@ const ConnectorItem = ({ */ let deeplink = - !wallet.isInstalled && isMobile + (!wallet.isInstalled && isMobile) || + (wallet.shouldDeeplinkDesktop && !isMobile) ? wallet.getWalletConnectDeeplink?.(uri ?? '') : undefined; diff --git a/packages/connectkit/src/wallets/walletConfigs.tsx b/packages/connectkit/src/wallets/walletConfigs.tsx index 520f44e2..080c8f2b 100644 --- a/packages/connectkit/src/wallets/walletConfigs.tsx +++ b/packages/connectkit/src/wallets/walletConfigs.tsx @@ -40,6 +40,7 @@ export type WalletConfigProps = { }; // Create URI for QR code, where uri is encoded data from WalletConnect getWalletConnectDeeplink?: (uri: string) => string; + shouldDeeplinkDesktop?: boolean; }; // Organised in alphabetical order by key @@ -353,6 +354,7 @@ export const walletConfigs: { ? uri : `ledgerlive://wc?uri=${encodeURIComponent(uri)}`; }, + shouldDeeplinkDesktop: true, }, zerion: { name: 'Zerion',