Skip to content

Commit 456ad9a

Browse files
authored
Merge branch 'main' into lochie/metamask-sdk
2 parents 85100e7 + dcf2a41 commit 456ad9a

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

examples/testbench/src/components/Web3Provider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export const ckConfig = getDefaultConfig({
4141
appName: 'ConnectKit testbench',
4242
appIcon: '/app.png',
4343
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
44-
coinbaseWalletPreference: 'smartWalletOnly',
4544
});
4645
const customConfig = {
4746
...ckConfig,

examples/testbench/src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const languages: SelectProps[] = [
6464
{ label: 'Portuguese', value: 'pt-BR' },
6565
{ label: 'Russian', value: 'ru-RU' },
6666
{ label: 'Spanish', value: 'es-ES' },
67-
{ label: 'Turkish', value: 'tr-TR'},
67+
{ label: 'Turkish', value: 'tr-TR' },
6868
{ label: 'Vietnamese', value: 'vi-VN' },
6969
];
7070

packages/connectkit/src/components/Common/ConnectorList/index.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ import { ScrollArea } from '../../Common/ScrollArea';
1515
import Alert from '../Alert';
1616

1717
import { WalletProps, useWallets } from '../../../wallets/useWallets';
18-
import { isWalletConnectConnector } from '../../../utils';
18+
import {
19+
detectBrowser,
20+
isCoinbaseWalletConnector,
21+
isWalletConnectConnector,
22+
} from '../../../utils';
1923
import { useLastConnector } from '../../../hooks/useLastConnector';
24+
import { useConnect } from '../../../hooks/useConnect';
2025

2126
const ConnectorList = () => {
2227
const context = useContext();
@@ -78,6 +83,8 @@ const ConnectorItem = ({
7883
const isMobile = useIsMobile();
7984
const context = useContext();
8085

86+
const { connect } = useConnect();
87+
8188
/*
8289
const [ready, setReady] = useState(false);
8390
useEffect(() => {
@@ -89,12 +96,18 @@ const ConnectorItem = ({
8996
*/
9097

9198
let deeplink =
92-
!wallet.isInstalled && isMobile
99+
(!wallet.isInstalled && isMobile) ||
100+
(wallet.shouldDeeplinkDesktop && !isMobile)
93101
? wallet.getWalletConnectDeeplink?.(uri ?? '')
94102
: undefined;
95103

96104
const redirectToMoreWallets = isMobile && isWalletConnectConnector(wallet.id);
97-
if (redirectToMoreWallets) deeplink = undefined; // mobile redirects to more wallets page
105+
// Safari requires opening popup on user gesture, so we connect immediately here
106+
const shouldConnectImmediately =
107+
(detectBrowser() === 'safari' || detectBrowser() === 'ios') &&
108+
isCoinbaseWalletConnector(wallet.connector.id);
109+
110+
if (redirectToMoreWallets || shouldConnectImmediately) deeplink = undefined; // mobile redirects to more wallets page
98111

99112
return (
100113
<ConnectorButton
@@ -109,6 +122,9 @@ const ConnectorItem = ({
109122
if (redirectToMoreWallets) {
110123
context.setRoute(routes.MOBILECONNECTORS);
111124
} else {
125+
if (shouldConnectImmediately) {
126+
connect({ connector: wallet?.connector });
127+
}
112128
context.setRoute(routes.CONNECT);
113129
context.setConnector({ id: wallet.id });
114130
}

packages/connectkit/src/wallets/walletConfigs.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type WalletConfigProps = {
4040
};
4141
// Create URI for QR code, where uri is encoded data from WalletConnect
4242
getWalletConnectDeeplink?: (uri: string) => string;
43+
shouldDeeplinkDesktop?: boolean;
4344
};
4445

4546
// Organised in alphabetical order by key
@@ -353,6 +354,7 @@ export const walletConfigs: {
353354
? uri
354355
: `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
355356
},
357+
shouldDeeplinkDesktop: true,
356358
},
357359
zerion: {
358360
name: 'Zerion',

0 commit comments

Comments
 (0)