From 20f8ec0e93fd4b1cf940d98f14e0f639de215184 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Thu, 28 Mar 2024 22:23:51 -0400 Subject: [PATCH] Remove "daoNetwork" from Fractal state, use value from useNetworkConfig everywhere --- src/components/DaoCreator/StepWrapper.tsx | 8 +- .../ProposalTemplateCard.tsx | 10 ++- src/components/ProposalTemplates/index.tsx | 8 +- .../Proposals/ProposalCard/ProposalCard.tsx | 8 +- src/components/Proposals/ProposalsList.tsx | 8 +- .../pages/DaoDashboard/Info/ParentLink.tsx | 8 +- .../pages/DaoDashboard/Info/index.tsx | 12 +-- src/components/pages/DaoHierarchy/DaoNode.tsx | 12 ++- .../DaoSettings/components/Metadata/index.tsx | 8 +- src/components/ui/cards/DAOInfoCard.tsx | 8 +- .../ui/menus/ManageDAO/ManageDAOMenu.tsx | 32 ++++---- .../modals/ConfirmModifyGovernanceModal.tsx | 8 +- .../ui/modals/ForkProposalTemplateModal.tsx | 20 +++-- .../ui/modals/ProposalTemplateModal.tsx | 8 +- src/components/ui/modals/Stake.tsx | 8 +- src/components/ui/page/Header/PageHeader.tsx | 10 ++- .../ui/page/Navigation/NavigationLinks.tsx | 16 ++-- src/components/ui/page/Navigation/index.tsx | 4 +- src/constants/routes.ts | 48 ++++++------ src/hooks/DAO/loaders/useFractalNode.ts | 76 +++++++++---------- src/hooks/DAO/loaders/useLoadDAONode.ts | 49 ++++++------ src/hooks/DAO/proposal/useSubmitProposal.ts | 2 +- src/hooks/DAO/useCreateSubDAOProposal.ts | 2 +- src/hooks/DAO/useDAOController.ts | 4 +- src/hooks/DAO/useDeployAzorius.ts | 9 ++- src/hooks/DAO/useDeployDAO.ts | 2 +- src/pages/create/index.tsx | 4 +- .../[daoAddress]/edit/governance/index.tsx | 8 +- .../daos/[daoAddress]/hierarchy/index.tsx | 5 +- src/pages/daos/[daoAddress]/new/index.tsx | 4 +- .../[daoAddress]/proposal-templates/index.tsx | 8 +- .../proposal-templates/new/index.tsx | 16 ++-- .../proposals/[proposalId]/index.tsx | 8 +- .../daos/[daoAddress]/proposals/index.tsx | 8 +- .../daos/[daoAddress]/proposals/new/index.tsx | 16 ++-- src/providers/App/node/reducer.ts | 1 - src/types/fractal.ts | 1 - 37 files changed, 246 insertions(+), 221 deletions(-) diff --git a/src/components/DaoCreator/StepWrapper.tsx b/src/components/DaoCreator/StepWrapper.tsx index 82faffb0c9..ba9f45aa06 100644 --- a/src/components/DaoCreator/StepWrapper.tsx +++ b/src/components/DaoCreator/StepWrapper.tsx @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom'; import { BACKGROUND_SEMI_TRANSPARENT } from '../../constants/common'; import { BASE_ROUTES, DAO_ROUTES } from '../../constants/routes'; import { useFractal } from '../../providers/App/AppProvider'; +import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import PageHeader from '../ui/page/Header/PageHeader'; import { DAOCreateMode } from './formComponents/EstablishEssentials'; @@ -27,8 +28,9 @@ export function StepWrapper({ shouldWrapChildren = true, }: IStepWrapper) { const { - node: { daoAddress, daoNetwork }, + node: { daoAddress }, } = useFractal(); + const { addressPrefix } = useNetworkConfig(); const { t } = useTranslation(['daoCreate']); const navigate = useNavigate(); @@ -64,9 +66,9 @@ export function StepWrapper({ isButtonDisabled={isFormSubmitting} buttonClick={() => navigate( - !isSubDAO || !daoAddress || !daoNetwork + !isSubDAO || !daoAddress ? BASE_ROUTES.landing - : DAO_ROUTES.dao.relative(daoNetwork, daoAddress), + : DAO_ROUTES.dao.relative(addressPrefix, daoAddress), ) } /> diff --git a/src/components/ProposalTemplates/ProposalTemplateCard.tsx b/src/components/ProposalTemplates/ProposalTemplateCard.tsx index 493fb09943..d8b27a2098 100644 --- a/src/components/ProposalTemplates/ProposalTemplateCard.tsx +++ b/src/components/ProposalTemplates/ProposalTemplateCard.tsx @@ -7,6 +7,7 @@ import { DAO_ROUTES } from '../../constants/routes'; import useRemoveProposalTemplate from '../../hooks/DAO/proposal/useRemoveProposalTemplate'; import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal'; import { useFractal } from '../../providers/App/AppProvider'; +import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { ProposalTemplate } from '../../types/createProposalTemplate'; import ContentBox from '../ui/containers/ContentBox'; import { OptionMenu } from '../ui/menus/OptionMenu'; @@ -26,8 +27,9 @@ export default function ProposalTemplateCard({ const navigate = useNavigate(); const { t } = useTranslation('proposalTemplate'); const { - node: { safe, daoAddress, daoNetwork }, + node: { safe, daoAddress }, } = useFractal(); + const { addressPrefix } = useNetworkConfig(); const { prepareRemoveProposalTemplateProposal } = useRemoveProposalTemplate(); const { submitProposal, canUserCreateProposal } = useSubmitProposal(); @@ -42,11 +44,11 @@ export default function ProposalTemplateCard({ }); const successCallback = useCallback(() => { - if (daoAddress && daoNetwork) { + if (daoAddress) { // Redirecting to proposals page so that user will see Proposal for Proposal Template creation - navigate(DAO_ROUTES.proposals.relative(daoNetwork, daoAddress)); + navigate(DAO_ROUTES.proposals.relative(addressPrefix, daoAddress)); } - }, [navigate, daoAddress, daoNetwork]); + }, [navigate, daoAddress, addressPrefix]); const nonce = safe?.nonce; const handleRemoveTemplate = useCallback(async () => { diff --git a/src/components/ProposalTemplates/index.tsx b/src/components/ProposalTemplates/index.tsx index 7cf24fa072..7776bf1538 100644 --- a/src/components/ProposalTemplates/index.tsx +++ b/src/components/ProposalTemplates/index.tsx @@ -4,6 +4,7 @@ import { Link } from 'react-router-dom'; import { DAO_ROUTES } from '../../constants/routes'; import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal'; import { useFractal } from '../../providers/App/AppProvider'; +import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { EmptyBox } from '../ui/containers/EmptyBox'; import { InfoBoxLoader } from '../ui/loaders/InfoBoxLoader'; import ProposalTemplateCard from './ProposalTemplateCard'; @@ -11,9 +12,10 @@ import ProposalTemplateCard from './ProposalTemplateCard'; export default function ProposalTemplates() { const { t } = useTranslation('proposalTemplate'); const { - node: { daoAddress, daoNetwork }, + node: { daoAddress }, governance: { proposalTemplates }, } = useFractal(); + const { addressPrefix } = useNetworkConfig(); const { canUserCreateProposal } = useSubmitProposal(); return ( @@ -36,8 +38,8 @@ export default function ProposalTemplates() { )) ) : ( - {canUserCreateProposal && daoNetwork && daoAddress && ( - + {canUserCreateProposal && daoAddress && ( + )} - {canUserCreateProposal && daoNetwork && daoAddress && ( - + {canUserCreateProposal && daoAddress && ( +