From 9f0017d2c85c5f23f3279b89cb0d65d036154ca2 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:16:50 -0500 Subject: [PATCH 1/3] Add chain switching logic in EstablishEssentials component --- .../DaoCreator/formComponents/EstablishEssentials.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx index aa917e26c..3c0953456 100644 --- a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx +++ b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx @@ -108,6 +108,13 @@ export function EstablishEssentials(props: ICreationStepProps) { }, }); + useEffect(() => { + if (chain.id !== walletChainID) { + const chainId = getChainIdFromPrefix(addressPrefix); + switchChain({ chainId }); + } + }); + return ( <> Date: Wed, 18 Dec 2024 14:20:39 -0500 Subject: [PATCH 2/3] actually switch network when selected --- src/components/DaoCreator/formComponents/EstablishEssentials.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx index 3c0953456..e880bf66d 100644 --- a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx +++ b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx @@ -151,6 +151,7 @@ export function EstablishEssentials(props: ICreationStepProps) { selectedItem={dropdownItems.find(item => item.selected)} onSelect={item => { setCurrentConfig(getConfigByChainId(Number(item.value))); + switchChain({ chainId: Number(item.value) }); }} title={t('networks')} isDisabled={false} From a0773eb108beb411857a0b340540f3b01f171542 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:13:32 -0500 Subject: [PATCH 3/3] Update dependency array in EstablishEssentials to include addressPrefix --- .../DaoCreator/formComponents/EstablishEssentials.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx index e880bf66d..1ac5af67a 100644 --- a/src/components/DaoCreator/formComponents/EstablishEssentials.tsx +++ b/src/components/DaoCreator/formComponents/EstablishEssentials.tsx @@ -113,7 +113,7 @@ export function EstablishEssentials(props: ICreationStepProps) { const chainId = getChainIdFromPrefix(addressPrefix); switchChain({ chainId }); } - }); + }, [chain.id, walletChainID, addressPrefix, switchChain]); return ( <>