Skip to content

Commit

Permalink
add update to 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Dec 16, 2024
1 parent e0ba7b6 commit 7677ebb
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 4 deletions.
68 changes: 68 additions & 0 deletions packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import daoFactoryArtifact from '../../../artifacts/src/framework/dao/DAOFactory.sol/DAOFactory.json';
import {DAO__factory} from '../../../typechain';
import {getLatestContractAddress} from '../../helpers';
import {Operation} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nUpdating DAOFactory');
const {deployments, ethers} = hre;
const {deploy} = deployments;
const [deployer] = await ethers.getSigners();

const managementDAOAddress = getLatestContractAddress(
'ManagementDAOProxy',
hre
);
const pluginSetupProcessorAddress = getLatestContractAddress(
'PluginSetupProcessor',
hre
);
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,
from: deployer.address,
args: [daoRegistryAddress, pluginSetupProcessorAddress],
log: true,
});

const daoInterface = DAO__factory.createInterface();
const calldata = daoInterface.encodeFunctionData(
'applyMultiTargetPermissions',
[
[
{
who: previousDAOFactoryAddress,
where: daoRegistryAddress,
operation: Operation.Revoke,
permissionId: ethers.utils.id('REGISTER_DAO_PERMISSION'),
condition: ethers.constants.AddressZero,
},
{
who: deployResult.address,
where: daoRegistryAddress,
operation: Operation.Grant,
permissionId: ethers.utils.id('REGISTER_DAO_PERMISSION'),
condition: ethers.constants.AddressZero,
},
],
]
);
// update permissions actions
hre.managementDAOActions.push({
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>).`,
});
};
export default func;
func.tags = ['DAOFactory', 'v1.4.0'];
func.dependencies = ['Env'];
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {DAOFactory__factory} from '../../../typechain';
import {getContractAddress} from '../../helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nConcluding DAOFactory update');
const {deployments, ethers} = hre;
const [deployer] = await ethers.getSigners();

const daoFactoryAddress = await getContractAddress('DAOFactory', hre);
const daoFactory = DAOFactory__factory.connect(daoFactoryAddress, deployer);
const daoBase = await daoFactory.callStatic.daoBase();

hre.aragonToVerifyContracts.push(await deployments.get('DAOFactory'));
hre.aragonToVerifyContracts.push({
address: daoBase,
args: [],
});
};
export default func;
func.tags = ['DAOFactory', 'Verify', 'v1.4.0'];
70 changes: 70 additions & 0 deletions packages/contracts/deploy/update/to_v1.4.0/20_PluginRepoFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import pluginRepoFactoryArtifact from '../../../artifacts/src/framework/plugin/repo/PluginRepoFactory.sol/PluginRepoFactory.json';
import {PluginRepo__factory} from '../../../typechain';
import {getLatestContractAddress} from '../../helpers';
import {Operation} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nUpdating PluginRepoFactory');
const {deployments, ethers} = hre;
const {deploy} = deployments;
const [deployer] = await ethers.getSigners();

const managementDAOAddress = getLatestContractAddress(
'ManagementDAOProxy',
hre
);
const pluginRepoRegistryAddress = getLatestContractAddress(
'PluginRepoRegistryProxy',
hre
);
const previousPluginRepoFactoryAddress = getLatestContractAddress(
'PluginRepoFactory',
hre
);
console.log(`Using managementDAO ${managementDAOAddress}`);
console.log(`Using PluginRepoRegistry ${pluginRepoRegistryAddress}`);
console.log(
`Using PreviousPluginRepoFactory ${previousPluginRepoFactoryAddress}`
);

const deployResult = await deploy('PluginRepoFactory', {
contract: pluginRepoFactoryArtifact,
from: deployer.address,
args: [pluginRepoRegistryAddress],
log: true,
});

const pluginRepoInterface = PluginRepo__factory.createInterface();
const calldata = pluginRepoInterface.encodeFunctionData(
'applyMultiTargetPermissions',
[
[
{
who: previousPluginRepoFactoryAddress,
where: pluginRepoRegistryAddress,
operation: Operation.Revoke,
permissionId: ethers.utils.id('REGISTER_PLUGIN_REPO_PERMISSION'),
condition: ethers.constants.AddressZero,
},
{
who: deployResult.address,
where: pluginRepoRegistryAddress,
operation: Operation.Grant,
permissionId: ethers.utils.id('REGISTER_PLUGIN_REPO_PERMISSION'),
condition: ethers.constants.AddressZero,
},
],
]
);
// update permissions actions
hre.managementDAOActions.push({
to: managementDAOAddress,
value: 0,
data: calldata,
description: `Moves the <strong>REGISTER_PLUGIN_REPO_PERMISSION</strong> permission on the <strong>PluginRepoRegistry</strong> (<code>${pluginRepoRegistryAddress}</code>) from the old <strong>PluginRepoFactory</strong> (<code>${previousPluginRepoFactoryAddress}</code>) to the new <strong>PluginRepoFactory</strong> (<code>${deployResult.address}</code>).`,
});
};
export default func;
func.tags = ['PluginRepoFactory', 'v1.4.0'];
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {PluginRepoFactory__factory} from '../../../typechain';
import {getContractAddress} from '../../helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nConcluding PluginRepoFactory update');
const {deployments, ethers} = hre;
const [deployer] = await ethers.getSigners();

const pluginRepoFactoryAddress = await getContractAddress(
'PluginRepoFactory',
hre
);
const pluginRepoFactory = PluginRepoFactory__factory.connect(
pluginRepoFactoryAddress,
deployer
);
const pluginRepoBase = await pluginRepoFactory.callStatic.pluginRepoBase();

hre.aragonToVerifyContracts.push(await deployments.get('PluginRepoFactory'));
hre.aragonToVerifyContracts.push({
address: pluginRepoBase,
args: [],
});
};
export default func;
func.tags = ['PluginRepoFactory', 'Verify', 'v1.4.0'];
44 changes: 44 additions & 0 deletions packages/contracts/deploy/update/to_v1.4.0/90_ManagingDAO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {DAOFactory__factory, DAO__factory} from '../../../typechain';
import {getContractAddress} from '../../helpers';
import {getProtocolVersion} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nUpgrade the management DAO to new Implementation');

const daoFactoryAddress = await getContractAddress('DAOFactory', hre);
const newDaoImplementation = await DAOFactory__factory.connect(
daoFactoryAddress,
hre.ethers.provider
).daoBase();

const managementDAOAddress = await getContractAddress(
'ManagementDAOProxy',
hre
);
const managementDAO = DAO__factory.connect(
managementDAOAddress,
hre.ethers.provider
);

const upgradeTX = await managementDAO.populateTransaction.upgradeToAndCall(
newDaoImplementation,
managementDAO.interface.encodeFunctionData('initializeFrom', [
await getProtocolVersion(managementDAO),
[],
])
);

if (!upgradeTX.to || !upgradeTX.data) {
throw new Error(`Failed to populate upgradeToAndCall transaction`);
}
hre.managementDAOActions.push({
to: upgradeTX.to,
data: upgradeTX.data,
value: 0,
description: `Upgrade the <strong>management DAO</strong> (<code>${managementDAOAddress}</code>) to the new <strong>implementation</strong> (<code>${newDaoImplementation}</code>).`,
});
};
export default func;
func.tags = ['ManagementDAO', 'v1.4.0'];
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`${pluginRepo}: ${aragonPluginRepos[pluginRepo]}`);
}

await fs.writeFile(
'deployed_contracts.json',
JSON.stringify(deployedContractAddresses)
);
const storeInfo = {
deployedContractAddresses,
managementDAOActions: hre.managementDAOActions,
};

await fs.writeFile('deployed_contracts.json', JSON.stringify(storeInfo));
};
export default func;
func.tags = ['New', 'Conclude', 'ConcludeEnd'];
Expand Down
6 changes: 6 additions & 0 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ for (const network of Object.keys(hardhatNetworks) as SupportedNetworks[]) {
if (network === SupportedNetworks.LOCAL) {
continue;
}

if (networkExtensions[network] == undefined) {
console.log(`WARNING: newtork ${network} is not found in networks.ts file`);
continue;
}

hardhatNetworks[network].accounts = accounts;
hardhatNetworks[network].deploy = networkExtensions[network].deploy;
}
Expand Down

0 comments on commit 7677ebb

Please sign in to comment.