Skip to content

Commit

Permalink
Remove FractalModule typechain from fractalModuleData
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed May 15, 2024
1 parent fcb89aa commit b1e1722
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const useBuildDAOTx = () => {
zodiacModuleProxyFactory,
multisend: multiSendCallOnly,
claimingMasterCopy: erc20ClaimMasterCopy,
fractalModuleMasterCopy,
},
} = useNetworkConfig();

Expand Down Expand Up @@ -114,6 +115,7 @@ const useBuildDAOTx = () => {
zodiacModuleProxyFactory,
multiSendCallOnly,
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
parentAddress,
parentTokenAddress,
);
Expand Down Expand Up @@ -170,6 +172,7 @@ const useBuildDAOTx = () => {
zodiacModuleProxyFactory,
multiSendCallOnly,
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
],
);

Expand Down
3 changes: 3 additions & 0 deletions src/hooks/DAO/useDeployAzorius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const useDeployAzorius = () => {
zodiacModuleProxyFactory,
multisend: multiSendCallOnly,
claimingMasterCopy: erc20ClaimMasterCopy,
fractalModuleMasterCopy,
},
addressPrefix,
} = useNetworkConfig();
Expand Down Expand Up @@ -101,6 +102,7 @@ const useDeployAzorius = () => {
zodiacModuleProxyFactory,
multiSendCallOnly,
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
undefined,
undefined,
);
Expand Down Expand Up @@ -169,6 +171,7 @@ const useDeployAzorius = () => {
zodiacModuleProxyFactory,
multiSendCallOnly,
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
],
);

Expand Down
5 changes: 4 additions & 1 deletion src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -54,6 +55,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
fractalRegistryAddress: string,
moduleProxyFactoryAddress: string,
multiSendCallOnlyAddress: string,
fractalModuleMasterCopyAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
parentStrategyType?: VotingStrategyType,
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/models/TxBuilderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -55,6 +56,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
moduleProxyFactoryAddress: string,
multiSendCallOnlyAddress: string,
erc20ClaimMasterCopyAddress: string,
fractalModuleMasterCopyAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
) {
Expand All @@ -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) {
Expand Down Expand Up @@ -130,6 +133,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.fractalRegistryAddress,
this.moduleProxyFactoryAddress,
this.multiSendCallOnlyAddress,
this.fractalModuleMasterCopyAddress,
this.parentAddress,
this.parentTokenAddress,
parentStrategyType,
Expand Down
26 changes: 10 additions & 16 deletions src/models/helpers/fractalModuleData.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -22,39 +21,34 @@ 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
safeAddress, // Target
[], // 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);

const deployFractalModuleTx = buildContractCallViem(
ModuleProxyFactoryAbi,
moduleProxyFactoryAddress,
'deployModule',
[fractalModuleMasterCopyContract.address, fractalModuleCalldata, saltNum],
[fractalModuleMasterCopyAddress, fractalModuleCalldata, saltNum],
0,
false,
);
Expand Down

0 comments on commit b1e1722

Please sign in to comment.