Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandoagf committed Jan 10, 2024
1 parent fd2b850 commit 60a4fa7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions modules/app/components/layout/header/AccountSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const AccountSelect = (): React.ReactElement => {
// Temporarily close the connections modal to move focus to the WalletConnect modal
handleModalToggle(connectionType, false);

// This is needed because of this issue https://github.com/MetaMask/metamask-extension/issues/3133
checkInjectedProvider();

await connection.connector.activate();

setSelectedConnection(connection.type);
Expand Down
10 changes: 5 additions & 5 deletions modules/web3/helpers/checkInjectedProvider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as env from 'detect-browser';
import { detect as detectBrowser } from 'detect-browser';
import { WindowPostMessageStream } from '@metamask/post-message-stream';
import { initializeProvider } from '@metamask/providers';

export function checkInjectedProvider() {
const injectedAvailable = !!window.ethereum;

if (!injectedAvailable) {
const browser = env.detect();
if (window.ethereum) {
return;
} else {
const browser = detectBrowser();
if (browser && browser.name === 'firefox') {
// Due to https://github.com/MetaMask/metamask-extension/issues/3133
// setup background connection
Expand Down
2 changes: 2 additions & 0 deletions modules/web3/hooks/useEagerlyConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { checkInjectedProvider } from '../helpers/checkInjectedProvider';

export async function connect(connector: Connector) {
try {
// This is needed because of this issue https://github.com/MetaMask/metamask-extension/issues/3133
checkInjectedProvider();

if (connector.connectEagerly) {
await connector.connectEagerly();
} else {
Expand Down

0 comments on commit 60a4fa7

Please sign in to comment.