Skip to content

Commit

Permalink
Merge branch 'develop' into fix/decode-transactions-with-abi-decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrila authored Jan 6, 2025
2 parents 2be56f6 + 5b85b67 commit 08d9864
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ export function EstablishEssentials(props: ICreationStepProps) {
},
});

useEffect(() => {
if (chain.id !== walletChainID) {
const chainId = getChainIdFromPrefix(addressPrefix);
switchChain({ chainId });
}
}, [chain.id, walletChainID, addressPrefix, switchChain]);

return (
<>
<StepWrapper
Expand Down
20 changes: 20 additions & 0 deletions src/components/DaoCreator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Box } from '@chakra-ui/react';
import { Formik } from 'formik';
import { useEffect } from 'react';
import { useChainId, useSwitchChain } from 'wagmi';
import { useDAOCreateSchema } from '../../hooks/schemas/DAOCreate/useDAOCreateSchema';
import { useNetworkConfigStore } from '../../providers/NetworkConfig/useNetworkConfigStore';
import {
AzoriusERC20DAO,
AzoriusERC721DAO,
Expand Down Expand Up @@ -28,6 +31,8 @@ function DaoCreator({
mode: DAOCreateMode;
}) {
const { totalParentVotingWeight } = useParentSafeVotingWeight();
const walletChainID = useChainId();
const { chain } = useNetworkConfigStore();

const { createDAOValidation } = useDAOCreateSchema({
isSubDAO: !!isSubDAO,
Expand All @@ -37,6 +42,21 @@ function DaoCreator({
const { prepareMultisigFormData, prepareAzoriusERC20FormData, prepareAzoriusERC721FormData } =
usePrepareFormData();

const { switchChain } = useSwitchChain({
mutation: {
onError: () => {
if (chain.id !== walletChainID && !isSubDAO) {
switchChain({ chainId: chain.id });
}
},
},
});
useEffect(() => {
if (chain.id !== walletChainID && !isSubDAO) {
switchChain({ chainId: chain.id });
}
}, [chain.id, walletChainID, switchChain, isSubDAO]);

return (
<Box>
<Formik<CreatorFormState>
Expand Down

0 comments on commit 08d9864

Please sign in to comment.