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",
"private": true,
"version": "0.7.7",
"version": "0.7.5",
"type": "module",
"scripts": {
"dev": "vite",

View File

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

View File

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

View File

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