-
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
1 parent
b89cb57
commit 86b8c95
Showing
11 changed files
with
281 additions
and
48 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 {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {Operation} from '../../../utils/types'; | ||
import {getActiveContractAddress} from '../../helpers'; | ||
import {DAO__factory} from '../../../typechain'; | ||
|
||
import daoFactoryArtifact from '../../../artifacts/src/framework/dao/DAOFactory.sol/DAOFactory.json'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nUpdating DAOFactory'); | ||
const {deployments, ethers} = hre; | ||
const {deploy} = deployments; | ||
const [deployer] = await ethers.getSigners(); | ||
|
||
const managingDAOAddress = await getActiveContractAddress('managingDAO', hre); | ||
const pluginSetupProcessorAddress = await getActiveContractAddress( | ||
'PluginSetupProcessor', | ||
hre | ||
); | ||
const daoRegistryAddress = await getActiveContractAddress('DAORegistry', hre); | ||
const previousDAOFactoryAddress = await getActiveContractAddress( | ||
'DAOFactory', | ||
hre | ||
); | ||
console.log(`Using managingDAO ${managingDAOAddress}`); | ||
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.managingDAOActions.push({ | ||
to: managingDAOAddress, | ||
value: 0, | ||
data: calldata, | ||
description: `Moves the REGISTER_DAO_PERMISSION_ID permission on the DAORegistry (${daoRegistryAddress}) from the old to the new DAOFactory (${previousDAOFactoryAddress} -> ${deployResult.address}).`, | ||
}); | ||
}; | ||
export default func; | ||
func.tags = ['DAOFactory', 'v1.4.0']; |
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 {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {DAOFactory__factory} from '../../../typechain'; | ||
import {getContractAddress} from '../../helpers'; | ||
|
||
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']; |
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import {DAOFactory__factory, DAO__factory} from '../../../typechain'; | ||
import {getContractAddress} from '../../helpers'; | ||
import {IMPLICIT_INITIAL_PROTOCOL_VERSION} from '../../../test/test-utils/protocol-version'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
console.log('\nUpgrade the managing DAO to new implemenation'); | ||
|
||
const daoFactoryAddress = await getContractAddress('DAOFactory', hre); | ||
const newDaoImplementation = await DAOFactory__factory.connect( | ||
daoFactoryAddress, | ||
hre.ethers.provider | ||
).daoBase(); | ||
|
||
const managingDAOAddress = await getContractAddress('managingDAO', hre); | ||
const managingDAO = DAO__factory.connect( | ||
managingDAOAddress, | ||
hre.ethers.provider | ||
); | ||
const upgradeTX = await managingDAO.populateTransaction.upgradeToAndCall( | ||
newDaoImplementation, | ||
managingDAO.interface.encodeFunctionData('initializeFrom', [ | ||
IMPLICIT_INITIAL_PROTOCOL_VERSION, | ||
[], | ||
]) | ||
); | ||
|
||
if (!upgradeTX.to || !upgradeTX.data) { | ||
throw new Error(`Failed to populate upgradeToAndCall transaction`); | ||
} | ||
hre.managingDAOActions.push({ | ||
to: upgradeTX.to, | ||
data: upgradeTX.data, | ||
value: 0, | ||
description: `Upgrade the managing DAO to the new implementation (${newDaoImplementation})`, | ||
}); | ||
}; | ||
export default func; | ||
func.tags = ['ManagingDAO', '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
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 |
---|---|---|
|
@@ -40,7 +40,8 @@ | |
}, | ||
"homepage": "https://github.com/aragon/osx#readme", | ||
"devDependencies": { | ||
"@aragon/osx-ethers-v1.2.0": "npm:@aragon/[email protected]", | ||
"@aragon/osx-ethers-v1.2.1": "npm:@aragon/[email protected]", | ||
"@aragon/osx-ethers-v1.3.0-rc0.2": "npm:@aragon/[email protected]", | ||
"@aragon/osx-v1.0.1": "npm:@aragon/[email protected]", | ||
"@aragon/osx-v1.3.0-rc0.2": "npm:@aragon/[email protected]", | ||
"@defi-wonderland/smock": "^2.3.4", | ||
|
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,15 @@ | ||
import {expect} from 'chai'; | ||
|
||
import {deployments} from 'hardhat'; | ||
import { | ||
ForkOsxVersion, | ||
initForkForOsxVersion, | ||
initializeDeploymentFixture, | ||
} from '../test-utils/fixture'; | ||
|
||
const enableTest = process.env.TEST_UPDATE_DEPLOY_SCRIPT !== undefined; | ||
|
||
export type NetworkForkData = { | ||
networkName: string; | ||
forkBlockNumber: number; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {expect} from 'chai'; | ||
|
||
import {deployments} from 'hardhat'; | ||
import { | ||
ForkOsxVersion, | ||
initForkForOsxVersion, | ||
initializeDeploymentFixture, | ||
} from '../test-utils/fixture'; | ||
import {activeContractsList as v1_3_0_rc0_2_activeContracts} from '@aragon/osx-ethers-v1.3.0-rc0.2'; | ||
|
||
const enableTest = process.env.TEST_UPDATE_DEPLOY_SCRIPT !== undefined; | ||
|
||
export type NetworkForkData = { | ||
networkName: string; | ||
forkBlockNumber: number; | ||
}; | ||
|
||
if (enableTest) { | ||
[ | ||
// TODO: check if those are correct forkBlockNumbers | ||
{networkName: 'mainnet', forkBlockNumber: 16722881}, | ||
{networkName: 'goerli', forkBlockNumber: 9225868}, | ||
{networkName: 'polygon', forkBlockNumber: 42000000}, | ||
{networkName: 'mumbai', forkBlockNumber: 33960187}, | ||
{networkName: 'baseMainnet', forkBlockNumber: 2094661}, | ||
{networkName: 'baseGoerli', forkBlockNumber: 7890908}, | ||
].forEach(function (networkData: NetworkForkData) { | ||
describe(`${networkData.networkName} update/to_v1.4.0`, function () { | ||
before(async () => { | ||
const previousOsxVersion: ForkOsxVersion = { | ||
version: 'v1.3.0', | ||
activeContracts: v1_3_0_rc0_2_activeContracts, | ||
forkBlockNumber: networkData.forkBlockNumber, | ||
}; | ||
|
||
await initForkForOsxVersion( | ||
networkData.networkName, | ||
previousOsxVersion | ||
); | ||
|
||
const updateDeployTags = ['v1.4.0']; | ||
await initializeDeploymentFixture(updateDeployTags); | ||
}); | ||
|
||
it('deploys new contracts with new addresses', async function () { | ||
const changedContracts = [ | ||
'DAOFactory', | ||
// TODO: what about `managingDAOImplemenation` (note the typo in "Implemenation" ) | ||
]; | ||
|
||
const allDeployments = await deployments.all(); | ||
|
||
changedContracts.forEach((contractName: string) => { | ||
const previous = (v1_3_0_rc0_2_activeContracts as any)[ | ||
networkData.networkName | ||
][contractName]; | ||
const current = allDeployments[contractName].address; | ||
|
||
expect(previous).to.not.be.empty; | ||
expect(current).to.not.be.empty; | ||
expect(current).to.not.eq(previous); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
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
Oops, something went wrong.