Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the safeSingletonContract object from useSafeContracts #1661

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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