Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing projectId in "More" mobile button + remove wc legacy #364

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/connectkit/src/assets/logos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export const WalletConnect = ({ background = false, ...props }) => (
</svg>
);

export const WalletConnectLegacy = ({ background = false, ...props }) =>
WalletConnect({ background, ...props });

export const MetaMask = ({ background = false, ...props }) => (
<svg
{...props}
Expand Down Expand Up @@ -1276,7 +1273,6 @@ export default {
Injected,
OtherWallets,
WalletConnect,
WalletConnectLegacy,
MetaMask,
Coinbase,
Family,
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/src/hooks/useConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function useWalletConnectConnector() {
showQrModal: false,
}
*/
return useConnector('walletConnect') ?? useConnector('walletConnectLegacy');
return useConnector('walletConnect');
}
export function useCoinbaseWalletConnector() {
/*
Expand Down
33 changes: 20 additions & 13 deletions packages/connectkit/src/hooks/useWalletConnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,33 @@ export function useWalletConnectModal() {
w3mcss.innerHTML = `w3m-modal, wcm-modal{ --wcm-z-index: 2147483647; --w3m-z-index:2147483647; }`;
document.head.appendChild(w3mcss);

const clientConnector = connectors.find((c) =>
const clientConnector: Connector | undefined = connectors.find((c) =>
isWalletConnectConnector(c.id)
);

if (clientConnector) {
const connector: CreateConnectorFn = walletConnect({
projectId: '',
showQrModal: true,
});

setIsOpen(true);
try {
await connectAsync({ connector: connector });
const provider: any = await clientConnector.getProvider();
const projectId = provider.rpc.projectId;

const connector: CreateConnectorFn = walletConnect({
projectId,
showQrModal: true,
});

setIsOpen(true);
try {
await connectAsync({ connector: connector });
} catch (err) {
log('WalletConnect', err);
}
setIsOpen(false);

// remove modal styling
document.head.removeChild(w3mcss);
} catch (err) {
log('WalletConnect', err);
log('Could not get WalletConnect provider', err);
}
setIsOpen(false);

// remove modal styling
document.head.removeChild(w3mcss);
} else {
log('No WalletConnect connector available');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function flattenChildren(children: React.ReactNode): ReactChildArray {
}

export const isWalletConnectConnector = (connectorId?: string) =>
connectorId === 'walletConnect' || connectorId === 'walletConnectLegacy';
connectorId === 'walletConnect';

export const isMetaMaskConnector = (connectorId?: string) =>
connectorId === 'metaMask';
Expand Down
Loading