Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep the 1.3 factory #632

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -61,7 +52,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
to: managementDAOAddress,
value: 0,
data: calldata,
description: `Moves the <strong>REGISTER_DAO_PERMISSION_ID</strong> permission on the <strong>DAORegistry</strong> (<code>${daoRegistryAddress}</code>) from the old <strong>DAOFactory</strong> (<code>${previousDAOFactoryAddress}</code>) to the new <strong>DAOFactory</strong> (<code>${deployResult.address}</code>).`,
description: `Grant the <strong>REGISTER_DAO_PERMISSION_ID</strong> permission on the <strong>DAORegistry</strong> (<code>${daoRegistryAddress}</code>) to the new <strong>DAOFactory</strong> (<code>${deployResult.address}</code>).`,
});
};
export default func;
Expand Down
83 changes: 82 additions & 1 deletion packages/contracts/test/deploy/update-1.4.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,6 +27,18 @@ 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',
};

async function forkSepolia() {
hre.network.deploy = ['./deploy/update/to_v1.4.0'];

Expand Down Expand Up @@ -176,7 +195,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,
Expand Down Expand Up @@ -228,4 +247,66 @@ skipTestSuiteIfNetworkIsZkSync('Update to 1.4.0', function () {
).address
);
});

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(
previousDAOFactoryAddress
);

// publish a plugin based on OSx 1.4
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<PluginRepoRegisteredEvent>(
await tx.wait(),
PluginRepoRegistry__factory.createInterface(),
EVENTS.PluginRepoRegistered
);

const pluginSetupMockRepoAddress = event.args.pluginRepo;

const pluginRepoPointer: PluginRepoPointer = [
pluginSetupMockRepoAddress,
1,
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(daoRegistryContract, EVENTS.DAORegistered)
.withArgs(dao, deployer.address, daoSettings.subdomain);
});
});
2 changes: 1 addition & 1 deletion packages/contracts/test/framework/dao/dao-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading