-
Couldn't load subscription status.
- Fork 3
added ENS support #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| NEXT_PUBLIC_API_BASE_URL=http://localhost:3012 | ||
| NEXT_PUBLIC_PRIVY_APP_ID= | ||
| NEXT_PUBLIC_ETHEREUM_RPC= |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,42 +5,59 @@ import { LogOut } from "lucide-react"; | |
| import Image from "next/image"; | ||
| import Link from "next/link"; | ||
| import { Button } from "./ui/button"; | ||
| import { useEffect, useState } from "react"; | ||
| import { ethers } from "ethers"; | ||
|
|
||
| export const Navbar = () => { | ||
| const { user, logout } = usePrivy(); | ||
| const walletAddress = (user?.linkedAccounts as WalletWithMetadata[])?.find( | ||
| (a) => a.connectorType !== "embedded" | ||
| )?.address; | ||
| const { user, logout } = usePrivy(); | ||
| const walletAddress = (user?.linkedAccounts as WalletWithMetadata[])?.find( | ||
| (a) => a.connectorType !== "embedded" | ||
| )?.address; | ||
|
|
||
| // const { resolvedTheme } = useTheme(); | ||
| // const theme = resolvedTheme === "dark" ? "dark" : "light"; | ||
| const [ensName, setEnsName] = useState<string | null>(null); | ||
|
|
||
| return ( | ||
| <div className="flex justify-between flex-wrap p-6 px-4 m-auto w-full lg:w-[1500px]"> | ||
| <Link | ||
| href={"/"} | ||
| className="text-4xl font-bold select-none cursor-pointer" | ||
| > | ||
| <Image | ||
| src={"https://chess.stf.xyz/logo-white.svg"} | ||
| width={150} | ||
| height={150} | ||
| alt="dchess-logo" | ||
| /> | ||
| </Link> | ||
| <div className="flex gap-4 place-items-center"> | ||
| {!!walletAddress && ( | ||
| <div className="flex gap-4 items-center"> | ||
| <p className="font-mono"> | ||
| <b>AA Wallet:</b> {formatHash(user?.wallet?.address || "...")} | ||
| </p> | ||
| <Button onClick={logout} variant="outline" size="icon"> | ||
| <LogOut /> | ||
| </Button> | ||
| </div> | ||
| )} | ||
| {/* <ThemeToggle /> */} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
| const mainnetProvider = new ethers.providers.JsonRpcProvider(process.env.NEXT_PUBLIC_ETHEREUM_RPC); | ||
|
|
||
| useEffect(() => { | ||
| const resolveEnsName = async () => { | ||
| if (walletAddress) { | ||
| try { | ||
| const resolvedName = await mainnetProvider.lookupAddress(walletAddress); | ||
| setEnsName(resolvedName || formatHash(walletAddress)); | ||
| } catch (error) { | ||
| setEnsName(formatHash(walletAddress)); | ||
| } | ||
| } | ||
| }; | ||
| resolveEnsName(); | ||
| }, [walletAddress]); | ||
|
|
||
| return ( | ||
| <div className="flex justify-between flex-wrap p-6 px-4 m-auto w-full lg:w-[1500px]"> | ||
| <Link | ||
| href={"/"} | ||
| className="text-4xl font-bold select-none cursor-pointer" | ||
| > | ||
| <Image | ||
| src={"https://chess.stf.xyz/logo-white.svg"} | ||
| width={150} | ||
| height={150} | ||
| alt="dchess-logo" | ||
| /> | ||
| </Link> | ||
| <div className="flex gap-4 place-items-center"> | ||
| {!!walletAddress && ( | ||
| <div className="flex gap-4 items-center"> | ||
| <p className="font-mono"> | ||
| <b>AA Wallet:</b> {ensName || formatHash(walletAddress)} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Few changes here, the Since this wallet is |
||
| </p> | ||
| <Button onClick={logout} variant="outline" size="icon"> | ||
| <LogOut /> | ||
| </Button> | ||
| </div> | ||
| )} | ||
| {/* <ThemeToggle /> */} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
ethersis dep ingame. You might have to useviemor install this.