Skip to content

Commit c90dd2e

Browse files
author
AugustoL
committed
fix(wallet-connectors): Fix wallet recognitions and connectors used, use injected by default
1 parent a702019 commit c90dd2e

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/components/Web3ConnectStatus/index.jsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
injected,
1010
isChainIdSupported,
1111
web3ContextNames,
12+
walletconnect
1213
} from 'provider/connectors';
1314
import Identicon from '../Identicon';
1415
import { useStores } from '../../contexts/storesContext';
@@ -84,24 +85,20 @@ const Web3ConnectStatus = observer((props) => {
8485
const {
8586
chainId,
8687
active,
88+
account,
8789
connector,
8890
error,
8991
} = providerStore.getActiveWeb3React();
90-
const { account, chainId: injectedChainId } = providerStore.getWeb3React(
91-
web3ContextNames.injected
92-
);
93-
94-
const contextNetwork = providerStore.getWeb3React(web3ContextNames.backup);
9592

9693
if (!chainId) {
9794
throw new Error('No chain ID specified');
9895
}
99-
96+
10097
let pending = undefined;
10198
let confirmed = undefined;
10299
let hasPendingTransactions = false;
103100

104-
if (account && isChainIdSupported(injectedChainId)) {
101+
if (account && isChainIdSupported(chainId)) {
105102
pending = transactionStore.getPendingTransactions(account);
106103
confirmed = transactionStore.getConfirmedTransactions(account);
107104
hasPendingTransactions = !!pending.length;
@@ -115,17 +112,19 @@ const Web3ConnectStatus = observer((props) => {
115112
function getStatusIcon() {
116113
if (connector === injected) {
117114
return <Identicon />;
115+
} else if (connector === walletconnect) {
116+
return <img src="walletConnectIcon.svg" />;
118117
}
119118
}
120119

121120
function getWeb3Status() {
122121
console.log('[GetWeb3Status]', {
123122
account,
124-
injectedChainId: injectedChainId,
123+
chainId: chainId,
125124
error,
126125
});
127126
// Wrong network
128-
if (account && !isChainIdSupported(injectedChainId)) {
127+
if (account && !isChainIdSupported(chainId)) {
129128
return (
130129
<WrongNetworkButton onClick={toggleWalletModal}>
131130
Wrong Network
@@ -157,10 +156,6 @@ const Web3ConnectStatus = observer((props) => {
157156
}
158157
}
159158

160-
if (!contextNetwork.active && !active) {
161-
return null;
162-
}
163-
164159
return (
165160
<>
166161
{getWeb3Status()}

src/provider/connectors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NetworkConnector } from 'provider/NetworkConnector';
22
import { MetamaskConnector } from './MetamaskConnector';
3+
import { InjectedConnector } from '@web3-react/injected-connector'
34
import { WalletConnectConnector } from '@web3-react/walletconnect-connector';
45

56
export const INFURA_API_KEY = process.env.REACT_APP_KEY_INFURA_API_KEY;
@@ -56,7 +57,7 @@ export const backup = new NetworkConnector({
5657
pollingInterval: POLLING_INTERVAL,
5758
});
5859

59-
export const injected = new MetamaskConnector({
60+
export const injected = new InjectedConnector({
6061
supportedChainIds: [1, 3, 4, 42, 66],
6162
});
6263

0 commit comments

Comments
 (0)