notifications for pending exoduses and signed messages added

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-11-23 13:02:05 +03:00
parent 852d3c86ce
commit 55988858d9
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
2 changed files with 45 additions and 6 deletions

View File

@ -1,7 +1,7 @@
{
"name": "ghost-dao-interface",
"private": true,
"version": "0.8.28",
"version": "0.8.29",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -1,4 +1,6 @@
import { useMemo, useEffect } from "react";
import useSWR from "swr";
import toast from "react-hot-toast";
import { useMemo, useEffect, useState } from "react";
import "./Sidebar.scss";
@ -15,7 +17,7 @@ import {
AccordionDetails,
} from "@mui/material";
import { styled } from "@mui/material/styles";
import { NavLink } from "react-router-dom";
import { NavLink, useLocation } from "react-router-dom";
import { useSwitchChain } from "wagmi";
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
@ -59,6 +61,7 @@ import WifiProtectedSetupIcon from '@mui/icons-material/WifiProtectedSetup';
import { useTokenSymbol } from "../../hooks/tokens";
import { useLiveBonds } from "../../hooks/bonds/index";
import { useLocalStorage } from "../../hooks/localstorage";
import { useUnstableProvider } from "../../hooks/ghost";
import pckg from "../../../package.json"
const PREFIX = "NavContent";
@ -74,12 +77,18 @@ const StyledBox = styled(Box)(({ theme }) => ({
}));
const NavContent = ({ chainId, addressChainId, address }) => {
const location = useLocation();
const { chains } = useSwitchChain();
const chainName = useMemo(() => {
return chains.find(chain => chain.id === chainId).name.toLowerCase();
}, [chains, chainId, addressChainId]);
const [pendingExoduses, setPendingExoduses] = useState(0);
const [signedExoduses, setSignedExoduses] = useState(0);
const { useStorageValue, CONSTANTS } = useLocalStorage();
const { casperApi } = useUnstableProvider();
const { liveBonds: ghostBonds } = useLiveBonds(chainId);
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
@ -95,6 +104,36 @@ const NavContent = ({ chainId, addressChainId, address }) => {
const sortedGhostBonds = useMemo(() => sortBondsByDiscount(ghostBonds), [ghostBonds]);
const { data: counterForExodusRequest } = useSWR(
casperApi ? ["counterForExodusRequest", casperApi] : null,
([_, api]) => api.query.GhostExodus.CounterForExodusRequests.getValue(),
{ fallbackData: 0, refetchInterval: 12000 },
);
useEffect(() => {
if (pendingExoduses === counterForExodusRequest) return
else if (pendingExoduses > counterForExodusRequest) {
const newlySigned = pendingExoduses - counterForExodusRequest;
setSignedExoduses((prev) => prev + newlySigned);
setPendingExoduses(counterForExodusRequest);
} else {
const newlyQueued = counterForExodusRequest - pendingExoduses;
const message =
newlyQueued === 1
? "GHOST Exodus request is signing now. Get ready to verify it and earn rewards!"
: `${newlyQueued} GHOST Exodus requests are signing now. Get ready to verify them and earn rewards!`;
toast.success(message, { autoClose: 5000 });
setPendingExoduses(counterForExodusRequest);
}
}, [counterForExodusRequest, pendingExoduses]);
useEffect(() => {
if (!location.pathname.endsWith("exodus")) return
setSignedExoduses(0);
}, [location]);
return (
<Paper className="dapp-sidebar">
<Box className="dapp-sidebar-inner" display="flex" justifyContent="space-between" flexDirection="column">
@ -107,7 +146,7 @@ const NavContent = ({ chainId, addressChainId, address }) => {
component={GhostIcon}
style={{ width: "150px", height: "150px" }}
/>
<Box mb="10px" mt="-40px" fontSize="12px" fontWeight="500" lineHeight={"15px"}>
<Box mb="10px" mt="-40px" fontSize="12px" fontWeight="500" lineHeight={"15px"}>
Version {pckg.version}
</Box>
</Link>
@ -189,9 +228,9 @@ const NavContent = ({ chainId, addressChainId, address }) => {
/>
<NavItem icon={ForkRightIcon} label={`${bridgeNumbers()} Bridge-In`} to={`/${chainName}/bridge-in`} />
<NavItem icon={RampLeftIcon} label={`${negativeBridgeNumbers()} Bridge-Out`} to={`/${chainName}/bridge-out`} />
<NavItem icon={RouteIcon} label="(1, 1) Ghost Exodus" to={`/${chainName}/exodus`} />
{/* <NavItem icon={GavelIcon} label={`Governance`} to={`/${chainName}/governance`} /> */}
<NavItem icon={RouteIcon} chipColor="warning" chip={signedExoduses > 0 ? signedExoduses : null} label="(1, 1) Ghost Exodus" to={`/${chainName}/exodus`} />
<NavItem icon={HistoryIcon} chipColor="warning" chip={pendingTransactions} label="Transaction History" to={`/${chainName}/history`} />
{/* <NavItem icon={GavelIcon} label={`Governance`} to={`/${chainName}/governance`} /> */}
<Box className="menu-divider">
<Divider />