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

add update to 1.4.0 #627

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
69 changes: 69 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,69 @@
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'];
50 changes: 50 additions & 0 deletions packages/contracts/deploy/update/to_v1.4.0/31_DAORegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import daoRegistryArtifact from '../../../artifacts/src/framework/dao/DAORegistry.sol/DAORegistry.json';
import {
DAOFactory__factory,
DAORegistry__factory,
DAO__factory,
} from '../../../typechain';
import {DAORegistry} from '../../../typechain/@aragon/osx-v1.0.1/framework/dao/DAORegistry.sol';
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 DAORegistry to new Implementation');

const {deployments, ethers} = hre;
const {deploy} = deployments;
const [deployer] = await ethers.getSigners();

const daoRegistryAddress = await getContractAddress('DAORegistryProxy', hre);
const daoRegistry = DAORegistry__factory.connect(
daoRegistryAddress,
hre.ethers.provider
);

const result = await deploy('DAORegistryImplementation', {
contract: daoRegistryArtifact,
from: deployer.address,
args: [],
log: true,
});

const upgradeTX = await daoRegistry.populateTransaction.upgradeTo(
result.address
);

if (!upgradeTX.to || !upgradeTX.data) {
throw new Error(`Failed to populate upgradeToAndCall transaction`);
}

console.log(result.address, ' fuck 2');
hre.managementDAOActions.push({
to: upgradeTX.to,
data: upgradeTX.data,
value: 0,
description: `Upgrade the <strong>DaoRegistry </strong> (<code>${daoRegistryAddress}</code>) to the new <strong>implementation</strong> (<code>${result.address}</code>).`,
});
};
export default func;
func.tags = ['DAORegistry', 'v1.4.0'];
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pluginRepoRegistryArtifact from '../../../artifacts/src/framework/plugin/repo/PluginRepoRegistry.sol/PluginRepoRegistry.json';
import {
DAOFactory__factory,
DAORegistry__factory,
DAO__factory,
PluginRepoRegistry__factory,
} from '../../../typechain';
import {DAORegistry} from '../../../typechain/@aragon/osx-v1.0.1/framework/dao/DAORegistry.sol';
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 pluginRepoRegistry to new Implementation');

const {deployments, ethers} = hre;
const {deploy} = deployments;
const [deployer] = await ethers.getSigners();

const pluginRepoRegistryAddress = await getContractAddress(
'PluginRepoRegistryProxy',
hre
);
const pluginRepoRegistry = PluginRepoRegistry__factory.connect(
pluginRepoRegistryAddress,
hre.ethers.provider
);

const result = await deploy('PluginRepoRegistryImplementation', {
contract: pluginRepoRegistryArtifact,
from: deployer.address,
args: [],
log: true,
});

const upgradeTX = await pluginRepoRegistry.populateTransaction.upgradeTo(
result.address
);

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>PluginRepoRegistry </strong> (<code>${pluginRepoRegistryAddress}</code>) to the new <strong>implementation</strong> (<code>${result.address}</code>).`,
});
};
export default func;
func.tags = ['PluginRepoRegistry', '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
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"eslint-plugin-promise": "^5.1.1",
"ethereumjs-util": "^7.1.4",
"ethers": "^5.7.0",
"hardhat": "^2.12.7",
"hardhat": "^2.22.15",
"hardhat-deploy": "^0.9.26",
"hardhat-gas-reporter": "^1.0.4",
"ipfs-http-client": "51.0.0",
Expand Down
Loading
Loading