From 317ad5b153bdd57971003814cd15fbe96ccd1199 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 15:25:32 -0400 Subject: [PATCH] Remove linearVotingERC721MasterCopyContract from FractalContracts, AzoriusContracts, useSafeContracts --- src/hooks/DAO/useBuildDAOTx.ts | 13 +++------ src/hooks/DAO/useDeployAzorius.ts | 5 ++-- src/hooks/safe/useSafeContracts.ts | 9 ------- src/models/AzoriusTxBuilder.ts | 43 +++++++++++++----------------- src/models/DaoTxBuilder.ts | 3 +-- src/models/TxBuilderFactory.ts | 4 +++ src/types/fractal.ts | 2 -- src/types/strategyAzorius.ts | 7 +---- 8 files changed, 30 insertions(+), 56 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index d40ab0721e..ee4aed99db 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -18,7 +18,6 @@ import useSignerOrProvider from '../utils/useSignerOrProvider'; const useBuildDAOTx = () => { const signerOrProvider = useSignerOrProvider(); const { - createOptions, contracts: { fallbackHandler, votesERC20WrapperMasterCopy, @@ -32,6 +31,7 @@ const useBuildDAOTx = () => { claimingMasterCopy: erc20ClaimMasterCopy, fractalModuleMasterCopy, linearVotingMasterCopy: linearERC20VotingMasterCopy, + linearVotingERC721MasterCopy: linearERC721VotingMasterCopy, }, } = useNetworkConfig(); @@ -55,7 +55,6 @@ const useBuildDAOTx = () => { return; } const { - linearVotingERC721MasterCopyContract, fractalAzoriusMasterCopyContract, fractalModuleMasterCopyContract, multisigFreezeGuardMasterCopyContract, @@ -65,12 +64,6 @@ const useBuildDAOTx = () => { freezeERC721VotingMasterCopyContract, } = baseContracts; - if ( - createOptions.includes(GovernanceType.AZORIUS_ERC721) && - (!freezeERC721VotingMasterCopyContract || !linearVotingERC721MasterCopyContract) - ) { - return; - } if ( daoData.governance === GovernanceType.AZORIUS_ERC20 || daoData.governance === GovernanceType.AZORIUS_ERC721 @@ -81,7 +74,6 @@ const useBuildDAOTx = () => { azoriusContracts = { fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asSigner, - linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asSigner, azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asSigner, }; } @@ -112,6 +104,7 @@ const useBuildDAOTx = () => { erc20ClaimMasterCopy, fractalModuleMasterCopy, linearERC20VotingMasterCopy, + linearERC721VotingMasterCopy, parentAddress, parentTokenAddress, ); @@ -157,7 +150,6 @@ const useBuildDAOTx = () => { erc721LinearVotingContractAddress, dao, governance, - createOptions, fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy, @@ -170,6 +162,7 @@ const useBuildDAOTx = () => { erc20ClaimMasterCopy, fractalModuleMasterCopy, linearERC20VotingMasterCopy, + linearERC721VotingMasterCopy, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index c67317aac2..f762d0eba5 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -37,6 +37,7 @@ const useDeployAzorius = () => { claimingMasterCopy: erc20ClaimMasterCopy, fractalModuleMasterCopy, linearVotingMasterCopy: linearERC20VotingMasterCopy, + linearVotingERC721MasterCopy: linearERC721VotingMasterCopy, }, addressPrefix, } = useNetworkConfig(); @@ -60,7 +61,6 @@ const useDeployAzorius = () => { return; } const { - linearVotingERC721MasterCopyContract, fractalAzoriusMasterCopyContract, fractalModuleMasterCopyContract, multisigFreezeGuardMasterCopyContract, @@ -73,7 +73,6 @@ const useDeployAzorius = () => { azoriusContracts = { fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asProvider, - linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asProvider, azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider, }; @@ -103,6 +102,7 @@ const useDeployAzorius = () => { erc20ClaimMasterCopy, fractalModuleMasterCopy, linearERC20VotingMasterCopy, + linearERC721VotingMasterCopy, undefined, undefined, ); @@ -173,6 +173,7 @@ const useDeployAzorius = () => { erc20ClaimMasterCopy, fractalModuleMasterCopy, linearERC20VotingMasterCopy, + linearERC721VotingMasterCopy, ], ); diff --git a/src/hooks/safe/useSafeContracts.ts b/src/hooks/safe/useSafeContracts.ts index 1e7c86d664..ea4b0c60fb 100644 --- a/src/hooks/safe/useSafeContracts.ts +++ b/src/hooks/safe/useSafeContracts.ts @@ -5,7 +5,6 @@ import { MultisigFreezeGuard__factory, MultisigFreezeVoting__factory, Azorius__factory, - LinearERC721Voting__factory, ERC721FreezeVoting__factory, } from '@fractal-framework/fractal-contracts'; import { useMemo } from 'react'; @@ -26,7 +25,6 @@ export default function useSafeContracts() { multisigFreezeVotingMasterCopy, erc20FreezeVotingMasterCopy, erc721FreezeVotingMasterCopy, - linearVotingERC721MasterCopy, }, } = useNetworkConfig(); @@ -40,11 +38,6 @@ export default function useSafeContracts() { asProvider: Azorius__factory.connect(fractalAzoriusMasterCopy, provider), }; - const linearVotingERC721MasterCopyContract = { - asSigner: LinearERC721Voting__factory.connect(linearVotingERC721MasterCopy, signerOrProvider), - asProvider: LinearERC721Voting__factory.connect(linearVotingERC721MasterCopy, provider), - }; - const fractalModuleMasterCopyContract = { asSigner: FractalModule__factory.connect(fractalModuleMasterCopy, signerOrProvider), asProvider: FractalModule__factory.connect(fractalModuleMasterCopy, provider), @@ -89,7 +82,6 @@ export default function useSafeContracts() { freezeMultisigVotingMasterCopyContract, freezeERC20VotingMasterCopyContract, freezeERC721VotingMasterCopyContract, - linearVotingERC721MasterCopyContract, }; }, [ fractalAzoriusMasterCopy, @@ -98,7 +90,6 @@ export default function useSafeContracts() { azoriusFreezeGuardMasterCopy, multisigFreezeVotingMasterCopy, erc20FreezeVotingMasterCopy, - linearVotingERC721MasterCopy, erc721FreezeVotingMasterCopy, signerOrProvider, provider, diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 87d63762a2..c73070d48d 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -1,9 +1,4 @@ -import { - Azorius, - Azorius__factory, - LinearERC721Voting, - LinearERC721Voting__factory, -} from '@fractal-framework/fractal-contracts'; +import { Azorius, Azorius__factory } from '@fractal-framework/fractal-contracts'; import { getCreate2Address, Address, @@ -22,11 +17,12 @@ import { import ERC20ClaimAbi from '../assets/abi/ERC20Claim'; import GnosisSafeL2Abi from '../assets/abi/GnosisSafeL2'; import LinearERC20VotingAbi from '../assets/abi/LinearERC20Voting'; +import LinearERC721VotingAbi from '../assets/abi/LinearERC721Voting'; import ModuleProxyFactoryAbi from '../assets/abi/ModuleProxyFactory'; import VotesERC20Abi from '../assets/abi/VotesERC20'; import VotesERC20WrapperAbi from '../assets/abi/VotesERC20Wrapper'; import { SENTINEL_ADDRESS } from '../constants/common'; -import { buildContractCall, buildContractCallViem, getRandomBytes } from '../helpers'; +import { buildContractCallViem, getRandomBytes } from '../helpers'; import { BaseContracts, SafeTransaction, @@ -55,7 +51,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { public azoriusContract: Azorius | undefined; public linearERC20VotingAddress: Address | undefined; - public linearERC721VotingContract: LinearERC721Voting | undefined; + public linearERC721VotingAddress: Address | undefined; public votesTokenAddress: Address | undefined; private votesERC20WrapperMasterCopyAddress: string; @@ -64,6 +60,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { private multiSendCallOnlyAddress: Address; private erc20ClaimMasterCopyAddress: Address; private linearERC20VotingMasterCopyAddress: Address; + private linearERC721VotingMasterCopyAddress: Address; private tokenNonce: bigint; private strategyNonce: bigint; @@ -83,6 +80,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { multiSendCallOnlyAddress: Address, erc20ClaimMasterCopyAddress: Address, linearERC20VotingMasterCopyAddress: Address, + linearERC721VotingMasterCopyAddress: Address, parentAddress?: Address, parentTokenAddress?: Address, ) { @@ -109,6 +107,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { this.multiSendCallOnlyAddress = multiSendCallOnlyAddress; this.erc20ClaimMasterCopyAddress = erc20ClaimMasterCopyAddress; this.linearERC20VotingMasterCopyAddress = linearERC20VotingMasterCopyAddress; + this.linearERC721VotingMasterCopyAddress = linearERC721VotingMasterCopyAddress; if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) { daoData = daoData as AzoriusERC20DAO; @@ -174,8 +173,9 @@ export class AzoriusTxBuilder extends BaseTxBuilder { false, ); } else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) { - return buildContractCall( - this.linearERC721VotingContract!, + return buildContractCallViem( + LinearERC721VotingAbi, + this.linearERC721VotingAddress!, 'setAzorius', // contract function name [this.azoriusContract!.address], 0, @@ -240,7 +240,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { [ daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20 ? this.linearERC20VotingMasterCopyAddress - : this.azoriusContracts!.linearVotingERC721MasterCopyContract.address, + : this.linearERC721VotingMasterCopyAddress, this.encodedStrategySetupData, this.strategyNonce, ], @@ -512,18 +512,14 @@ export class AzoriusTxBuilder extends BaseTxBuilder { ], ); - const encodedStrategySetupData = - this.azoriusContracts!.linearVotingERC721MasterCopyContract.interface.encodeFunctionData( - 'setUp', - [encodedStrategyInitParams], - ); - - if (!isHex(encodedStrategySetupData)) { - throw new Error('Error encoding strategy setup data'); - } + const encodedStrategySetupData = encodeFunctionData({ + abi: LinearERC721VotingAbi, + functionName: 'setUp', + args: [encodedStrategyInitParams], + }); const strategyByteCodeLinear = generateContractByteCodeLinear( - getAddress(this.azoriusContracts!.linearVotingERC721MasterCopyContract.address), + this.linearERC721VotingMasterCopyAddress, ); const strategySalt = keccak256( @@ -596,10 +592,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { this.votesTokenAddress = this.predictedTokenAddress; this.linearERC20VotingAddress = this.predictedStrategyAddress; } else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) { - this.linearERC721VotingContract = LinearERC721Voting__factory.connect( - this.predictedStrategyAddress!, - this.signerOrProvider, - ); + this.linearERC721VotingAddress = this.predictedStrategyAddress; } } } diff --git a/src/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index 3f7ec7ae79..f2bbc61c17 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -115,8 +115,7 @@ export class DaoTxBuilder extends BaseTxBuilder { if (this.parentAddress) { const freezeGuardTxBuilder = this.txBuilderFactory.createFreezeGuardTxBuilder( azoriusTxBuilder.azoriusContract!.address, - azoriusTxBuilder.linearERC20VotingAddress ?? - azoriusTxBuilder.linearERC721VotingContract?.address, + azoriusTxBuilder.linearERC20VotingAddress ?? azoriusTxBuilder.linearERC721VotingAddress, this.parentStrategyType, this.parentStrategyAddress, ); diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index 505455c4fd..99fa343f07 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -40,6 +40,7 @@ export class TxBuilderFactory extends BaseTxBuilder { private erc20ClaimMasterCopyAddress: string; private fractalModuleMasterCopyAddress: string; private linearERC20VotingMasterCopyAddress: string; + private linearERC721VotingMasterCopyAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -59,6 +60,7 @@ export class TxBuilderFactory extends BaseTxBuilder { erc20ClaimMasterCopyAddress: string, fractalModuleMasterCopyAddress: string, linearERC20VotingMasterCopyAddress: string, + linearERC721VotingMasterCopyAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -85,6 +87,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.erc20ClaimMasterCopyAddress = erc20ClaimMasterCopyAddress; this.fractalModuleMasterCopyAddress = fractalModuleMasterCopyAddress; this.linearERC20VotingMasterCopyAddress = linearERC20VotingMasterCopyAddress; + this.linearERC721VotingMasterCopyAddress = linearERC721VotingMasterCopyAddress; } public setSafeContract(safeAddress: Address) { @@ -191,6 +194,7 @@ export class TxBuilderFactory extends BaseTxBuilder { getAddress(this.multiSendCallOnlyAddress), getAddress(this.erc20ClaimMasterCopyAddress), getAddress(this.linearERC20VotingMasterCopyAddress), + getAddress(this.linearERC721VotingMasterCopyAddress), this.parentAddress ? getAddress(this.parentAddress) : undefined, this.parentTokenAddress ? getAddress(this.parentTokenAddress) : undefined, ); diff --git a/src/types/fractal.ts b/src/types/fractal.ts index f60c21326c..625610acca 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -6,7 +6,6 @@ import { MultisigFreezeVoting, MultisigFreezeGuard, ERC721FreezeVoting, - LinearERC721Voting, } from '@fractal-framework/fractal-contracts'; import { SafeMultisigTransactionWithTransfersResponse, @@ -318,7 +317,6 @@ export interface NodeHierarchy { export interface FractalContracts { fractalAzoriusMasterCopyContract: ContractConnection; - linearVotingERC721MasterCopyContract: ContractConnection; fractalModuleMasterCopyContract: ContractConnection; multisigFreezeGuardMasterCopyContract: ContractConnection; azoriusFreezeGuardMasterCopyContract: ContractConnection; diff --git a/src/types/strategyAzorius.ts b/src/types/strategyAzorius.ts index e46b3d25f5..a81fe8b6c8 100644 --- a/src/types/strategyAzorius.ts +++ b/src/types/strategyAzorius.ts @@ -1,11 +1,6 @@ -import { - Azorius, - AzoriusFreezeGuard, - LinearERC721Voting, -} from '@fractal-framework/fractal-contracts'; +import { Azorius, AzoriusFreezeGuard } from '@fractal-framework/fractal-contracts'; export interface AzoriusContracts { fractalAzoriusMasterCopyContract: Azorius; - linearVotingERC721MasterCopyContract: LinearERC721Voting; azoriusFreezeGuardMasterCopyContract: AzoriusFreezeGuard; }