Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit c02e7b6

Browse files
committed
fix: fixes #92 shows unlock wallet when on the right network
1 parent 1118158 commit c02e7b6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

example/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import '@rsksmart/rif-ui/dist/index.css';
1616
import Routes from './Routes';
1717

18-
const requiredNetworkId = 8545
18+
const requiredNetworkId = 31
1919

2020
const App = () => {
2121

src/components/molecules/Account.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ const Account: FC<AccountProps> = ({
5555
const handleClose = (): void => setOpen(false)
5656
const handleOpen = (): void => setOpen(true)
5757

58+
const accountText = (): string => {
59+
if (!web3) return 'Connect wallet'
60+
61+
if (currentNetworkId !== requiredNetworkId) {
62+
return 'Wrong Network'
63+
}
64+
65+
if (account) {
66+
return shortenString(account)
67+
}
68+
return 'Unlock your wallet'
69+
}
70+
5871
return (
5972
<React.Fragment>
6073
<Button onClick={handleOpen} className={classes.button} variant="contained" color="primary" rounded>
@@ -71,10 +84,7 @@ const Account: FC<AccountProps> = ({
7184
)
7285
}
7386
<Typography className={classes.accountText}>
74-
{!web3 && 'Connect wallet'}
75-
{web3 && networkName}
76-
{web3 && !account && 'Wrong Network'}
77-
{web3 && account && shortenString(account)}
87+
{accountText()}
7888
</Typography>
7989
</Button>
8090

0 commit comments

Comments
 (0)