diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 20db2302d4..dded6beea6 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -30,6 +30,7 @@ const useBuildDAOTx = () => { zodiacModuleProxyFactory, multisend: multiSendCallOnly, claimingMasterCopy: erc20ClaimMasterCopy, + fractalModuleMasterCopy, }, } = useNetworkConfig(); @@ -114,6 +115,7 @@ const useBuildDAOTx = () => { zodiacModuleProxyFactory, multiSendCallOnly, erc20ClaimMasterCopy, + fractalModuleMasterCopy, parentAddress, parentTokenAddress, ); @@ -170,6 +172,7 @@ const useBuildDAOTx = () => { zodiacModuleProxyFactory, multiSendCallOnly, erc20ClaimMasterCopy, + fractalModuleMasterCopy, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index 7ac058fc6e..8640dfdf7b 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -35,6 +35,7 @@ const useDeployAzorius = () => { zodiacModuleProxyFactory, multisend: multiSendCallOnly, claimingMasterCopy: erc20ClaimMasterCopy, + fractalModuleMasterCopy, }, addressPrefix, } = useNetworkConfig(); @@ -101,6 +102,7 @@ const useDeployAzorius = () => { zodiacModuleProxyFactory, multiSendCallOnly, erc20ClaimMasterCopy, + fractalModuleMasterCopy, undefined, undefined, ); @@ -169,6 +171,7 @@ const useDeployAzorius = () => { zodiacModuleProxyFactory, multiSendCallOnly, erc20ClaimMasterCopy, + fractalModuleMasterCopy, ], ); diff --git a/src/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index 0ad67ae90f..91618beb11 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -39,6 +39,7 @@ export class DaoTxBuilder extends BaseTxBuilder { private readonly fractalRegistryAddress: string; private readonly moduleProxyFactoryAddress: string; private readonly multiSendCallOnlyAddress: string; + private readonly fractalModuleMasterCopyAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -54,6 +55,7 @@ export class DaoTxBuilder extends BaseTxBuilder { fractalRegistryAddress: string, moduleProxyFactoryAddress: string, multiSendCallOnlyAddress: string, + fractalModuleMasterCopyAddress: string, parentAddress?: string, parentTokenAddress?: string, parentStrategyType?: VotingStrategyType, @@ -80,6 +82,7 @@ export class DaoTxBuilder extends BaseTxBuilder { this.fractalRegistryAddress = fractalRegistryAddress; this.moduleProxyFactoryAddress = moduleProxyFactoryAddress; this.multiSendCallOnlyAddress = multiSendCallOnlyAddress; + this.fractalModuleMasterCopyAddress = fractalModuleMasterCopyAddress; // Prep fractal module txs for setting up subDAOs this.setFractalModuleTxs(); @@ -222,7 +225,7 @@ export class DaoTxBuilder extends BaseTxBuilder { private setFractalModuleTxs(): void { const { enableFractalModuleTx, deployFractalModuleTx }: FractalModuleData = fractalModuleData( - this.baseContracts.fractalModuleMasterCopyContract, + getAddress(this.fractalModuleMasterCopyAddress), getAddress(this.moduleProxyFactoryAddress), this.safeContractAddress, this.saltNum, diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index c09100022d..5133857c73 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -38,6 +38,7 @@ export class TxBuilderFactory extends BaseTxBuilder { private moduleProxyFactoryAddress: string; private multiSendCallOnlyAddress: string; private erc20ClaimMasterCopyAddress: string; + private fractalModuleMasterCopyAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -55,6 +56,7 @@ export class TxBuilderFactory extends BaseTxBuilder { moduleProxyFactoryAddress: string, multiSendCallOnlyAddress: string, erc20ClaimMasterCopyAddress: string, + fractalModuleMasterCopyAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -79,6 +81,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.moduleProxyFactoryAddress = moduleProxyFactoryAddress; this.multiSendCallOnlyAddress = multiSendCallOnlyAddress; this.erc20ClaimMasterCopyAddress = erc20ClaimMasterCopyAddress; + this.fractalModuleMasterCopyAddress = fractalModuleMasterCopyAddress; } public setSafeContract(safeAddress: Address) { @@ -131,6 +134,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.fractalRegistryAddress, this.moduleProxyFactoryAddress, this.multiSendCallOnlyAddress, + this.fractalModuleMasterCopyAddress, this.parentAddress, this.parentTokenAddress, parentStrategyType, diff --git a/src/models/helpers/fractalModuleData.ts b/src/models/helpers/fractalModuleData.ts index f81e3afb9c..7cb659f692 100644 --- a/src/models/helpers/fractalModuleData.ts +++ b/src/models/helpers/fractalModuleData.ts @@ -1,14 +1,13 @@ -import { FractalModule, FractalModule__factory } from '@fractal-framework/fractal-contracts'; import { encodeAbiParameters, parseAbiParameters, - getAddress, - isHex, Address, getCreate2Address, keccak256, encodePacked, + encodeFunctionData, } from 'viem'; +import FractalModuleAbi from '../../assets/abi/FractalModule'; import GnosisSafeL2Abi from '../../assets/abi/GnosisSafeL2'; import ModuleProxyFactoryAbi from '../../assets/abi/ModuleProxyFactory'; import { buildContractCallViem } from '../../helpers/crypto'; @@ -22,15 +21,16 @@ export interface FractalModuleData { } export const fractalModuleData = ( - fractalModuleMasterCopyContract: FractalModule, + fractalModuleMasterCopyAddress: Address, moduleProxyFactoryAddress: Address, safeAddress: Address, saltNum: bigint, parentAddress?: Address, ): FractalModuleData => { - const fractalModuleCalldata = FractalModule__factory.createInterface().encodeFunctionData( - 'setUp', - [ + const fractalModuleCalldata = encodeFunctionData({ + abi: FractalModuleAbi, + functionName: 'setUp', + args: [ encodeAbiParameters(parseAbiParameters(['address, address, address, address[]']), [ parentAddress ?? safeAddress, // Owner -- Parent DAO or safe contract safeAddress, // Avatar @@ -38,15 +38,9 @@ export const fractalModuleData = ( [], // Authorized Controllers ]), ], - ); - - if (!isHex(fractalModuleCalldata)) { - throw new Error('Error encoding fractal module call data'); - } + }); - const fractalByteCodeLinear = generateContractByteCodeLinear( - getAddress(fractalModuleMasterCopyContract.address), - ); + const fractalByteCodeLinear = generateContractByteCodeLinear(fractalModuleMasterCopyAddress); const fractalSalt = generateSalt(fractalModuleCalldata, saltNum); @@ -54,7 +48,7 @@ export const fractalModuleData = ( ModuleProxyFactoryAbi, moduleProxyFactoryAddress, 'deployModule', - [fractalModuleMasterCopyContract.address, fractalModuleCalldata, saltNum], + [fractalModuleMasterCopyAddress, fractalModuleCalldata, saltNum], 0, false, );