From e616409ee9f02a15d8e25960b5be139ad9ef3062 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:56:03 -0400 Subject: [PATCH 1/3] Fix object delcarations to be of types, not as types, and fix some bugs in the process --- src/hooks/DAO/useBuildDAOTx.ts | 4 ++-- src/hooks/DAO/useDeployAzorius.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 3f0ceff487..cc0bb141c6 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -92,7 +92,7 @@ const useBuildDAOTx = () => { }; } - const buildrerBaseContracts = { + const buildrerBaseContracts: BaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asSigner, fractalRegistryContract: fractalRegistryContract.asSigner, safeFactoryContract: safeFactoryContract.asSigner, @@ -103,7 +103,7 @@ const useBuildDAOTx = () => { freezeERC721VotingMasterCopyContract: freezeERC721VotingMasterCopyContract.asSigner, freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asSigner, zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asSigner, - } as BaseContracts; + }; const txBuilderFactory = new TxBuilderFactory( signerOrProvider, diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index 11789c75a8..24381bc103 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -54,6 +54,7 @@ const useDeployAzorius = () => { safeFactoryContract, safeSingletonContract, linearVotingMasterCopyContract, + linearVotingERC721MasterCopyContract, fractalAzoriusMasterCopyContract, zodiacModuleProxyFactoryContract, fractalRegistryContract, @@ -62,18 +63,20 @@ const useDeployAzorius = () => { azoriusFreezeGuardMasterCopyContract, freezeMultisigVotingMasterCopyContract, freezeERC20VotingMasterCopyContract, + freezeERC721VotingMasterCopyContract, claimingMasterCopyContract, } = baseContracts; - let azoriusContracts; + let azoriusContracts: AzoriusContracts; azoriusContracts = { fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asProvider, linearVotingMasterCopyContract: linearVotingMasterCopyContract.asProvider, + linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asProvider, azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider, claimingMasterCopyContract: claimingMasterCopyContract.asProvider, - } as AzoriusContracts; + }; - const builderBaseContracts = { + const builderBaseContracts: BaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asProvider, fractalRegistryContract: fractalRegistryContract.asProvider, safeFactoryContract: safeFactoryContract.asProvider, @@ -81,9 +84,10 @@ const useDeployAzorius = () => { multisigFreezeGuardMasterCopyContract: multisigFreezeGuardMasterCopyContract.asProvider, multiSendContract: multiSendContract.asProvider, freezeERC20VotingMasterCopyContract: freezeERC20VotingMasterCopyContract.asProvider, + freezeERC721VotingMasterCopyContract: freezeERC721VotingMasterCopyContract.asProvider, freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asProvider, zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asProvider, - } as BaseContracts; + }; const txBuilderFactory = new TxBuilderFactory( signerOrProvider, From 032d618fc0d434c628b1d9d41778946829a9c643 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:56:03 -0400 Subject: [PATCH 2/3] Add FractalRegistryAbi --- src/assets/abi/FractalRegistry.ts | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/assets/abi/FractalRegistry.ts diff --git a/src/assets/abi/FractalRegistry.ts b/src/assets/abi/FractalRegistry.ts new file mode 100644 index 0000000000..a9857c0cf7 --- /dev/null +++ b/src/assets/abi/FractalRegistry.ts @@ -0,0 +1,68 @@ +const FractalRegistryAbi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'daoAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'string', + name: 'daoName', + type: 'string', + }, + ], + name: 'FractalNameUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'parentDAOAddress', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'subDAOAddress', + type: 'address', + }, + ], + name: 'FractalSubDAODeclared', + type: 'event', + }, + { + inputs: [ + { + internalType: 'address', + name: '_subDAOAddress', + type: 'address', + }, + ], + name: 'declareSubDAO', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'string', + name: '_name', + type: 'string', + }, + ], + name: 'updateDAOName', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export default FractalRegistryAbi; From 02ed6ce8667a040b8beb6d3a6a8a7e0f94dbfdbd Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:56:03 -0400 Subject: [PATCH 3/3] Remove fractalRegistryContract from BaseContracts, resolve all downstream issues --- src/hooks/DAO/useBuildDAOTx.ts | 5 +++-- src/hooks/DAO/useDeployAzorius.ts | 5 +++-- src/models/DaoTxBuilder.ts | 9 +++++++-- src/models/TxBuilderFactory.ts | 4 ++++ src/types/contract.ts | 2 -- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index cc0bb141c6..55f5577eca 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -24,6 +24,7 @@ const useBuildDAOTx = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, }, } = useNetworkConfig(); @@ -54,7 +55,6 @@ const useBuildDAOTx = () => { linearVotingERC721MasterCopyContract, fractalAzoriusMasterCopyContract, zodiacModuleProxyFactoryContract, - fractalRegistryContract, fractalModuleMasterCopyContract, multisigFreezeGuardMasterCopyContract, azoriusFreezeGuardMasterCopyContract, @@ -94,7 +94,6 @@ const useBuildDAOTx = () => { const buildrerBaseContracts: BaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asSigner, - fractalRegistryContract: fractalRegistryContract.asSigner, safeFactoryContract: safeFactoryContract.asSigner, safeSingletonContract: safeSingletonContract.asSigner, multisigFreezeGuardMasterCopyContract: multisigFreezeGuardMasterCopyContract.asSigner, @@ -115,6 +114,7 @@ const useBuildDAOTx = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, parentAddress, parentTokenAddress, ); @@ -165,6 +165,7 @@ const useBuildDAOTx = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index 24381bc103..36a54ada62 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -27,6 +27,7 @@ const useDeployAzorius = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, }, addressPrefix, } = useNetworkConfig(); @@ -57,7 +58,6 @@ const useDeployAzorius = () => { linearVotingERC721MasterCopyContract, fractalAzoriusMasterCopyContract, zodiacModuleProxyFactoryContract, - fractalRegistryContract, fractalModuleMasterCopyContract, multisigFreezeGuardMasterCopyContract, azoriusFreezeGuardMasterCopyContract, @@ -78,7 +78,6 @@ const useDeployAzorius = () => { const builderBaseContracts: BaseContracts = { fractalModuleMasterCopyContract: fractalModuleMasterCopyContract.asProvider, - fractalRegistryContract: fractalRegistryContract.asProvider, safeFactoryContract: safeFactoryContract.asProvider, safeSingletonContract: safeSingletonContract.asProvider, multisigFreezeGuardMasterCopyContract: multisigFreezeGuardMasterCopyContract.asProvider, @@ -99,6 +98,7 @@ const useDeployAzorius = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, undefined, undefined, ); @@ -160,6 +160,7 @@ const useDeployAzorius = () => { votesERC20WrapperMasterCopy, votesERC20MasterCopy, keyValuePairs, + fractalRegistry, ], ); diff --git a/src/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index df2cd83588..cda0b12a55 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -1,5 +1,6 @@ import { ethers } from 'ethers'; import { PublicClient, getAddress, zeroAddress } from 'viem'; +import FractalRegistryAbi from '../assets/abi/FractalRegistry'; import KeyValuePairsAbi from '../assets/abi/KeyValuePairs'; import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; import { buildContractCall, buildContractCallViem, encodeMultiSend } from '../helpers'; @@ -34,6 +35,7 @@ export class DaoTxBuilder extends BaseTxBuilder { private internalTxs: SafeTransaction[] = []; private readonly keyValuePairsAddress: string; + private readonly fractalRegistryAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -46,6 +48,7 @@ export class DaoTxBuilder extends BaseTxBuilder { safeContract: GnosisSafeL2, txBuilderFactory: TxBuilderFactory, keyValuePairsAddress: string, + fractalRegistryAddress: string, parentAddress?: string, parentTokenAddress?: string, parentStrategyType?: VotingStrategyType, @@ -69,6 +72,7 @@ export class DaoTxBuilder extends BaseTxBuilder { this.parentStrategyAddress = parentStrategyAddress; this.keyValuePairsAddress = keyValuePairsAddress; + this.fractalRegistryAddress = fractalRegistryAddress; // Prep fractal module txs for setting up subDAOs this.setFractalModuleTxs(); @@ -227,8 +231,9 @@ export class DaoTxBuilder extends BaseTxBuilder { // private buildUpdateDAONameTx(): SafeTransaction { - return buildContractCall( - this.baseContracts.fractalRegistryContract, + return buildContractCallViem( + FractalRegistryAbi, + getAddress(this.fractalRegistryAddress), 'updateDAOName', [this.daoData.daoName], 0, diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index 4a5a98c0f3..0b77d858ef 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -32,6 +32,7 @@ export class TxBuilderFactory extends BaseTxBuilder { private votesERC20WrapperMasterCopyAddress: string; private votesERC20MasterCopyAddress: string; private keyValuePairsAddress: string; + private fractalRegistryAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -43,6 +44,7 @@ export class TxBuilderFactory extends BaseTxBuilder { votesERC20WrapperMasterCopyAddress: string, votesERC20MasterCopyAddress: string, keyValuePairsAddress: string, + fractalRegistryAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -61,6 +63,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress; this.keyValuePairsAddress = keyValuePairsAddress; + this.fractalRegistryAddress = fractalRegistryAddress; } public setSafeContract(safeAddress: string) { @@ -100,6 +103,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.safeContract!, this, this.keyValuePairsAddress, + this.fractalRegistryAddress, this.parentAddress, this.parentTokenAddress, parentStrategyType, diff --git a/src/types/contract.ts b/src/types/contract.ts index 881eb564c1..3dd200a263 100644 --- a/src/types/contract.ts +++ b/src/types/contract.ts @@ -2,7 +2,6 @@ import { GnosisSafeProxyFactory, ModuleProxyFactory, FractalModule, - FractalRegistry, MultisigFreezeGuard, MultisigFreezeVoting, ERC20FreezeVoting, @@ -22,7 +21,6 @@ export type ContractConnection = { export interface BaseContracts { fractalModuleMasterCopyContract: FractalModule; - fractalRegistryContract: FractalRegistry; safeFactoryContract: GnosisSafeProxyFactory; safeSingletonContract: GnosisSafeL2; multisigFreezeGuardMasterCopyContract: MultisigFreezeGuard;