notifications for pending exoduses and signed messages added
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
852d3c86ce
commit
55988858d9
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.8.28",
|
"version": "0.8.29",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -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";
|
import "./Sidebar.scss";
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ import {
|
|||||||
AccordionDetails,
|
AccordionDetails,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { styled } from "@mui/material/styles";
|
import { styled } from "@mui/material/styles";
|
||||||
import { NavLink } from "react-router-dom";
|
import { NavLink, useLocation } from "react-router-dom";
|
||||||
import { useSwitchChain } from "wagmi";
|
import { useSwitchChain } from "wagmi";
|
||||||
|
|
||||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
||||||
@ -59,6 +61,7 @@ import WifiProtectedSetupIcon from '@mui/icons-material/WifiProtectedSetup';
|
|||||||
import { useTokenSymbol } from "../../hooks/tokens";
|
import { useTokenSymbol } from "../../hooks/tokens";
|
||||||
import { useLiveBonds } from "../../hooks/bonds/index";
|
import { useLiveBonds } from "../../hooks/bonds/index";
|
||||||
import { useLocalStorage } from "../../hooks/localstorage";
|
import { useLocalStorage } from "../../hooks/localstorage";
|
||||||
|
import { useUnstableProvider } from "../../hooks/ghost";
|
||||||
import pckg from "../../../package.json"
|
import pckg from "../../../package.json"
|
||||||
|
|
||||||
const PREFIX = "NavContent";
|
const PREFIX = "NavContent";
|
||||||
@ -74,12 +77,18 @@ const StyledBox = styled(Box)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const NavContent = ({ chainId, addressChainId, address }) => {
|
const NavContent = ({ chainId, addressChainId, address }) => {
|
||||||
|
const location = useLocation();
|
||||||
const { chains } = useSwitchChain();
|
const { chains } = useSwitchChain();
|
||||||
|
|
||||||
const chainName = useMemo(() => {
|
const chainName = useMemo(() => {
|
||||||
return chains.find(chain => chain.id === chainId).name.toLowerCase();
|
return chains.find(chain => chain.id === chainId).name.toLowerCase();
|
||||||
}, [chains, chainId, addressChainId]);
|
}, [chains, chainId, addressChainId]);
|
||||||
|
|
||||||
|
const [pendingExoduses, setPendingExoduses] = useState(0);
|
||||||
|
const [signedExoduses, setSignedExoduses] = useState(0);
|
||||||
|
|
||||||
const { useStorageValue, CONSTANTS } = useLocalStorage();
|
const { useStorageValue, CONSTANTS } = useLocalStorage();
|
||||||
|
const { casperApi } = useUnstableProvider();
|
||||||
|
|
||||||
const { liveBonds: ghostBonds } = useLiveBonds(chainId);
|
const { liveBonds: ghostBonds } = useLiveBonds(chainId);
|
||||||
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
|
const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO");
|
||||||
@ -95,6 +104,36 @@ const NavContent = ({ chainId, addressChainId, address }) => {
|
|||||||
|
|
||||||
const sortedGhostBonds = useMemo(() => sortBondsByDiscount(ghostBonds), [ghostBonds]);
|
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 (
|
return (
|
||||||
<Paper className="dapp-sidebar">
|
<Paper className="dapp-sidebar">
|
||||||
<Box className="dapp-sidebar-inner" display="flex" justifyContent="space-between" flexDirection="column">
|
<Box className="dapp-sidebar-inner" display="flex" justifyContent="space-between" flexDirection="column">
|
||||||
@ -107,7 +146,7 @@ const NavContent = ({ chainId, addressChainId, address }) => {
|
|||||||
component={GhostIcon}
|
component={GhostIcon}
|
||||||
style={{ width: "150px", height: "150px" }}
|
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}
|
Version {pckg.version}
|
||||||
</Box>
|
</Box>
|
||||||
</Link>
|
</Link>
|
||||||
@ -189,9 +228,9 @@ const NavContent = ({ chainId, addressChainId, address }) => {
|
|||||||
/>
|
/>
|
||||||
<NavItem icon={ForkRightIcon} label={`${bridgeNumbers()} Bridge-In`} to={`/${chainName}/bridge-in`} />
|
<NavItem icon={ForkRightIcon} label={`${bridgeNumbers()} Bridge-In`} to={`/${chainName}/bridge-in`} />
|
||||||
<NavItem icon={RampLeftIcon} label={`${negativeBridgeNumbers()} Bridge-Out`} to={`/${chainName}/bridge-out`} />
|
<NavItem icon={RampLeftIcon} label={`${negativeBridgeNumbers()} Bridge-Out`} to={`/${chainName}/bridge-out`} />
|
||||||
<NavItem icon={RouteIcon} label="(1, 1) Ghost Exodus" to={`/${chainName}/exodus`} />
|
<NavItem icon={RouteIcon} chipColor="warning" chip={signedExoduses > 0 ? signedExoduses : null} label="(1, 1) Ghost Exodus" to={`/${chainName}/exodus`} />
|
||||||
{/* <NavItem icon={GavelIcon} label={`Governance`} to={`/${chainName}/governance`} /> */}
|
|
||||||
<NavItem icon={HistoryIcon} chipColor="warning" chip={pendingTransactions} label="Transaction History" to={`/${chainName}/history`} />
|
<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">
|
<Box className="menu-divider">
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user