diff --git a/src/components/ProposalTemplates/ProposalTemplateCard.tsx b/src/components/ProposalTemplates/ProposalTemplateCard.tsx index d8b27a2098..cc8336146a 100644 --- a/src/components/ProposalTemplates/ProposalTemplateCard.tsx +++ b/src/components/ProposalTemplates/ProposalTemplateCard.tsx @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom'; import { DAO_ROUTES } from '../../constants/routes'; import useRemoveProposalTemplate from '../../hooks/DAO/proposal/useRemoveProposalTemplate'; import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../providers/App/AppProvider'; import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { ProposalTemplate } from '../../types/createProposalTemplate'; @@ -32,7 +33,8 @@ export default function ProposalTemplateCard({ const { addressPrefix } = useNetworkConfig(); const { prepareRemoveProposalTemplateProposal } = useRemoveProposalTemplate(); - const { submitProposal, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const { title, description } = proposalTemplate; const openProposalForm = useFractalModal(ModalType.CREATE_PROPOSAL_FROM_TEMPLATE, { diff --git a/src/components/ProposalTemplates/index.tsx b/src/components/ProposalTemplates/index.tsx index 7776bf1538..55d55fa74b 100644 --- a/src/components/ProposalTemplates/index.tsx +++ b/src/components/ProposalTemplates/index.tsx @@ -2,7 +2,7 @@ import { Flex, Box, Button } from '@chakra-ui/react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import { DAO_ROUTES } from '../../constants/routes'; -import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../providers/App/AppProvider'; import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { EmptyBox } from '../ui/containers/EmptyBox'; @@ -16,7 +16,7 @@ export default function ProposalTemplates() { governance: { proposalTemplates }, } = useFractal(); const { addressPrefix } = useNetworkConfig(); - const { canUserCreateProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); return ( { - const loadCanUserCreateProposal = async () => { - if (safeAddress) { - setCanUserCreateProposal(await getCanUserCreateProposal(safeAddress)); - } - }; - - loadCanUserCreateProposal(); - }, [safeAddress, getCanUserCreateProposal]); - useEffect(() => { const loadGovernanceType = async () => { if (safe && safe.address && safe.address === safeAddress && type) { diff --git a/src/components/ui/modals/ForkProposalTemplateModal.tsx b/src/components/ui/modals/ForkProposalTemplateModal.tsx index 25e5484b51..f63cf23d7d 100644 --- a/src/components/ui/modals/ForkProposalTemplateModal.tsx +++ b/src/components/ui/modals/ForkProposalTemplateModal.tsx @@ -3,9 +3,9 @@ import { ChangeEventHandler, useState, useCallback, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { DAO_ROUTES } from '../../../constants/routes'; -import useSubmitProposal from '../../../hooks/DAO/proposal/useSubmitProposal'; import { useIsSafe } from '../../../hooks/safe/useIsSafe'; import { validateAddress } from '../../../hooks/schemas/common/useValidationAddress'; +import { useCanUserCreateProposal } from '../../../hooks/utils/useCanUserSubmitProposal'; import useSignerOrProvider from '../../../hooks/utils/useSignerOrProvider'; import { useFractal } from '../../../providers/App/AppProvider'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; @@ -36,7 +36,7 @@ export default function ForkProposalTemplateModal({ } = useFractal(); const { isSafe, isSafeLoading } = useIsSafe(targetDAOAddress); - const { getCanUserCreateProposal } = useSubmitProposal(); + const { getCanUserCreateProposal } = useCanUserCreateProposal(); const handleAddressChange: ChangeEventHandler = e => { setInputValue(e.target.value); diff --git a/src/components/ui/modals/ProposalTemplateModal.tsx b/src/components/ui/modals/ProposalTemplateModal.tsx index 45028ba7aa..a5c6230892 100644 --- a/src/components/ui/modals/ProposalTemplateModal.tsx +++ b/src/components/ui/modals/ProposalTemplateModal.tsx @@ -16,6 +16,7 @@ import { DAO_ROUTES } from '../../../constants/routes'; import { logError } from '../../../helpers/errorLogging'; import { usePrepareProposal } from '../../../hooks/DAO/proposal/usePrepareProposal'; import useSubmitProposal from '../../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../providers/App/AppProvider'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; import { ProposalTemplate } from '../../../types/createProposalTemplate'; @@ -43,7 +44,8 @@ export default function ProposalTemplateModal({ const [showAll, setShowAll] = useState(false); const { t } = useTranslation(['proposalTemplate', 'proposal']); const navigate = useNavigate(); - const { submitProposal, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const { prepareProposal } = usePrepareProposal(); const handleParameterChange = ({ diff --git a/src/hooks/DAO/proposal/useSubmitProposal.ts b/src/hooks/DAO/proposal/useSubmitProposal.ts index 5b61885778..2d5d2ec4c7 100644 --- a/src/hooks/DAO/proposal/useSubmitProposal.ts +++ b/src/hooks/DAO/proposal/useSubmitProposal.ts @@ -3,7 +3,7 @@ import { Azorius } from '@fractal-framework/fractal-contracts'; import axios from 'axios'; import { BigNumber, Signer, utils } from 'ethers'; import { getAddress, isAddress } from 'ethers/lib/utils'; -import { useCallback, useMemo, useState, useEffect } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { toast } from 'react-toastify'; import { GnosisSafeL2__factory } from '../../../assets/typechain-types/usul/factories/@gnosis.pm/safe-contracts/contracts'; import { ADDRESS_MULTISIG_METADATA } from '../../../constants/common'; @@ -15,12 +15,7 @@ import { useSafeAPI } from '../../../providers/App/hooks/useSafeAPI'; import { useEthersProvider } from '../../../providers/Ethers/hooks/useEthersProvider'; import { useEthersSigner } from '../../../providers/Ethers/hooks/useEthersSigner'; import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider'; -import { - MetaTransaction, - ProposalExecuteData, - GovernanceType, - ProposalMetadata, -} from '../../../types'; +import { MetaTransaction, ProposalExecuteData, ProposalMetadata } from '../../../types'; import { buildSafeApiUrl, getAzoriusModuleFromModules } from '../../../utils'; import { getAverageBlockTime } from '../../../utils/contract'; import useSafeContracts from '../../safe/useSafeContracts'; @@ -58,7 +53,6 @@ interface ISubmitAzoriusProposal extends ISubmitProposal { export default function useSubmitProposal() { const [pendingCreateTx, setPendingCreateTx] = useState(false); - const [canUserCreateProposal, setCanUserCreateProposal] = useState(false); const loadDAOProposals = useDAOProposals(); const signer = useEthersSigner(); const provider = useEthersProvider(); @@ -67,8 +61,6 @@ export default function useSubmitProposal() { node: { safe, fractalModules }, guardContracts: { freezeVotingContractAddress }, governanceContracts: { ozLinearVotingContractAddress, erc721LinearVotingContractAddress }, - governance: { type }, - readOnly: { user }, } = useFractal(); const baseContracts = useSafeContracts(); const safeAPI = useSafeAPI(); @@ -90,87 +82,6 @@ export default function useSubmitProposal() { const { chainId, safeBaseURL, addressPrefix } = useNetworkConfig(); const ipfsClient = useIPFSClient(); - /** - * Performs a check whether user has access rights to create proposal for DAO - * @param {string} safeAddress - parameter to verify that user can create proposal for this specific DAO. - * Otherwise - it is checked for DAO from the global context. - * @returns {Promise} - whether or not user has rights to create proposal either in global scope either for provided `safeAddress`. - */ - const getCanUserCreateProposal = useCallback( - async (safeAddress?: string): Promise => { - if (!user.address || !safeAPI || !signerOrProvider) { - return false; - } - - const checkIsMultisigOwner = (owners?: string[]) => { - return !!owners?.includes(user.address || ''); - }; - - if (safeAddress && baseContracts) { - const safeInfo = await safeAPI.getSafeInfo(utils.getAddress(safeAddress)); - const safeModules = await lookupModules(safeInfo.modules); - const azoriusModule = getAzoriusModuleFromModules(safeModules); - - if (azoriusModule && azoriusModule.moduleContract) { - const azoriusContract = azoriusModule.moduleContract as Azorius; - // @dev assumes the first strategy is the voting contract - const votingContractAddress = ( - await azoriusContract.getStrategies('0x0000000000000000000000000000000000000001', 0) - )[1]; - const votingContract = - baseContracts.linearVotingMasterCopyContract.asProvider.attach(votingContractAddress); - const isProposer = await votingContract.isProposer(user.address); - return isProposer; - } else { - return checkIsMultisigOwner(safeInfo.owners); - } - } else { - if (type === GovernanceType.MULTISIG) { - const { owners } = safe || {}; - return checkIsMultisigOwner(owners); - } else if (type === GovernanceType.AZORIUS_ERC20) { - if (ozLinearVotingContractAddress && user.address && baseContracts) { - const ozLinearVotingContract = - baseContracts.linearVotingMasterCopyContract.asProvider.attach( - ozLinearVotingContractAddress, - ); - return ozLinearVotingContract.isProposer(user.address); - } - } else if ( - type === GovernanceType.AZORIUS_ERC721 && - baseContracts && - erc721LinearVotingContractAddress - ) { - const erc721LinearVotingContract = - baseContracts.linearVotingERC721MasterCopyContract.asProvider.attach( - erc721LinearVotingContractAddress, - ); - return erc721LinearVotingContract.isProposer(user.address); - } else { - return false; - } - } - return false; - }, - [ - safe, - type, - user, - ozLinearVotingContractAddress, - erc721LinearVotingContractAddress, - lookupModules, - safeAPI, - signerOrProvider, - baseContracts, - ], - ); - useEffect(() => { - const loadCanUserCreateProposal = async () => { - setCanUserCreateProposal(await getCanUserCreateProposal()); - }; - loadCanUserCreateProposal(); - }, [getCanUserCreateProposal]); - const submitMultisigProposal = useCallback( async ({ pendingToastMessage, @@ -455,5 +366,5 @@ export default function useSubmitProposal() { ], ); - return { submitProposal, pendingCreateTx, canUserCreateProposal, getCanUserCreateProposal }; + return { submitProposal, pendingCreateTx }; } diff --git a/src/hooks/DAO/useClawBack.ts b/src/hooks/DAO/useClawBack.ts index 87df359d49..d5bb2ffc34 100644 --- a/src/hooks/DAO/useClawBack.ts +++ b/src/hooks/DAO/useClawBack.ts @@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'; import { useSafeAPI } from '../../providers/App/hooks/useSafeAPI'; import { useEthersProvider } from '../../providers/Ethers/hooks/useEthersProvider'; import { FractalModuleType, FractalNode } from '../../types'; +import { useCanUserCreateProposal } from '../utils/useCanUserSubmitProposal'; import useSubmitProposal from './proposal/useSubmitProposal'; interface IUseClawBack { @@ -16,7 +17,8 @@ export default function useClawBack({ childSafeInfo, parentAddress }: IUseClawBa const { t } = useTranslation(['proposal', 'proposalMetadata']); const provider = useEthersProvider(); const safeAPI = useSafeAPI(); - const { submitProposal, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const handleClawBack = useCallback(async () => { if (childSafeInfo && childSafeInfo.daoAddress && parentAddress && safeAPI && provider) { diff --git a/src/hooks/DAO/useCreateSubDAOProposal.ts b/src/hooks/DAO/useCreateSubDAOProposal.ts index 6a591f7c07..0e6ad1f4be 100644 --- a/src/hooks/DAO/useCreateSubDAOProposal.ts +++ b/src/hooks/DAO/useCreateSubDAOProposal.ts @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import { useFractal } from '../../providers/App/AppProvider'; import { SafeMultisigDAO, AzoriusGovernance, AzoriusERC20DAO, AzoriusERC721DAO } from '../../types'; import { ProposalExecuteData } from '../../types/daoProposal'; +import { useCanUserCreateProposal } from '../utils/useCanUserSubmitProposal'; import useSubmitProposal from './proposal/useSubmitProposal'; import useBuildDAOTx from './useBuildDAOTx'; @@ -11,7 +12,8 @@ export const useCreateSubDAOProposal = () => { const { baseContracts } = useFractal(); const { t } = useTranslation(['daoCreate', 'proposal', 'proposalMetadata']); - const { submitProposal, pendingCreateTx, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal, pendingCreateTx } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const [build] = useBuildDAOTx(); const { node: { daoAddress }, diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index 0ec2ee4817..642757570a 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -13,6 +13,7 @@ import { AzoriusERC20DAO, AzoriusERC721DAO, } from '../../types'; +import { useCanUserCreateProposal } from '../utils/useCanUserSubmitProposal'; import useSignerOrProvider from '../utils/useSignerOrProvider'; import useSubmitProposal from './proposal/useSubmitProposal'; @@ -29,8 +30,8 @@ const useDeployAzorius = () => { } = useFractal(); const { t } = useTranslation(['transaction', 'proposalMetadata']); - const { submitProposal, canUserCreateProposal } = useSubmitProposal(); - + const { submitProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const deployAzorius = useCallback( async ( daoData: AzoriusERC20DAO | AzoriusERC721DAO, diff --git a/src/hooks/utils/useCanUserSubmitProposal.ts b/src/hooks/utils/useCanUserSubmitProposal.ts new file mode 100644 index 0000000000..132aa0b6b9 --- /dev/null +++ b/src/hooks/utils/useCanUserSubmitProposal.ts @@ -0,0 +1,103 @@ +import { Azorius } from '@fractal-framework/fractal-contracts'; +import { utils } from 'ethers'; +import { useState, useCallback, useEffect } from 'react'; +import { useFractal } from '../../providers/App/AppProvider'; +import { useSafeAPI } from '../../providers/App/hooks/useSafeAPI'; +import { GovernanceType } from '../../types'; +import { getAzoriusModuleFromModules } from '../../utils'; +import { useFractalModules } from '../DAO/loaders/useFractalModules'; +import useSafeContracts from '../safe/useSafeContracts'; + +export function useCanUserCreateProposal() { + const { + node: { safe }, + governance: { type }, + governanceContracts: { ozLinearVotingContractAddress, erc721LinearVotingContractAddress }, + readOnly: { user }, + } = useFractal(); + const safeAPI = useSafeAPI(); + const baseContracts = useSafeContracts(); + const lookupModules = useFractalModules(); + const [canUserCreateProposal, setCanUserCreateProposal] = useState(); + /** + * Performs a check whether user has access rights to create proposal for DAO + * @param {string} safeAddress - parameter to verify that user can create proposal for this specific DAO. + * Otherwise - it is checked for DAO from the global context. + * @returns {Promise} - whether or not user has rights to create proposal either in global scope either for provided `safeAddress`. + */ + const getCanUserCreateProposal = useCallback( + async (safeAddress?: string): Promise => { + if (!user.address || !safeAPI) { + return; + } + + const checkIsMultisigOwner = (owners?: string[]) => { + return !!owners?.includes(user.address || ''); + }; + + if (safeAddress && baseContracts) { + const safeInfo = await safeAPI.getSafeInfo(utils.getAddress(safeAddress)); + const safeModules = await lookupModules(safeInfo.modules); + const azoriusModule = getAzoriusModuleFromModules(safeModules); + + if (azoriusModule && azoriusModule.moduleContract) { + const azoriusContract = azoriusModule.moduleContract as Azorius; + // @dev assumes the first strategy is the voting contract + const votingContractAddress = ( + await azoriusContract.getStrategies('0x0000000000000000000000000000000000000001', 0) + )[1]; + const votingContract = + baseContracts.linearVotingMasterCopyContract.asProvider.attach(votingContractAddress); + const isProposer = await votingContract.isProposer(user.address); + return isProposer; + } else { + return checkIsMultisigOwner(safeInfo.owners); + } + } else { + if (type === GovernanceType.MULTISIG) { + const { owners } = safe || {}; + return checkIsMultisigOwner(owners); + } else if (type === GovernanceType.AZORIUS_ERC20) { + if (ozLinearVotingContractAddress && user.address && baseContracts) { + const ozLinearVotingContract = + baseContracts.linearVotingMasterCopyContract.asProvider.attach( + ozLinearVotingContractAddress, + ); + return ozLinearVotingContract.isProposer(user.address); + } + } else if ( + type === GovernanceType.AZORIUS_ERC721 && + baseContracts && + erc721LinearVotingContractAddress + ) { + const erc721LinearVotingContract = + baseContracts.linearVotingERC721MasterCopyContract.asProvider.attach( + erc721LinearVotingContractAddress, + ); + return erc721LinearVotingContract.isProposer(user.address); + } else { + return; + } + } + return; + }, + [ + safe, + type, + user, + ozLinearVotingContractAddress, + erc721LinearVotingContractAddress, + lookupModules, + safeAPI, + baseContracts, + ], + ); + useEffect(() => { + const loadCanUserCreateProposal = async () => { + setCanUserCreateProposal(await getCanUserCreateProposal()); + }; + loadCanUserCreateProposal(); + }, [getCanUserCreateProposal, canUserCreateProposal]); + + return { canUserCreateProposal, getCanUserCreateProposal }; +} diff --git a/src/hooks/utils/useMasterCopy.ts b/src/hooks/utils/useMasterCopy.ts index 53e3dc769c..8bb49a6926 100644 --- a/src/hooks/utils/useMasterCopy.ts +++ b/src/hooks/utils/useMasterCopy.ts @@ -3,7 +3,7 @@ import { Contract, constants } from 'ethers'; import { useCallback } from 'react'; import { getEventRPC } from '../../helpers'; import { useFractal } from '../../providers/App/AppProvider'; -import { CacheKeys } from './cache/cacheDefaults'; +import { CacheExpiry, CacheKeys } from './cache/cacheDefaults'; import { useLocalStorage } from './cache/useLocalStorage'; export function useMasterCopy() { @@ -57,7 +57,13 @@ export function useMasterCopy() { const filter = contract.filters.ModuleProxyCreation(proxyAddress, null); return contract.queryFilter(filter).then(proxiesCreated => { + // @dev to prevent redundant queries, cache the master copy address as AddressZero if no proxies were created if (proxiesCreated.length === 0) { + setValue( + CacheKeys.MASTER_COPY_PREFIX + proxyAddress, + constants.AddressZero, + CacheExpiry.ONE_WEEK, + ); return [constants.AddressZero, 'No proxies created'] as const; } const masterCopyAddress = proxiesCreated[0].args!.masterCopy; diff --git a/src/pages/daos/[daoAddress]/proposal-templates/index.tsx b/src/pages/daos/[daoAddress]/proposal-templates/index.tsx index 5e7fdd5dc0..41c0ebff14 100644 --- a/src/pages/daos/[daoAddress]/proposal-templates/index.tsx +++ b/src/pages/daos/[daoAddress]/proposal-templates/index.tsx @@ -5,7 +5,7 @@ import { Link } from 'react-router-dom'; import ProposalTemplates from '../../../../components/ProposalTemplates'; import PageHeader from '../../../../components/ui/page/Header/PageHeader'; import { DAO_ROUTES } from '../../../../constants/routes'; -import useSubmitProposal from '../../../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../../providers/App/AppProvider'; import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider'; @@ -14,8 +14,8 @@ export default function ProposalTemplatesPage() { const { node: { daoAddress }, } = useFractal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const { addressPrefix } = useNetworkConfig(); - const { canUserCreateProposal } = useSubmitProposal(); return (
diff --git a/src/pages/daos/[daoAddress]/proposal-templates/new/index.tsx b/src/pages/daos/[daoAddress]/proposal-templates/new/index.tsx index bc58c19a3c..d557d064f7 100644 --- a/src/pages/daos/[daoAddress]/proposal-templates/new/index.tsx +++ b/src/pages/daos/[daoAddress]/proposal-templates/new/index.tsx @@ -17,6 +17,7 @@ import { logError } from '../../../../../helpers/errorLogging'; import useCreateProposalTemplate from '../../../../../hooks/DAO/proposal/useCreateProposalTemplate'; import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitProposal'; import useCreateProposalTemplateSchema from '../../../../../hooks/schemas/createProposalTemplate/useCreateProposalTemplateSchema'; +import { useCanUserCreateProposal } from '../../../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../../../providers/App/AppProvider'; import useIPFSClient from '../../../../../providers/App/hooks/useIPFSClient'; import { useNetworkConfig } from '../../../../../providers/NetworkConfig/NetworkConfigProvider'; @@ -52,7 +53,8 @@ export default function CreateProposalTemplatePage() { const { addressPrefix } = useNetworkConfig(); const { prepareProposalTemplateProposal } = useCreateProposalTemplate(); - const { submitProposal, pendingCreateTx, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal, pendingCreateTx } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const { createProposalTemplateValidation } = useCreateProposalTemplateSchema(); const ipfsClient = useIPFSClient(); diff --git a/src/pages/daos/[daoAddress]/proposals/index.tsx b/src/pages/daos/[daoAddress]/proposals/index.tsx index d6f8c9d214..2a804e3e2b 100644 --- a/src/pages/daos/[daoAddress]/proposals/index.tsx +++ b/src/pages/daos/[daoAddress]/proposals/index.tsx @@ -8,7 +8,7 @@ import { ModalType } from '../../../../components/ui/modals/ModalProvider'; import { useFractalModal } from '../../../../components/ui/modals/useFractalModal'; import PageHeader from '../../../../components/ui/page/Header/PageHeader'; import { DAO_ROUTES } from '../../../../constants/routes'; -import useSubmitProposal from '../../../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../../providers/App/AppProvider'; import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider'; import { AzoriusGovernance, DecentGovernance, GovernanceType } from '../../../../types'; @@ -33,7 +33,7 @@ export default function ProposalsPage() { } return false; }, [azoriusGovernance]); - const { canUserCreateProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const showWrapTokenButton = !!azoriusGovernance.votesToken?.underlyingTokenData; const showUnWrapTokenButton = diff --git a/src/pages/daos/[daoAddress]/proposals/new/index.tsx b/src/pages/daos/[daoAddress]/proposals/new/index.tsx index a148cd9a5f..bd0954259a 100644 --- a/src/pages/daos/[daoAddress]/proposals/new/index.tsx +++ b/src/pages/daos/[daoAddress]/proposals/new/index.tsx @@ -16,6 +16,7 @@ import { DAO_ROUTES } from '../../../../../constants/routes'; import { usePrepareProposal } from '../../../../../hooks/DAO/proposal/usePrepareProposal'; import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitProposal'; import { useCreateProposalSchema } from '../../../../../hooks/schemas/proposalCreate/useCreateProposalSchema'; +import { useCanUserCreateProposal } from '../../../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../../../providers/App/AppProvider'; import { useNetworkConfig } from '../../../../../providers/NetworkConfig/NetworkConfigProvider'; import { CreateProposalForm, CreateProposalState, GovernanceType } from '../../../../../types'; @@ -32,7 +33,8 @@ export default function ProposalCreatePage() { const { addressPrefix } = useNetworkConfig(); const { createProposalValidation } = useCreateProposalSchema(); const { prepareProposal } = usePrepareProposal(); - const { submitProposal, pendingCreateTx, canUserCreateProposal } = useSubmitProposal(); + const { submitProposal, pendingCreateTx } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const navigate = useNavigate(); const { t } = useTranslation(['proposal', 'common', 'breadcrumbs']); diff --git a/src/pages/daos/[daoAddress]/treasury/index.tsx b/src/pages/daos/[daoAddress]/treasury/index.tsx index bf8534f410..46c8dcbda7 100644 --- a/src/pages/daos/[daoAddress]/treasury/index.tsx +++ b/src/pages/daos/[daoAddress]/treasury/index.tsx @@ -7,7 +7,7 @@ import { TitledInfoBox } from '../../../../components/ui/containers/TitledInfoBo import { ModalType } from '../../../../components/ui/modals/ModalProvider'; import { useFractalModal } from '../../../../components/ui/modals/useFractalModal'; import PageHeader from '../../../../components/ui/page/Header/PageHeader'; -import useSubmitProposal from '../../../../hooks/DAO/proposal/useSubmitProposal'; +import { useCanUserCreateProposal } from '../../../../hooks/utils/useCanUserSubmitProposal'; import { useFractal } from '../../../../providers/App/AppProvider'; export default function Treasury() { @@ -16,7 +16,7 @@ export default function Treasury() { } = useFractal(); const { t } = useTranslation('treasury'); const treasuryTotal = useTreasuryTotalBN(); - const { canUserCreateProposal } = useSubmitProposal(); + const { canUserCreateProposal } = useCanUserCreateProposal(); const showButton = canUserCreateProposal && !treasuryTotal.isZero(); return (