diff --git a/front/src/app/page.tsx b/front/src/app/page.tsx index 2bfed97..4240277 100644 --- a/front/src/app/page.tsx +++ b/front/src/app/page.tsx @@ -65,9 +65,6 @@ export default function Home() { chain: CHAIN, }); - // Get the SismoConnectConfig and Sismo Connect Request from the contract - // Set react state accordingly to display the Sismo Connect Button - useEffect(() => { setClaimError(error); if (!responseBytes) return; @@ -88,7 +85,6 @@ export default function Home() { /* ************ Handle the airdrop claim button click ******************* */ async function claimAirdrop() { if (!address) return; - setClaimError(""); try { if (chain?.id !== CHAIN.id) await switchNetworkAsync?.(CHAIN.id); setPageState("confirmingTransaction"); @@ -159,7 +155,7 @@ export default function Home() { /> > )} - {claimError !== null && ( + {!claimError && (
- Please restart your frontend with "yarn dev" command and try again, it will - automatically deploy a new contract for you! + If you are developing on a local fork, please restart your frontend with "yarn + dev" command and try again, it will automatically deploy a new contract for you!
)} {claimError.slice(0, 16) === "Please switch to" && ( diff --git a/front/src/utils/useContract.tsx b/front/src/utils/useContract.tsx index 08c481f..cc180ad 100644 --- a/front/src/utils/useContract.tsx +++ b/front/src/utils/useContract.tsx @@ -47,13 +47,18 @@ export default function useContract({ /* ************* Handle simulateContract call & chain errors ************ */ useEffect(() => { - if (currentChain?.id !== chain.id) return setError(`Please switch to ${chain.name} network`); + if (currentChain?.id !== chain.id) { + return setError(`Please switch to ${chain.name} network`); + } setError(""); }, [currentChain]); useEffect(() => { if (!isConnected) return; if (!responseBytes) return; + if (currentChain?.id !== chain.id) { + return setError(`Please switch to ${chain.name} network`); + } async function simulate() { try { await airdropContract.simulate.claimWithSismo([responseBytes, address]); @@ -64,7 +69,7 @@ export default function useContract({ } simulate(); - }, [address, isConnected, responseBytes]); + }, [address, isConnected, responseBytes, currentChain]); async function waitingForTransaction( hash: `0x${string}`