Skip to content

Commit 29281c6

Browse files
authored
Add alert if network is not added in metamask (#283)
* Add alert if network is not added in metamask * Add changeset * Fix eslint errors
1 parent be483bd commit 29281c6

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

.changeset/four-apes-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web3-ui/hooks': minor
3+
---
4+
5+
Bug fixing for adding network to MetaMask

packages/hooks/src/hooks/useWallet.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,7 @@ export function useWallet() {
5151
// If it is not, then install it into the user's MetaMask
5252
// @ts-expect-error unknown error type
5353
if (error.code === 4902) {
54-
try {
55-
await window.ethereum.request({
56-
method: 'wallet_addEthereumChain',
57-
params: [
58-
{
59-
chainId: '0x61',
60-
rpcUrl: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
61-
},
62-
],
63-
});
64-
} catch (addError) {
65-
console.error(addError);
66-
}
54+
alert('Please add the network to your MetaMask');
6755
}
6856
}
6957
} else {

0 commit comments

Comments
 (0)