Compare commits

..

No commits in common. "4c455bd1f5cc65d475262082e7fa8c0e9c9f866a" and "421f2cef27eff871827b513053ee8641c3974c42" have entirely different histories.

5 changed files with 14 additions and 23 deletions

View File

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

View File

@ -116,7 +116,7 @@ function App() {
const [isSidebarExpanded, setIsSidebarExpanded] = useState(false); const [isSidebarExpanded, setIsSidebarExpanded] = useState(false);
const [mobileOpen, setMobileOpen] = useState(false); const [mobileOpen, setMobileOpen] = useState(false);
const { address = "", chainId: addressChainId, status, isConnected, isReconnecting } = useAccount(); const { address = "", chainId: addressChainId, isConnected, isReconnecting } = useAccount();
const provider = usePublicClient(); const provider = usePublicClient();
const chainId = useChainId(); const chainId = useChainId();
@ -177,6 +177,7 @@ function App() {
}; };
const themeMode = theme === "light" ? lightTheme : theme === "dark" ? darkTheme : gTheme; const themeMode = theme === "light" ? lightTheme : theme === "dark" ? darkTheme : gTheme;
const chainExists = isNetworkAvailable(chainId, addressChainId); const chainExists = isNetworkAvailable(chainId, addressChainId);
useEffect(() => { useEffect(() => {
@ -193,7 +194,6 @@ function App() {
wrongNetworkToastId={wrongNetworkToastId} wrongNetworkToastId={wrongNetworkToastId}
setWrongNetworkToastId={setWrongNetworkToastId} setWrongNetworkToastId={setWrongNetworkToastId}
address={address} address={address}
status={status}
chainId={addressChainId ? addressChainId : chainId} chainId={addressChainId ? addressChainId : chainId}
chainExists={chainExists} chainExists={chainExists}
handleDrawerToggle={handleDrawerToggle} handleDrawerToggle={handleDrawerToggle}

View File

@ -1,4 +1,4 @@
import { useState, useEffect, useRef } from "react"; import { useState, useEffect } from "react";
import { Box, Typography, SvgIcon, useTheme } from "@mui/material"; import { Box, Typography, SvgIcon, useTheme } from "@mui/material";
@ -15,10 +15,9 @@ import { useSwitchChain } from 'wagmi';
import { useNavigate, useLocation } from 'react-router-dom'; import { useNavigate, useLocation } from 'react-router-dom';
import toast from "react-hot-toast"; import toast from "react-hot-toast";
function SelectNetwork({ chainId, wrongNetworkToastId, setWrongNetworkToastId, small, status }) { function SelectNetwork({ chainId, wrongNetworkToastId, setWrongNetworkToastId, small }) {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const hasAttemptedSwitch = useRef(false);
const { chains, switchChain } = useSwitchChain(); const { chains, switchChain } = useSwitchChain();
const { pathname } = useLocation(); const { pathname } = useLocation();
@ -26,21 +25,21 @@ function SelectNetwork({ chainId, wrongNetworkToastId, setWrongNetworkToastId, s
const [networkId, setNetworkId] = useState(chainId); const [networkId, setNetworkId] = useState(chainId);
useEffect(() => { useEffect(() => {
if (status === 'reconnecting' || status === 'connecting') return;
const parts = pathname.split('/'); const parts = pathname.split('/');
if (!hasAttemptedSwitch.current && parts.length > 2) { if (parts.length > 2) {
let targetChain = chains.at(0); let targetChain = chains.at(0);
const chainName = parts[1].toLowerCase(); const chainName = parts[1].toLowerCase();
const chain = chains.find(chain => chain.name.toLowerCase() === chainName); const chain = chains.find(chain => chain.name.toLowerCase() === chainName);
if (chain && targetChain.name !== chain.name) { if (chain && targetChain.name !== chain.name) {
targetChain = chain; targetChain = chain;
} }
changeNetworkId(targetChain.name, targetChain.id)
hasAttemptedSwitch.current = true;
changeNetworkId(targetChain.name, targetChain.id);
} }
}, [status, chains, pathname]); }, [])
useEffect(() => {
if (chainId !== networkId) setNetworkId(chainId);
}, [chainId, networkId])
const changeNetworkId = (chainName, newNetworkId) => { const changeNetworkId = (chainName, newNetworkId) => {
toast.dismiss(wrongNetworkToastId); toast.dismiss(wrongNetworkToastId);
@ -50,12 +49,7 @@ function SelectNetwork({ chainId, wrongNetworkToastId, setWrongNetworkToastId, s
setWrongNetworkToastId(toastId); setWrongNetworkToastId(toastId);
setNetworkId(newNetworkId); setNetworkId(newNetworkId);
switchChain({ switchChain({ chainId: newNetworkId });
chainId: newNetworkId
}, {
onSuccess: (data) => console.log("Network switched to", data.name),
onError: (error) => console.log("Error during network switching", error),
});
} }
const handleChange = (event) => { const handleChange = (event) => {
@ -76,7 +70,6 @@ function SelectNetwork({ chainId, wrongNetworkToastId, setWrongNetworkToastId, s
labelId="network-select-helper-label" labelId="network-select-helper-label"
id="network-select-helper" id="network-select-helper"
value={networkId} value={networkId}
disabled={!hasAttemptedSwitch.current}
onChange={handleChange} onChange={handleChange}
sx={{ sx={{
boxShadow: 'none', boxShadow: 'none',

View File

@ -18,7 +18,6 @@ function TopBar({
address, address,
wrongNetworkToastId, wrongNetworkToastId,
connect, connect,
status,
handleDrawerToggle, handleDrawerToggle,
setWrongNetworkToastId setWrongNetworkToastId
}) { }) {
@ -40,7 +39,6 @@ function TopBar({
setWrongNetworkToastId={setWrongNetworkToastId} setWrongNetworkToastId={setWrongNetworkToastId}
chainId={chainId} chainId={chainId}
small={small} small={small}
status={status}
/> />
<Wallet address={address} connect={connect} chainId={chainId} /> <Wallet address={address} connect={connect} chainId={chainId} />
</Box> </Box>

View File

@ -20,7 +20,7 @@ export const useCurrentIndex = (chainId) => {
chainId: chainId, chainId: chainId,
}); });
const currentIndexRaw = index ? index : 1000000000n; const currentIndexRaw = index ? index : 0n;
const currentIndex = new DecimalBigNumber(currentIndexRaw, 9); const currentIndex = new DecimalBigNumber(currentIndexRaw, 9);
return { currentIndex, refetch }; return { currentIndex, refetch };