Skip to content

Commit

Permalink
Remove the safeSingletonContract object from useSafeContracts, and fi…
Browse files Browse the repository at this point in the history
…x downstream issues
  • Loading branch information
adamgall committed May 7, 2024
1 parent 476155d commit 91c0f27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
15 changes: 10 additions & 5 deletions src/hooks/DAO/loaders/useFractalFreeze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FreezeVoteCastEvent } from '@fractal-framework/fractal-contracts/dist/t
import { useCallback, useEffect, useRef } from 'react';
import { getAddress, getContract, zeroAddress } from 'viem';
import { useAccount, usePublicClient } from 'wagmi';
import GnosisSafeL2Abi from '../../../assets/abi/GnosisSafeL2';
import VotesERC20Abi from '../../../assets/abi/VotesERC20';
import {
isWithinFreezeProposalPeriod,
Expand Down Expand Up @@ -98,13 +99,17 @@ export const useFractalFreeze = ({
isFrozen,
};

const { safeSingletonContract, freezeERC20VotingMasterCopyContract } = baseContracts;
const { freezeERC20VotingMasterCopyContract } = baseContracts;

if (freezeVotingType === FreezeVotingType.MULTISIG) {
const safeContract = safeSingletonContract!.asProvider.attach(
await (freezeVotingContract as MultisigFreezeVoting).parentGnosisSafe(),
);
const owners = await safeContract.getOwners();
const safeContract = getContract({
abi: GnosisSafeL2Abi,
address: getAddress(
await (freezeVotingContract as MultisigFreezeVoting).parentGnosisSafe(),
),
client: publicClient,
});
const owners = await safeContract.read.getOwners();
userHasVotes = owners.find(owner => owner === account) !== undefined;
} else if (freezeVotingType === FreezeVotingType.ERC20) {
const freezeERC20VotingContract = freezeERC20VotingMasterCopyContract.asProvider.attach(
Expand Down
9 changes: 0 additions & 9 deletions src/hooks/safe/useSafeContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@fractal-framework/fractal-contracts';
import { useMemo } from 'react';
import { MultiSend__factory } from '../../assets/typechain-types/usul';
import { GnosisSafeL2__factory } from '../../assets/typechain-types/usul/factories/@gnosis.pm/safe-contracts/contracts';
import { useEthersProvider } from '../../providers/Ethers/hooks/useEthersProvider';
import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider';
import useSignerOrProvider from '../utils/useSignerOrProvider';
Expand All @@ -23,7 +22,6 @@ export default function useSafeContracts() {

const {
contracts: {
safe,
linearVotingMasterCopy,
multisend,
fractalAzoriusMasterCopy,
Expand Down Expand Up @@ -61,11 +59,6 @@ export default function useSafeContracts() {
asProvider: LinearERC721Voting__factory.connect(linearVotingERC721MasterCopy, provider),
};

const safeSingletonContract = {
asSigner: GnosisSafeL2__factory.connect(safe, signerOrProvider),
asProvider: GnosisSafeL2__factory.connect(safe, provider),
};

const fractalModuleMasterCopyContract = {
asSigner: FractalModule__factory.connect(fractalModuleMasterCopy, signerOrProvider),
asProvider: FractalModule__factory.connect(fractalModuleMasterCopy, provider),
Expand Down Expand Up @@ -111,7 +104,6 @@ export default function useSafeContracts() {
multiSendContract,
fractalAzoriusMasterCopyContract,
linearVotingMasterCopyContract,
safeSingletonContract,
fractalModuleMasterCopyContract,
multisigFreezeGuardMasterCopyContract,
azoriusFreezeGuardMasterCopyContract,
Expand All @@ -122,7 +114,6 @@ export default function useSafeContracts() {
linearVotingERC721MasterCopyContract,
};
}, [
safe,
linearVotingMasterCopy,
fractalAzoriusMasterCopy,
multisend,
Expand Down

0 comments on commit 91c0f27

Please sign in to comment.