File tree Expand file tree Collapse file tree 2 files changed +32
-27
lines changed Expand file tree Collapse file tree 2 files changed +32
-27
lines changed Original file line number Diff line number Diff line change 1
1
/** @format */
2
2
"use client";
3
- import { UNISAT, useLaserEyes } from "@omnisat/lasereyes";
3
+ import { useLaserEyes } from "@omnisat/lasereyes";
4
+ import { ConnectWallet } from "@/components/ConnectWallet";
4
5
5
6
export default function Home() {
6
- const { connect, address } = useLaserEyes();
7
+ const { address } = useLaserEyes();
7
8
8
9
return (
9
- <div className="grid grid-rows-[20px_1fr_20px] items-center justify-items- center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)] ">
10
- <div className="flex flex-col items-center gap-8 ">
11
- <h1 className="text-4xl font-bold text-center">
12
- Welcome to LaserEyes Template
13
- </h1 >
14
- <button
15
- onClick={() => connect(UNISAT)}
16
- className="px-6 py-3 text-lg font-medium text-white bg-black rounded-lg hover:bg-gray-800 transition-colors"
17
- >
18
- {address ? address : "Connect Wallet"}
19
- </button>
10
+ <div className="min-h-screen flex flex-col items-center justify-center gap-8 p-8 ">
11
+ <h1 className="text-4xl font-bold text-center ">
12
+ Welcome to LaserEyes Template
13
+ </h1>
14
+ <div className="flex flex-col items-center gap-4" >
15
+ <ConnectWallet />
16
+ {address && (
17
+ <div className="flex flex-col gap-2">
18
+ <p className="text-lg text-center">Connected Address: {address}</p >
19
+ </div>
20
+ )}
20
21
</div>
21
22
</div>
22
23
);
23
- }
24
+ }
Original file line number Diff line number Diff line change 1
1
/** @format */
2
2
3
+ "use client";
4
+
3
5
import { useLaserEyes, UNISAT } from "@omnisat/lasereyes";
4
6
import { Button } from "@/components/ui/button";
5
7
6
8
export function ConnectWallet() {
7
- const { connect, disconnect, connected, address } = useLaserEyes();
9
+ const { connect, disconnect, connected, hasUnisat } = useLaserEyes();
8
10
9
- const handleClick = () => {
10
- if (connected) {
11
- disconnect();
12
- } else {
13
- connect(UNISAT);
11
+ const handleConnect = async () => {
12
+ if (!hasUnisat) {
13
+ console.error("Please install Unisat wallet");
14
+ return;
14
15
}
16
+ await connect(UNISAT);
15
17
};
16
18
17
19
return (
18
- <Button onClick={handleClick} variant="outline" size="lg">
19
- {!connected ? (
20
- "Connect Wallet"
21
- ) : (
22
- <span className="truncate max-w-[200px]">{address}</span>
23
- )}
24
- </Button>
20
+ <div className="flex flex-col items-center gap-4">
21
+ <Button
22
+ onClick={connected ? disconnect : handleConnect}
23
+ variant="outline"
24
+ size="lg"
25
+ >
26
+ {connected ? "Disconnect" : "Connect Wallet"}
27
+ </Button>
28
+ </div>
25
29
);
26
30
}
You can’t perform that action at this time.
0 commit comments