From 55988858d92011adfe6e3c1fa2bae1c85149d35b Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Mon, 23 Nov 2026 13:02:05 +0300 Subject: [PATCH] notifications for pending exoduses and signed messages added Signed-off-by: Uncle Fatso --- package.json | 2 +- src/components/Sidebar/NavContent.jsx | 49 ++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 56ea2a0..3333acb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.8.28", + "version": "0.8.29", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/Sidebar/NavContent.jsx b/src/components/Sidebar/NavContent.jsx index 6f09d20..8f5c950 100644 --- a/src/components/Sidebar/NavContent.jsx +++ b/src/components/Sidebar/NavContent.jsx @@ -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 ( @@ -107,7 +146,7 @@ const NavContent = ({ chainId, addressChainId, address }) => { component={GhostIcon} style={{ width: "150px", height: "150px" }} /> - + Version {pckg.version} @@ -189,9 +228,9 @@ const NavContent = ({ chainId, addressChainId, address }) => { /> - - {/* */} + 0 ? signedExoduses : null} label="(1, 1) Ghost Exodus" to={`/${chainName}/exodus`} /> + {/* */}