import React from "react"; import { NavLink } from "react-router"; import AppBar from '@mui/material/AppBar'; import Box from '@mui/material/Box'; import Toolbar from '@mui/material/Toolbar'; import Button from "@mui/material/Button"; import LoginIcon from "@mui/icons-material/Login"; import { Typography, Menu, MenuItem, IconButton, Avatar, Tooltip } from "@mui/material"; import useAuth from "~/hooks/useAuth"; import { signMessage } from './Metamask/Connections'; export default function ButtonAppBar() { const { auth, setAuth } = useAuth(); const account = auth?.accounts?.[0]; const isAuthed = Boolean(account); const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); const handleOpen = (e: React.MouseEvent) => setAnchorEl(e.currentTarget); const handleClose = () => setAnchorEl(null); const handleLogout = () => { if (setAuth) { setAuth({ providerWithInfo: undefined as any, accounts: [] } as any); } handleClose(); }; const register = async () => { const sig = await signMessage("H8zfXnSclIQ/wLy7GSt7GNqa1utAi4Uvr7Dg3p9vdHQ=",auth.providerWithInfo.provider, auth.accounts[0]); try { const res_string = sig; } catch (error) { console.error('Error:', error); } } return ( {} Home About {} {} {} {!isAuthed && ( )} {} {isAuthed && ( <> Register Logout )} ); }