-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWalletButton.js
More file actions
43 lines (41 loc) · 1.28 KB
/
WalletButton.js
File metadata and controls
43 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { useReady, useWallet, useConnect } from '../dappstate';
import { useSettingsContext } from '../settings.js';
import Button from '@material-ui/core/Button';
import Link from '@material-ui/core/Link';
import { useTheme } from '@material-ui/core/styles';
const WalletButton = (props) => {
const theme = useTheme();
const ready = useReady();
const wallet = useWallet();
const connect= useConnect();
const { settings } = useSettingsContext();
const handleConnect = React.useCallback(async () => {
try {
await connect(settings.network);
} catch (err) {
alert(err.message);
};
}, [connect]);
return ((ready) ? (
<div></div>
) :(wallet ? (
<Button variant="outlined"
color={theme.palette.text.primary}
onClick={handleConnect}>
connect to wallet
</Button>
):(
<Link href="https://templewallet.com/" rel="noopener" underline="none">
<Button variant="contained" disableElevation
style={{
backgroundColor: '#ed8936',
color: 'white',
fontWeight: 'bold',
}}>
install Temple
</Button>
</Link>
)));
}
export default WalletButton;