diff --git a/src/components/pages/DaoSettings/components/Metadata/index.tsx b/src/components/pages/DaoSettings/components/Metadata/index.tsx index 3e17271262..6d373b6e9d 100644 --- a/src/components/pages/DaoSettings/components/Metadata/index.tsx +++ b/src/components/pages/DaoSettings/components/Metadata/index.tsx @@ -188,7 +188,7 @@ export default function MetadataContainer() { onChange={handleSnapshotURLChange} value={snapshotURL} disabled={!userHasVotingWeight} - placeholder="example.eth" + placeholder="httpsexample.eth" testId="daoSettings.snapshotUrl" gridContainerProps={{ display: 'inline-flex', diff --git a/src/components/pages/DaoSettings/components/Signers/hooks/useAddSigner.ts b/src/components/pages/DaoSettings/components/Signers/hooks/useAddSigner.ts index 5c22f89455..824eb92b0e 100644 --- a/src/components/pages/DaoSettings/components/Signers/hooks/useAddSigner.ts +++ b/src/components/pages/DaoSettings/components/Signers/hooks/useAddSigner.ts @@ -8,9 +8,7 @@ import { ProposalExecuteData } from '../../../../../../types'; const useAddSigner = () => { const { submitProposal } = useSubmitProposal(); const { t } = useTranslation(['modals']); - const { - baseContracts: { safeSingletonContract }, - } = useFractal(); + const { baseContracts } = useFractal(); const addSigner = useCallback( async ({ newSigner, @@ -25,6 +23,10 @@ const useAddSigner = () => { daoAddress: string | null; close: () => void; }) => { + if (!baseContracts) { + return; + } + const { safeSingletonContract } = baseContracts; const description = 'Add Signer'; const calldatas = [ @@ -54,7 +56,7 @@ const useAddSigner = () => { failedToastMessage: t('addSignerFailureToastMessage'), }); }, - [safeSingletonContract.asSigner.interface, submitProposal, t] + [baseContracts, submitProposal, t] ); return addSigner; diff --git a/src/components/pages/DaoSettings/components/Signers/hooks/useRemoveSigner.ts b/src/components/pages/DaoSettings/components/Signers/hooks/useRemoveSigner.ts index da247c3edd..16ee429dbd 100644 --- a/src/components/pages/DaoSettings/components/Signers/hooks/useRemoveSigner.ts +++ b/src/components/pages/DaoSettings/components/Signers/hooks/useRemoveSigner.ts @@ -20,11 +20,13 @@ const useRemoveSigner = ({ }) => { const { submitProposal } = useSubmitProposal(); const { t } = useTranslation(['modals']); - const { - baseContracts: { safeSingletonContract }, - } = useFractal(); + const { baseContracts } = useFractal(); const removeSigner = useCallback(async () => { + if (!baseContracts) { + return; + } + const { safeSingletonContract } = baseContracts; const description = 'Remove Signers'; const calldatas = [ @@ -53,16 +55,7 @@ const useRemoveSigner = ({ successToastMessage: t('removeSignerSuccessToastMessage'), failedToastMessage: t('removeSignerFailureToastMessage'), }); - }, [ - safeSingletonContract.asProvider.interface, - prevSigner, - signerToRemove, - threshold, - daoAddress, - submitProposal, - nonce, - t, - ]); + }, [baseContracts, prevSigner, signerToRemove, threshold, daoAddress, submitProposal, nonce, t]); return removeSigner; }; diff --git a/src/hooks/DAO/loaders/governance/useERC20Claim.ts b/src/hooks/DAO/loaders/governance/useERC20Claim.ts index a9fc4e0424..193bdd9b3f 100644 --- a/src/hooks/DAO/loaders/governance/useERC20Claim.ts +++ b/src/hooks/DAO/loaders/governance/useERC20Claim.ts @@ -9,13 +9,13 @@ import { FractalGovernanceAction } from '../../../../providers/App/governance/ac export function useERC20Claim() { const { governanceContracts: { tokenContract }, - baseContracts: { claimingMasterCopyContract }, + baseContracts, action, } = useFractal(); const loadTokenClaimContract = useCallback(async () => { - if (!claimingMasterCopyContract || !tokenContract) return; - + if (!baseContracts || !tokenContract) return; + const { claimingMasterCopyContract } = baseContracts; const approvalFilter = tokenContract.asProvider.filters.Approval(); const approvals = await tokenContract.asProvider.queryFilter(approvalFilter); if (!approvals.length) return; @@ -38,7 +38,7 @@ export function useERC20Claim() { type: FractalGovernanceAction.SET_CLAIMING_CONTRACT, payload: possibleTokenClaimContract, }); - }, [claimingMasterCopyContract, tokenContract, action]); + }, [baseContracts, tokenContract, action]); useEffect(() => { loadTokenClaimContract(); diff --git a/src/hooks/DAO/loaders/useFractalModules.ts b/src/hooks/DAO/loaders/useFractalModules.ts index a09d54c46b..96df63e86a 100644 --- a/src/hooks/DAO/loaders/useFractalModules.ts +++ b/src/hooks/DAO/loaders/useFractalModules.ts @@ -4,9 +4,7 @@ import { FractalModuleData, FractalModuleType } from '../../../types'; import { useMasterCopy } from '../../utils/useMasterCopy'; export const useFractalModules = () => { - const { - baseContracts: { fractalAzoriusMasterCopyContract, fractalModuleMasterCopyContract }, - } = useFractal(); + const { baseContracts } = useFractal(); const { getZodiacModuleProxyMasterCopyData } = useMasterCopy(); const lookupModules = useCallback( async (_moduleAddresses: string[]) => { @@ -16,15 +14,17 @@ export const useFractalModules = () => { let safeModule: FractalModuleData; - if (masterCopyData.isAzorius) { + if (masterCopyData.isAzorius && baseContracts) { safeModule = { - moduleContract: fractalAzoriusMasterCopyContract.asSigner.attach(moduleAddress), + moduleContract: + baseContracts.fractalAzoriusMasterCopyContract.asSigner.attach(moduleAddress), moduleAddress: moduleAddress, moduleType: FractalModuleType.AZORIUS, }; - } else if (masterCopyData.isFractalModule) { + } else if (masterCopyData.isFractalModule && baseContracts) { safeModule = { - moduleContract: fractalModuleMasterCopyContract.asSigner.attach(moduleAddress), + moduleContract: + baseContracts.fractalModuleMasterCopyContract.asSigner.attach(moduleAddress), moduleAddress: moduleAddress, moduleType: FractalModuleType.FRACTAL, }; @@ -41,11 +41,7 @@ export const useFractalModules = () => { ); return modules; }, - [ - fractalAzoriusMasterCopyContract, - fractalModuleMasterCopyContract, - getZodiacModuleProxyMasterCopyData, - ] + [baseContracts, getZodiacModuleProxyMasterCopyData] ); return lookupModules; }; diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 41c74bb4af..e2ce2e9ce3 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -22,26 +22,7 @@ const useBuildDAOTx = () => { } = useNetworkConfig(); const { - baseContracts: { - multiSendContract, - safeFactoryContract, - safeSingletonContract, - linearVotingMasterCopyContract, - linearVotingERC721MasterCopyContract, - fractalAzoriusMasterCopyContract, - zodiacModuleProxyFactoryContract, - fractalRegistryContract, - fractalModuleMasterCopyContract, - multisigFreezeGuardMasterCopyContract, - azoriusFreezeGuardMasterCopyContract, - freezeMultisigVotingMasterCopyContract, - freezeERC20VotingMasterCopyContract, - freezeERC721VotingMasterCopyContract, - votesTokenMasterCopyContract, - claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, - keyValuePairsContract, - }, + baseContracts, readOnly: { user, dao }, governance, governanceContracts: { erc721LinearVotingContract }, @@ -55,24 +36,29 @@ const useBuildDAOTx = () => { ) => { let azoriusContracts; - if ( - !user.address || - !signerOrProvider || - !multiSendContract || - !fractalRegistryContract || - !zodiacModuleProxyFactoryContract || - !fractalModuleMasterCopyContract || - !multisigFreezeGuardMasterCopyContract || - !freezeMultisigVotingMasterCopyContract || - !freezeERC20VotingMasterCopyContract || - !safeFactoryContract || - !safeSingletonContract || - !claimingMasterCopyContract || - !votesERC20WrapperMasterCopyContract || - !keyValuePairsContract - ) { + if (!user.address || !signerOrProvider || !baseContracts) { return; } + const { + multiSendContract, + safeFactoryContract, + safeSingletonContract, + linearVotingMasterCopyContract, + linearVotingERC721MasterCopyContract, + fractalAzoriusMasterCopyContract, + zodiacModuleProxyFactoryContract, + fractalRegistryContract, + fractalModuleMasterCopyContract, + multisigFreezeGuardMasterCopyContract, + azoriusFreezeGuardMasterCopyContract, + freezeMultisigVotingMasterCopyContract, + freezeERC20VotingMasterCopyContract, + freezeERC721VotingMasterCopyContract, + votesTokenMasterCopyContract, + claimingMasterCopyContract, + votesERC20WrapperMasterCopyContract, + keyValuePairsContract, + } = baseContracts; if ( createOptions.includes(GovernanceType.AZORIUS_ERC721) && @@ -105,7 +91,7 @@ const useBuildDAOTx = () => { } as AzoriusContracts; } - const baseContracts = { + const buildrerBaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asSigner, fractalRegistryContract: fractalRegistryContract.asSigner, safeFactoryContract: safeFactoryContract.asSigner, @@ -121,7 +107,7 @@ const useBuildDAOTx = () => { const txBuilderFactory = new TxBuilderFactory( signerOrProvider, - baseContracts, + buildrerBaseContracts, azoriusContracts, daoData, fallbackHandler, @@ -165,24 +151,7 @@ const useBuildDAOTx = () => { [ user.address, signerOrProvider, - multiSendContract, - fractalRegistryContract, - zodiacModuleProxyFactoryContract, - fractalModuleMasterCopyContract, - multisigFreezeGuardMasterCopyContract, - freezeMultisigVotingMasterCopyContract, - freezeERC20VotingMasterCopyContract, - freezeERC721VotingMasterCopyContract, - safeFactoryContract, - safeSingletonContract, - claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, - keyValuePairsContract, - fractalAzoriusMasterCopyContract, - linearVotingMasterCopyContract, - linearVotingERC721MasterCopyContract, - votesTokenMasterCopyContract, - azoriusFreezeGuardMasterCopyContract, + baseContracts, erc721LinearVotingContract, dao, governance, diff --git a/src/hooks/DAO/useCreateSubDAOProposal.ts b/src/hooks/DAO/useCreateSubDAOProposal.ts index e0ea6c89ad..36c2d14d5a 100644 --- a/src/hooks/DAO/useCreateSubDAOProposal.ts +++ b/src/hooks/DAO/useCreateSubDAOProposal.ts @@ -8,9 +8,7 @@ import useSubmitProposal from './proposal/useSubmitProposal'; import useBuildDAOTx from './useBuildDAOTx'; export const useCreateSubDAOProposal = () => { - const { - baseContracts: { multiSendContract, fractalRegistryContract }, - } = useFractal(); + const { baseContracts } = useFractal(); const { t } = useTranslation(['daoCreate', 'proposal', 'proposalMetadata']); const { submitProposal, pendingCreateTx, canUserCreateProposal } = useSubmitProposal(); @@ -27,9 +25,10 @@ export const useCreateSubDAOProposal = () => { successCallback: (daoAddress: string) => void ) => { const propose = async () => { - if (!multiSendContract || !fractalRegistryContract || !daoAddress) { + if (!baseContracts || !daoAddress) { return; } + const { multiSendContract, fractalRegistryContract } = baseContracts; const builtSafeTx = await build(daoData, daoAddress, azoriusGovernance.votesToken?.address); if (!builtSafeTx) { @@ -67,15 +66,7 @@ export const useCreateSubDAOProposal = () => { }; propose(); }, - [ - multiSendContract, - fractalRegistryContract, - build, - daoAddress, - submitProposal, - azoriusGovernance, - t, - ] + [baseContracts, build, daoAddress, submitProposal, azoriusGovernance, t] ); return { proposeDao, pendingCreateTx, canUserCreateProposal } as const; diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index a992afe8c8..9ed222c273 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -24,24 +24,7 @@ const useDeployAzorius = () => { } = useNetworkConfig(); const { node: { daoAddress, safe }, - baseContracts: { - multiSendContract, - safeFactoryContract, - safeSingletonContract, - linearVotingMasterCopyContract, - fractalAzoriusMasterCopyContract, - zodiacModuleProxyFactoryContract, - fractalRegistryContract, - fractalModuleMasterCopyContract, - multisigFreezeGuardMasterCopyContract, - azoriusFreezeGuardMasterCopyContract, - freezeMultisigVotingMasterCopyContract, - freezeERC20VotingMasterCopyContract, - votesTokenMasterCopyContract, - claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, - keyValuePairsContract, - }, + baseContracts, } = useFractal(); const { t } = useTranslation(['transaction', 'proposalMetadata']); @@ -53,9 +36,27 @@ const useDeployAzorius = () => { shouldSetName?: boolean, shouldSetSnapshot?: boolean ) => { - if (!daoAddress || !canUserCreateProposal || !safe) { + if (!daoAddress || !canUserCreateProposal || !safe || !baseContracts) { return; } + const { + multiSendContract, + safeFactoryContract, + safeSingletonContract, + linearVotingMasterCopyContract, + fractalAzoriusMasterCopyContract, + zodiacModuleProxyFactoryContract, + fractalRegistryContract, + fractalModuleMasterCopyContract, + multisigFreezeGuardMasterCopyContract, + azoriusFreezeGuardMasterCopyContract, + freezeMultisigVotingMasterCopyContract, + freezeERC20VotingMasterCopyContract, + votesTokenMasterCopyContract, + claimingMasterCopyContract, + votesERC20WrapperMasterCopyContract, + keyValuePairsContract, + } = baseContracts; let azoriusContracts; azoriusContracts = { @@ -67,7 +68,7 @@ const useDeployAzorius = () => { votesERC20WrapperMasterCopyContract: votesERC20WrapperMasterCopyContract.asProvider, } as AzoriusContracts; - const baseContracts = { + const builderBaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asProvider, fractalRegistryContract: fractalRegistryContract.asProvider, safeFactoryContract: safeFactoryContract.asProvider, @@ -82,7 +83,7 @@ const useDeployAzorius = () => { const txBuilderFactory = new TxBuilderFactory( signerOrProvider, - baseContracts, + builderBaseContracts, azoriusContracts, daoData, fallbackHandler, @@ -125,22 +126,7 @@ const useDeployAzorius = () => { }, [ signerOrProvider, - multiSendContract, - fractalRegistryContract, - zodiacModuleProxyFactoryContract, - fractalModuleMasterCopyContract, - multisigFreezeGuardMasterCopyContract, - freezeMultisigVotingMasterCopyContract, - freezeERC20VotingMasterCopyContract, - safeFactoryContract, - safeSingletonContract, - claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, - keyValuePairsContract, - fractalAzoriusMasterCopyContract, - linearVotingMasterCopyContract, - votesTokenMasterCopyContract, - azoriusFreezeGuardMasterCopyContract, + baseContracts, t, canUserCreateProposal, daoAddress, diff --git a/src/hooks/DAO/useDeployDAO.ts b/src/hooks/DAO/useDeployDAO.ts index 063fbc29f1..5bcff69018 100644 --- a/src/hooks/DAO/useDeployDAO.ts +++ b/src/hooks/DAO/useDeployDAO.ts @@ -6,9 +6,7 @@ import { useTransaction } from '../utils/useTransaction'; import useBuildDAOTx from './useBuildDAOTx'; const useDeployDAO = () => { - const { - baseContracts: { multiSendContract }, - } = useFractal(); + const { baseContracts } = useFractal(); const [contractCallDeploy, contractCallPending] = useTransaction(); const [build] = useBuildDAOTx(); @@ -21,10 +19,12 @@ const useDeployDAO = () => { successCallback: (daoAddress: string) => void ) => { const deploy = async () => { - if (!multiSendContract) { + if (!baseContracts) { return; } + const { multiSendContract } = baseContracts; + const builtSafeTx = await build(daoData); if (!builtSafeTx) { return; @@ -43,7 +43,7 @@ const useDeployDAO = () => { deploy(); }, - [build, contractCallDeploy, multiSendContract, t] + [build, contractCallDeploy, baseContracts, t] ); return [deployDao, contractCallPending] as const; diff --git a/src/hooks/utils/useMasterCopy.ts b/src/hooks/utils/useMasterCopy.ts index 35d0a27ab9..dfcb26f7c3 100644 --- a/src/hooks/utils/useMasterCopy.ts +++ b/src/hooks/utils/useMasterCopy.ts @@ -8,53 +8,43 @@ import { useLocalStorage } from './cache/useLocalStorage'; export function useMasterCopy() { const { getValue, setValue } = useLocalStorage(); - const { - baseContracts: { - zodiacModuleProxyFactoryContract, - linearVotingMasterCopyContract, - linearVotingERC721MasterCopyContract, - multisigFreezeGuardMasterCopyContract, - freezeMultisigVotingMasterCopyContract, - freezeERC721VotingMasterCopyContract, - fractalAzoriusMasterCopyContract, - fractalModuleMasterCopyContract, - }, - } = useFractal(); + const { baseContracts } = useFractal(); const isOzLinearVoting = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === linearVotingMasterCopyContract.asProvider.address, - [linearVotingMasterCopyContract] + masterCopyAddress === baseContracts?.linearVotingMasterCopyContract.asProvider.address, + [baseContracts] ); const isOzLinearVotingERC721 = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === linearVotingERC721MasterCopyContract.asProvider.address, - [linearVotingERC721MasterCopyContract] + masterCopyAddress === baseContracts?.linearVotingERC721MasterCopyContract.asProvider.address, + [baseContracts] ); const isMultisigFreezeGuard = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === multisigFreezeGuardMasterCopyContract.asProvider.address, - [multisigFreezeGuardMasterCopyContract] + masterCopyAddress === baseContracts?.multisigFreezeGuardMasterCopyContract.asProvider.address, + [baseContracts] ); const isMultisigFreezeVoting = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === freezeMultisigVotingMasterCopyContract.asProvider.address, - [freezeMultisigVotingMasterCopyContract] + masterCopyAddress === + baseContracts?.freezeMultisigVotingMasterCopyContract.asProvider.address, + [baseContracts] ); const isERC721FreezeVoting = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === freezeERC721VotingMasterCopyContract.asProvider.address, - [freezeERC721VotingMasterCopyContract] + masterCopyAddress === baseContracts?.freezeERC721VotingMasterCopyContract.asProvider.address, + [baseContracts] ); const isAzorius = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === fractalAzoriusMasterCopyContract.asProvider.address, - [fractalAzoriusMasterCopyContract] + masterCopyAddress === baseContracts?.fractalAzoriusMasterCopyContract.asProvider.address, + [baseContracts] ); const isFractalModule = useCallback( (masterCopyAddress: string | `0x${string}`) => - masterCopyAddress === fractalModuleMasterCopyContract.asProvider.address, - [fractalModuleMasterCopyContract] + masterCopyAddress === baseContracts?.fractalModuleMasterCopyContract.asProvider.address, + [baseContracts] ); const getMasterCopyAddress = useCallback( @@ -80,10 +70,16 @@ export function useMasterCopy() { const getZodiacModuleProxyMasterCopyData = useCallback( async function (proxyAddress: string | `0x${string}`) { - const contract = getEventRPC(zodiacModuleProxyFactoryContract); - const [masterCopyAddress, error] = await getMasterCopyAddress(contract, proxyAddress); - if (error) { - console.error(error); + let masterCopyAddress = ''; + let error; + if (baseContracts) { + const contract = getEventRPC( + baseContracts?.zodiacModuleProxyFactoryContract + ); + [masterCopyAddress, error] = await getMasterCopyAddress(contract, proxyAddress); + if (error) { + console.error(error); + } } return { address: masterCopyAddress, @@ -97,7 +93,6 @@ export function useMasterCopy() { }; }, [ - zodiacModuleProxyFactoryContract, getMasterCopyAddress, isAzorius, isFractalModule, @@ -106,6 +101,7 @@ export function useMasterCopy() { isMultisigFreezeVoting, isOzLinearVoting, isOzLinearVotingERC721, + baseContracts, ] );