From a635c3d5fe21d0883e51fe48d8798fa77f332358 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Mon, 6 May 2024 15:20:55 -0400 Subject: [PATCH 1/2] Turn votesERC20MasterCopy type from NetworkConfig into Address --- src/providers/NetworkConfig/networks/base.ts | 2 +- src/providers/NetworkConfig/networks/baseSepolia.ts | 2 +- src/providers/NetworkConfig/networks/mainnet.ts | 2 +- src/providers/NetworkConfig/networks/optimism.ts | 2 +- src/providers/NetworkConfig/networks/polygon.ts | 2 +- src/providers/NetworkConfig/networks/sepolia.ts | 2 +- src/types/network.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/providers/NetworkConfig/networks/base.ts b/src/providers/NetworkConfig/networks/base.ts index 86bb5b08f7..05a50696fe 100644 --- a/src/providers/NetworkConfig/networks/base.ts +++ b/src/providers/NetworkConfig/networks/base.ts @@ -46,7 +46,7 @@ export const baseConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: LinearVotingERC721.address, claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/providers/NetworkConfig/networks/baseSepolia.ts b/src/providers/NetworkConfig/networks/baseSepolia.ts index 3b9c9c9fcd..ce74e9ea1c 100644 --- a/src/providers/NetworkConfig/networks/baseSepolia.ts +++ b/src/providers/NetworkConfig/networks/baseSepolia.ts @@ -46,7 +46,7 @@ export const baseSepoliaConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: LinearVotingERC721.address, claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/providers/NetworkConfig/networks/mainnet.ts b/src/providers/NetworkConfig/networks/mainnet.ts index 785bef1a12..a1a7f94772 100644 --- a/src/providers/NetworkConfig/networks/mainnet.ts +++ b/src/providers/NetworkConfig/networks/mainnet.ts @@ -46,7 +46,7 @@ export const mainnetConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: '', // TODO - Add actual address once contract is deployed on mainnet claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/providers/NetworkConfig/networks/optimism.ts b/src/providers/NetworkConfig/networks/optimism.ts index 7ebfea0c9b..420c4de0cd 100644 --- a/src/providers/NetworkConfig/networks/optimism.ts +++ b/src/providers/NetworkConfig/networks/optimism.ts @@ -46,7 +46,7 @@ export const optimismConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: LinearVotingERC721.address, claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/providers/NetworkConfig/networks/polygon.ts b/src/providers/NetworkConfig/networks/polygon.ts index 272d547a6c..98800188a0 100644 --- a/src/providers/NetworkConfig/networks/polygon.ts +++ b/src/providers/NetworkConfig/networks/polygon.ts @@ -46,7 +46,7 @@ export const polygonConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: '', // TODO - Add actual address once contract is deployed on polygon claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/providers/NetworkConfig/networks/sepolia.ts b/src/providers/NetworkConfig/networks/sepolia.ts index 5095962b66..acf29eda6b 100644 --- a/src/providers/NetworkConfig/networks/sepolia.ts +++ b/src/providers/NetworkConfig/networks/sepolia.ts @@ -46,7 +46,7 @@ export const sepoliaConfig: NetworkConfig = { fractalAzoriusMasterCopy: Azorius.address, fractalModuleMasterCopy: FractalModule.address, fractalRegistry: FractalRegistry.address, - votesERC20MasterCopy: VotesERC20.address, + votesERC20MasterCopy: getAddress(VotesERC20.address), linearVotingERC721MasterCopy: LinearVotingERC721.address, claimingMasterCopy: ERC20Claim.address, azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address, diff --git a/src/types/network.ts b/src/types/network.ts index 1fad136fff..88f8f8edd1 100644 --- a/src/types/network.ts +++ b/src/types/network.ts @@ -31,7 +31,7 @@ export type NetworkConfig = { fractalAzoriusMasterCopy: string; fractalModuleMasterCopy: string; fractalRegistry: string; - votesERC20MasterCopy: string; + votesERC20MasterCopy: Address; linearVotingERC721MasterCopy: string; claimingMasterCopy: string; multisigFreezeGuardMasterCopy: string; From f0f4b26bc794fa5f7745025715d535fa912eca4f Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Mon, 6 May 2024 15:20:55 -0400 Subject: [PATCH 2/2] Remove votesTokenMasterCopyContract from AzoriusContracts interface and FractalContracts interface, fix all typescript issues --- src/hooks/DAO/useBuildDAOTx.ts | 7 +++---- src/hooks/DAO/useDeployAzorius.ts | 6 +++--- src/models/AzoriusTxBuilder.ts | 25 +++++++++++-------------- src/models/TxBuilderFactory.ts | 4 ++++ src/types/fractal.ts | 2 -- src/types/strategyAzorius.ts | 2 -- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 6955f50bef..f8eeeebd81 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -18,7 +18,7 @@ const useBuildDAOTx = () => { const signerOrProvider = useSignerOrProvider(); const { createOptions, - contracts: { fallbackHandler, votesERC20WrapperMasterCopy }, + contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy }, } = useNetworkConfig(); const { @@ -54,7 +54,6 @@ const useBuildDAOTx = () => { freezeMultisigVotingMasterCopyContract, freezeERC20VotingMasterCopyContract, freezeERC721VotingMasterCopyContract, - votesTokenMasterCopyContract, claimingMasterCopyContract, keyValuePairsContract, } = baseContracts; @@ -72,7 +71,6 @@ const useBuildDAOTx = () => { if ( !fractalAzoriusMasterCopyContract || !linearVotingMasterCopyContract || - !votesTokenMasterCopyContract || !azoriusFreezeGuardMasterCopyContract || !claimingMasterCopyContract ) { @@ -84,7 +82,6 @@ const useBuildDAOTx = () => { linearVotingMasterCopyContract: linearVotingMasterCopyContract.asSigner, linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asSigner, azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asSigner, - votesTokenMasterCopyContract: votesTokenMasterCopyContract.asSigner, claimingMasterCopyContract: claimingMasterCopyContract.asSigner, }; } @@ -110,6 +107,7 @@ const useBuildDAOTx = () => { daoData, fallbackHandler, votesERC20WrapperMasterCopy, + votesERC20MasterCopy, parentAddress, parentTokenAddress, ); @@ -157,6 +155,7 @@ const useBuildDAOTx = () => { createOptions, fallbackHandler, votesERC20WrapperMasterCopy, + votesERC20MasterCopy, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index c6dcf46905..7a85510812 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -21,7 +21,7 @@ const useDeployAzorius = () => { const signerOrProvider = useSignerOrProvider(); const navigate = useNavigate(); const { - contracts: { fallbackHandler, votesERC20WrapperMasterCopy }, + contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy }, addressPrefix, } = useNetworkConfig(); const { @@ -54,7 +54,6 @@ const useDeployAzorius = () => { azoriusFreezeGuardMasterCopyContract, freezeMultisigVotingMasterCopyContract, freezeERC20VotingMasterCopyContract, - votesTokenMasterCopyContract, claimingMasterCopyContract, keyValuePairsContract, } = baseContracts; @@ -64,7 +63,6 @@ const useDeployAzorius = () => { fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asProvider, linearVotingMasterCopyContract: linearVotingMasterCopyContract.asProvider, azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider, - votesTokenMasterCopyContract: votesTokenMasterCopyContract.asProvider, claimingMasterCopyContract: claimingMasterCopyContract.asProvider, } as AzoriusContracts; @@ -88,6 +86,7 @@ const useDeployAzorius = () => { daoData, fallbackHandler, votesERC20WrapperMasterCopy, + votesERC20MasterCopy, undefined, undefined, ); @@ -146,6 +145,7 @@ const useDeployAzorius = () => { fallbackHandler, addressPrefix, votesERC20WrapperMasterCopy, + votesERC20MasterCopy, ], ); diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 798526ed63..732f47e358 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -21,6 +21,7 @@ import { isHex, encodeFunctionData, } from 'viem'; +import VotesERC20Abi from '../assets/abi/VotesERC20'; import VotesERC20WrapperAbi from '../assets/abi/VotesERC20Wrapper'; import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; import { SENTINEL_ADDRESS } from '../constants/common'; @@ -57,6 +58,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { public votesTokenContract: VotesERC20 | undefined; private votesERC20WrapperMasterCopyAddress: string; + private votesERC20MasterCopyAddress: string; private tokenNonce: bigint; private strategyNonce: bigint; @@ -70,6 +72,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { daoData: AzoriusERC20DAO | AzoriusERC721DAO, safeContract: GnosisSafeL2, votesERC20WrapperMasterCopyAddress: string, + votesERC20MasterCopyAddress: string, parentAddress?: Address, parentTokenAddress?: Address, ) { @@ -90,6 +93,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { this.azoriusNonce = getRandomBytes(); this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; + this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress; if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) { daoData = daoData as AzoriusERC20DAO; @@ -188,11 +192,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { return buildContractCall( this.baseContracts.zodiacModuleProxyFactoryContract, 'deployModule', - [ - this.azoriusContracts!.votesTokenMasterCopyContract.address, - this.encodedSetupTokenData, - this.tokenNonce, - ], + [this.votesERC20MasterCopyAddress, this.encodedSetupTokenData, this.tokenNonce], 0, false, ); @@ -346,19 +346,16 @@ export class AzoriusTxBuilder extends BaseTxBuilder { ], ); - const encodedSetupTokenData = - this.azoriusContracts!.votesTokenMasterCopyContract.interface.encodeFunctionData('setUp', [ - encodedInitTokenData, - ]); - if (!isHex(encodedSetupTokenData)) { - throw new Error('Error encoding setup token data'); - } - this.encodedSetupTokenData = encodedSetupTokenData; + this.encodedSetupTokenData = encodeFunctionData({ + abi: VotesERC20Abi, + functionName: 'setUp', + args: [encodedInitTokenData], + }); } private setPredictedTokenAddress() { const tokenByteCodeLinear = generateContractByteCodeLinear( - getAddress(this.azoriusContracts!.votesTokenMasterCopyContract.address), + getAddress(this.votesERC20MasterCopyAddress), ); const tokenSalt = generateSalt(this.encodedSetupTokenData!, this.tokenNonce); diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index a45654eea2..cae1742ce3 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -30,6 +30,7 @@ export class TxBuilderFactory extends BaseTxBuilder { public fallbackHandler: string; private votesERC20WrapperMasterCopyAddress: string; + private votesERC20MasterCopyAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -38,6 +39,7 @@ export class TxBuilderFactory extends BaseTxBuilder { daoData: SafeMultisigDAO | AzoriusERC20DAO | AzoriusERC721DAO | SubDAO, fallbackHandler: string, votesERC20WrapperMasterCopyAddress: string, + votesERC20MasterCopyAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -53,6 +55,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.fallbackHandler = fallbackHandler; this.saltNum = getRandomBytes(); this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; + this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress; } public setSafeContract(safeAddress: string) { @@ -135,6 +138,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.daoData as AzoriusERC20DAO, this.safeContract!, this.votesERC20WrapperMasterCopyAddress, + this.votesERC20MasterCopyAddress, 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 798238f5f3..c4cb228a12 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -9,7 +9,6 @@ import { ERC20Claim, ERC20FreezeVoting, MultisigFreezeVoting, - VotesERC20, MultisigFreezeGuard, KeyValuePairs, ERC721FreezeVoting, @@ -347,7 +346,6 @@ export interface FractalContracts { freezeMultisigVotingMasterCopyContract: ContractConnection; freezeERC20VotingMasterCopyContract: ContractConnection; freezeERC721VotingMasterCopyContract: ContractConnection; - votesTokenMasterCopyContract: ContractConnection; claimingMasterCopyContract: ContractConnection; keyValuePairsContract: ContractConnection; } diff --git a/src/types/strategyAzorius.ts b/src/types/strategyAzorius.ts index 0e3388290e..135c059083 100644 --- a/src/types/strategyAzorius.ts +++ b/src/types/strategyAzorius.ts @@ -2,7 +2,6 @@ import { Azorius, LinearERC20Voting, AzoriusFreezeGuard, - VotesERC20, ERC20Claim, LinearERC721Voting, } from '@fractal-framework/fractal-contracts'; @@ -12,6 +11,5 @@ export interface AzoriusContracts { linearVotingMasterCopyContract: LinearERC20Voting; linearVotingERC721MasterCopyContract: LinearERC721Voting; azoriusFreezeGuardMasterCopyContract: AzoriusFreezeGuard; - votesTokenMasterCopyContract: VotesERC20; claimingMasterCopyContract: ERC20Claim; }