-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
244 additions
and
4 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
packages/contracts/deploy/update/to_v1.4.0/10_DAOFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; |
22 changes: 22 additions & 0 deletions
22
packages/contracts/deploy/update/to_v1.4.0/11_DAOFactory_conclude.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
70
packages/contracts/deploy/update/to_v1.4.0/20_PluginRepoFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; |
28 changes: 28 additions & 0 deletions
28
packages/contracts/deploy/update/to_v1.4.0/21_PluginRepoFactory_conclude.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
44
packages/contracts/deploy/update/to_v1.4.0/90_ManagingDAO.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters