1
- import type { NextPage } from 'next' ;
2
- import { useCallback } from 'react' ;
3
- import { useAccount , useConnect , useNetwork , useSignMessage } from 'wagmi' ;
1
+ import { NextPage } from 'next' ;
2
+ import { FC } from 'react' ;
3
+ import { useConnect , useAccount } from 'wagmi' ;
4
4
5
5
const Home : NextPage = ( ) => {
6
- const [ { data, error } , connect ] = useConnect ( ) ;
6
+ const [ { data : connectData , error : connectError } , connect ] = useConnect ( ) ;
7
+ const { connected } = connectData ;
7
8
const [ { data : accountData } , disconnect ] = useAccount ( {
8
9
fetchEns : true ,
9
10
} ) ;
10
- const { connected } = data ;
11
11
12
12
if ( connected ) {
13
13
return (
@@ -21,6 +21,7 @@ const Home: NextPage = () => {
21
21
>
22
22
Disconnect
23
23
</ button >
24
+ < InfoSection />
24
25
</ div >
25
26
) ;
26
27
}
@@ -30,7 +31,8 @@ const Home: NextPage = () => {
30
31
< h1 className = 'text-2xl font-bold' > Welcome to create-web3-frontend</ h1 >
31
32
< p className = 'mt-10' > Connect your wallet:</ p >
32
33
< div className = 'mt-5 flex justify-center gap-6' >
33
- { data . connectors . map ( ( x ) => (
34
+ { /* connectData.connectors contains the list of available 'connectors' like Metamask, WalletConnect, etc */ }
35
+ { connectData . connectors . map ( ( x ) => (
34
36
< button
35
37
className = 'rounded bg-slate-200 p-2'
36
38
key = { x . id }
@@ -42,9 +44,38 @@ const Home: NextPage = () => {
42
44
) ) }
43
45
</ div >
44
46
45
- { error && (
46
- < p className = 'text-red-500' > { error ?. message ?? 'Failed to connect' } </ p >
47
+ { connectError && (
48
+ < p className = 'text-red-500' >
49
+ { connectError ?. message ?? 'Failed to connect' }
50
+ </ p >
47
51
) }
52
+
53
+ < InfoSection />
54
+ </ div >
55
+ ) ;
56
+ } ;
57
+
58
+ const InfoSection : FC = ( ) => {
59
+ return (
60
+ < div className = 'mt-10' >
61
+ < hr className = 'my-4' />
62
+ < h2 className = 'text-xl font-bold' > If you need help</ h2 >
63
+ < div className = 'flex flex-col gap-2 mt-2' >
64
+ < a
65
+ href = 'https://wagmi.sh'
66
+ target = '_blank'
67
+ className = 'underline text-gray-600'
68
+ >
69
+ Link to wagmi docs
70
+ </ a >
71
+ < a
72
+ href = 'https://github.com/dhaiwat10/create-web3-frontend'
73
+ target = '_blank'
74
+ className = 'underline text-gray-600'
75
+ >
76
+ Open an issue on Github
77
+ </ a >
78
+ </ div >
48
79
</ div >
49
80
) ;
50
81
} ;
0 commit comments