Skip to content

Commit

Permalink
Moar linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrila committed Mar 7, 2024
1 parent d17a103 commit d969571
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,6 +23,10 @@ const useAddSigner = () => {
daoAddress: string | null;
close: () => void;
}) => {
if (!baseContracts) {
return;
}
const { safeSingletonContract } = baseContracts;
const description = 'Add Signer';

const calldatas = [
Expand Down Expand Up @@ -54,7 +56,7 @@ const useAddSigner = () => {
failedToastMessage: t('addSignerFailureToastMessage'),
});
},
[safeSingletonContract.asSigner.interface, submitProposal, t]
[baseContracts, submitProposal, t]
);

return addSigner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/DAO/loaders/governance/useERC20Claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,7 +38,7 @@ export function useERC20Claim() {
type: FractalGovernanceAction.SET_CLAIMING_CONTRACT,
payload: possibleTokenClaimContract,
});
}, [claimingMasterCopyContract, tokenContract, action]);
}, [baseContracts, tokenContract, action]);

useEffect(() => {
loadTokenClaimContract();
Expand Down
20 changes: 8 additions & 12 deletions src/hooks/DAO/loaders/useFractalModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) => {
Expand All @@ -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,
};
Expand All @@ -41,11 +41,7 @@ export const useFractalModules = () => {
);
return modules;
},
[
fractalAzoriusMasterCopyContract,
fractalModuleMasterCopyContract,
getZodiacModuleProxyMasterCopyData,
]
[baseContracts, getZodiacModuleProxyMasterCopyData]
);
return lookupModules;
};
81 changes: 25 additions & 56 deletions src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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) &&
Expand Down Expand Up @@ -105,7 +91,7 @@ const useBuildDAOTx = () => {
} as AzoriusContracts;
}

const baseContracts = {
const buildrerBaseContracts = {
fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asSigner,
fractalRegistryContract: fractalRegistryContract.asSigner,
safeFactoryContract: safeFactoryContract.asSigner,
Expand All @@ -121,7 +107,7 @@ const useBuildDAOTx = () => {

const txBuilderFactory = new TxBuilderFactory(
signerOrProvider,
baseContracts,
buildrerBaseContracts,
azoriusContracts,
daoData,
fallbackHandler,
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 4 additions & 13 deletions src/hooks/DAO/useCreateSubDAOProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit d969571

Please sign in to comment.