Skip to content

Commit

Permalink
Merge branch 'main' into lochie/metamask-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
lochie authored Jun 14, 2024
2 parents 85100e7 + dcf2a41 commit 456ad9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 0 additions & 1 deletion examples/testbench/src/components/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/testbench/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
];

Expand Down
22 changes: 19 additions & 3 deletions packages/connectkit/src/components/Common/ConnectorList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -78,6 +83,8 @@ const ConnectorItem = ({
const isMobile = useIsMobile();
const context = useContext();

const { connect } = useConnect();

/*
const [ready, setReady] = useState(false);
useEffect(() => {
Expand All @@ -89,12 +96,18 @@ const ConnectorItem = ({
*/

let deeplink =
!wallet.isInstalled && isMobile
(!wallet.isInstalled && isMobile) ||
(wallet.shouldDeeplinkDesktop && !isMobile)
? wallet.getWalletConnectDeeplink?.(uri ?? '')
: 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 (
<ConnectorButton
Expand All @@ -109,6 +122,9 @@ const ConnectorItem = ({
if (redirectToMoreWallets) {
context.setRoute(routes.MOBILECONNECTORS);
} else {
if (shouldConnectImmediately) {
connect({ connector: wallet?.connector });
}
context.setRoute(routes.CONNECT);
context.setConnector({ id: wallet.id });
}
Expand Down
2 changes: 2 additions & 0 deletions packages/connectkit/src/wallets/walletConfigs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -353,6 +354,7 @@ export const walletConfigs: {
? uri
: `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
},
shouldDeeplinkDesktop: true,
},
zerion: {
name: 'Zerion',
Expand Down

0 comments on commit 456ad9a

Please sign in to comment.