From 83346376f8ee95eda8c7406d5af3cb8b6c30c64f Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:49:03 +0100 Subject: [PATCH 1/3] keep the 1.3 factory --- .../deploy/update/to_v1.4.0/10_DAOFactory.ts | 11 +-- .../contracts/test/deploy/update-1.4.0.ts | 86 ++++++++++++++++++- .../test/framework/dao/dao-factory.ts | 2 +- .../test/test-utils/skip-functions.ts | 2 +- 4 files changed, 87 insertions(+), 14 deletions(-) diff --git a/packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts b/packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts index 24ee600eb..c3fc286e7 100644 --- a/packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts +++ b/packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts @@ -21,11 +21,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ); const daoRegistryAddress = getLatestContractAddress('DAORegistryProxy', hre); - const previousDAOFactoryAddress = getLatestContractAddress('DAOFactory', hre); console.log(`Using managementDAO ${managementDAOAddress}`); console.log(`Using PluginSetupProcessor ${pluginSetupProcessorAddress}`); console.log(`Using DAORegistry ${daoRegistryAddress}`); - console.log(`Using PreviousDAOFactory ${previousDAOFactoryAddress}`); const deployResult = await deploy('DAOFactory', { contract: daoFactoryArtifact, @@ -39,13 +37,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 'applyMultiTargetPermissions', [ [ - { - who: previousDAOFactoryAddress, - where: daoRegistryAddress, - operation: Operation.Revoke, - permissionId: ethers.utils.id('REGISTER_DAO_PERMISSION'), - condition: ethers.constants.AddressZero, - }, { who: deployResult.address, where: daoRegistryAddress, @@ -61,7 +52,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { to: managementDAOAddress, value: 0, data: calldata, - description: `Moves the REGISTER_DAO_PERMISSION_ID permission on the DAORegistry (${daoRegistryAddress}) from the old DAOFactory (${previousDAOFactoryAddress}) to the new DAOFactory (${deployResult.address}).`, + description: `Grant the REGISTER_DAO_PERMISSION_ID permission on the DAORegistry (${daoRegistryAddress}) to the new DAOFactory (${deployResult.address}).`, }); }; export default func; diff --git a/packages/contracts/test/deploy/update-1.4.0.ts b/packages/contracts/test/deploy/update-1.4.0.ts index 0ec1ca789..5f911a2ad 100644 --- a/packages/contracts/test/deploy/update-1.4.0.ts +++ b/packages/contracts/test/deploy/update-1.4.0.ts @@ -6,12 +6,19 @@ import { DAORegistry__factory, PluginRepoRegistry__factory, } from '../../typechain'; +import {PluginRepoRegisteredEvent} from '../../typechain/PluginRepoRegistry'; +import {getAnticipatedAddress} from '../framework/dao/dao-factory'; +import {daoExampleURI} from '../test-utils/dao'; import { closeFork, initForkForOsxVersion, initializeDeploymentFixture, } from '../test-utils/fixture'; +import {createPrepareInstallationParams} from '../test-utils/psp/create-params'; +import {PluginRepoPointer} from '../test-utils/psp/types'; import {skipTestSuiteIfNetworkIsZkSync} from '../test-utils/skip-functions'; +import {findEventTopicLog} from '@aragon/osx-commons-sdk'; +import {PluginRepoFactory__factory} from '@aragon/osx-ethers-v1.2.0'; import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; import {expect} from 'chai'; import {defaultAbiCoder} from 'ethers/lib/utils'; @@ -20,6 +27,27 @@ import hre, {ethers, deployments} from 'hardhat'; const IMPLEMENTATION_ADDRESS_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'; +const daoSettings = { + trustedForwarder: ethers.constants.AddressZero, + subdomain: 'dao1', + metadata: '0x0000', + daoURI: daoExampleURI, +}; + +const EVENTS = { + PluginRepoRegistered: 'PluginRepoRegistered', + DAORegistered: 'DAORegistered', + InstallationPrepared: 'InstallationPrepared', + InstallationApplied: 'InstallationApplied', + UpdateApplied: 'UpdateApplied', + UninstallationApplied: 'UninstallationApplied', + MetadataSet: 'MetadataSet', + TrustedForwarderSet: 'TrustedForwarderSet', + NewURI: 'NewURI', + Revoked: 'Revoked', + Granted: 'Granted', +}; + async function forkSepolia() { hre.network.deploy = ['./deploy/update/to_v1.4.0']; @@ -104,7 +132,7 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { closeFork(); }); - it('should update dao, daoRegistry, PluginRepoRegistry and set permissions correctly', async () => { + it.only('should update dao, daoRegistry, PluginRepoRegistry and set permissions correctly', async () => { const previousPluginRepoFactory = getAddress('PluginRepoFactory'); const previousDAOFactoryAddress = getAddress('DAOFactory'); @@ -176,7 +204,7 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { { where: daoRegistry.address, who: previousDAOFactoryAddress, - isSet: false, + isSet: true, // Makes sure we keep the the permission of the previouse DAO factory }, { where: pluginRepoRegistry.address, @@ -228,4 +256,58 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { ).address ); }); + + it.only('Previouse (v1.3) DAO Factory can still register DAOs', async () => { + const previousDAOFactoryAddress = getAddress('DAOFactory'); + const dao = await getAnticipatedAddress(previousDAOFactoryAddress); + const daoContract = new DAO__factory(deployer).attach(dao); + + const daoFactory = new DAOFactory__factory(deployer).attach( + previousDAOFactoryAddress + ); + + const pluginImp = await hre.wrapper.deploy('PluginUUPSUpgradeableV1Mock'); + const pluginSetupMock = await hre.wrapper.deploy( + 'PluginUUPSUpgradeableSetupV1Mock', + {args: [pluginImp.address]} + ); + + const newPluginRepoFactoryAddress = ( + await deployments.get('PluginRepoFactory') + ).address; + + const pluginRepoFactory = new PluginRepoFactory__factory(deployer).attach( + newPluginRepoFactoryAddress + ); + + const tx = await pluginRepoFactory.createPluginRepoWithFirstVersion( + 'plugin-uupsupgradeable-setup-v1-mock', + pluginSetupMock.address, + deployer.address, + '0x00', + '0x00' + ); + + const event = findEventTopicLog( + await tx.wait(), + PluginRepoRegistry__factory.createInterface(), + EVENTS.PluginRepoRegistered + ); + + const pluginSetupMockRepoAddress = event.args.pluginRepo; + + const pluginRepoPointer: PluginRepoPointer = [ + pluginSetupMockRepoAddress, + 1, + 1, + ]; + + expect( + await daoFactory.createDao(daoSettings, [ + createPrepareInstallationParams(pluginRepoPointer, '0x'), + ]) + ) + .to.emit(daoContract, EVENTS.MetadataSet) + .withArgs(daoSettings.metadata); + }); }); diff --git a/packages/contracts/test/framework/dao/dao-factory.ts b/packages/contracts/test/framework/dao/dao-factory.ts index 3956a327e..146ddca8e 100644 --- a/packages/contracts/test/framework/dao/dao-factory.ts +++ b/packages/contracts/test/framework/dao/dao-factory.ts @@ -99,7 +99,7 @@ async function extractInfoFromCreateDaoTx(tx: any): Promise<{ }; } -async function getAnticipatedAddress(from: string, offset: number = 0) { +export async function getAnticipatedAddress(from: string, offset: number = 0) { const nonce = await hre.wrapper.getNonce(from); const anticipatedAddress = hre.wrapper.getCreateAddress(from, nonce + offset); diff --git a/packages/contracts/test/test-utils/skip-functions.ts b/packages/contracts/test/test-utils/skip-functions.ts index e2482eec6..4f00e2ba8 100644 --- a/packages/contracts/test/test-utils/skip-functions.ts +++ b/packages/contracts/test/test-utils/skip-functions.ts @@ -1,4 +1,4 @@ -import {ZK_SYNC_NETWORKS} from '../../utils/zkSync'; +import {ZK_SYNC_NETWORKS} from '../../utils/zksync'; import hre from 'hardhat'; // ANSI escape codes for colored terminal output From a5fa953da5f0680a85d8ed899651022faf65c1e0 Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:13:18 +0100 Subject: [PATCH 2/3] clean up --- .../contracts/test/deploy/update-1.4.0.ts | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/contracts/test/deploy/update-1.4.0.ts b/packages/contracts/test/deploy/update-1.4.0.ts index 5f911a2ad..49fc40846 100644 --- a/packages/contracts/test/deploy/update-1.4.0.ts +++ b/packages/contracts/test/deploy/update-1.4.0.ts @@ -37,15 +37,6 @@ const daoSettings = { const EVENTS = { PluginRepoRegistered: 'PluginRepoRegistered', DAORegistered: 'DAORegistered', - InstallationPrepared: 'InstallationPrepared', - InstallationApplied: 'InstallationApplied', - UpdateApplied: 'UpdateApplied', - UninstallationApplied: 'UninstallationApplied', - MetadataSet: 'MetadataSet', - TrustedForwarderSet: 'TrustedForwarderSet', - NewURI: 'NewURI', - Revoked: 'Revoked', - Granted: 'Granted', }; async function forkSepolia() { @@ -257,15 +248,14 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { ); }); - it.only('Previouse (v1.3) DAO Factory can still register DAOs', async () => { + it.only('Previous (v1.3) DAO Factory can still register DAOs', async () => { + // get previouse DAO factory from OSx 1.4 const previousDAOFactoryAddress = getAddress('DAOFactory'); - const dao = await getAnticipatedAddress(previousDAOFactoryAddress); - const daoContract = new DAO__factory(deployer).attach(dao); - const daoFactory = new DAOFactory__factory(deployer).attach( previousDAOFactoryAddress ); + // publish a plugin based on OSx 1.4 const pluginImp = await hre.wrapper.deploy('PluginUUPSUpgradeableV1Mock'); const pluginSetupMock = await hre.wrapper.deploy( 'PluginUUPSUpgradeableSetupV1Mock', @@ -302,12 +292,21 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { 1, ]; + // Get anticipated DAO contract + const dao = await getAnticipatedAddress(previousDAOFactoryAddress); + + // Get dao registry + const daoRegistryAddress = getAddress('DAORegistryProxy'); + const daoRegistryContract = new DAOFactory__factory(deployer).attach( + daoRegistryAddress + ); + expect( await daoFactory.createDao(daoSettings, [ createPrepareInstallationParams(pluginRepoPointer, '0x'), ]) ) - .to.emit(daoContract, EVENTS.MetadataSet) - .withArgs(daoSettings.metadata); + .to.emit(daoRegistryContract, EVENTS.DAORegistered) + .withArgs(dao, deployer.address, daoSettings.subdomain); }); }); From 65966d623163d49f8426fa8a4995d75a23063261 Mon Sep 17 00:00:00 2001 From: Rekard0 <5880388+Rekard0@users.noreply.github.com> Date: Tue, 4 Feb 2025 14:07:54 +0100 Subject: [PATCH 3/3] remove .only --- packages/contracts/test/deploy/update-1.4.0.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contracts/test/deploy/update-1.4.0.ts b/packages/contracts/test/deploy/update-1.4.0.ts index 49fc40846..72a37b616 100644 --- a/packages/contracts/test/deploy/update-1.4.0.ts +++ b/packages/contracts/test/deploy/update-1.4.0.ts @@ -123,7 +123,7 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { closeFork(); }); - it.only('should update dao, daoRegistry, PluginRepoRegistry and set permissions correctly', async () => { + it('should update dao, daoRegistry, PluginRepoRegistry and set permissions correctly', async () => { const previousPluginRepoFactory = getAddress('PluginRepoFactory'); const previousDAOFactoryAddress = getAddress('DAOFactory'); @@ -248,7 +248,7 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () { ); }); - it.only('Previous (v1.3) DAO Factory can still register DAOs', async () => { + it('Previous (v1.3) DAO Factory can still register DAOs', async () => { // get previouse DAO factory from OSx 1.4 const previousDAOFactoryAddress = getAddress('DAOFactory'); const daoFactory = new DAOFactory__factory(deployer).attach(