From 0429e1424dea3dc24d2bbaba59b2ff1b99a574c7 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Tue, 28 Feb 2023 14:19:57 +0400 Subject: [PATCH 1/2] fix metadata --- .../deploy/00_managing-dao/00_managing-dao.ts | 9 +----- ...0_register-managing-dao-on-dao-registry.ts | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/packages/contracts/deploy/00_managing-dao/00_managing-dao.ts b/packages/contracts/deploy/00_managing-dao/00_managing-dao.ts index ab41e3425..d09eddaae 100644 --- a/packages/contracts/deploy/00_managing-dao/00_managing-dao.ts +++ b/packages/contracts/deploy/00_managing-dao/00_managing-dao.ts @@ -19,15 +19,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ` At the final step when Multisig is available, it will be installed on managingDAO and all roles for the Deployer will be revoked.` ); - const metadataCIDPath = await uploadToIPFS( - JSON.stringify(MANAGING_DAO_METADATA), - network.name - ); - const initializeParams = { - metadata: ethers.utils.hexlify( - ethers.utils.toUtf8Bytes(`ipfs://${metadataCIDPath}`) - ), + metadata: '0x', initialOwner: deployer, trustedForwarder: ethers.constants.AddressZero, daoURI: '0x', diff --git a/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts b/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts index 70cc7737a..5847352e7 100644 --- a/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts +++ b/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts @@ -5,6 +5,8 @@ import { getContractAddress, getENSAddress, isENSDomainRegistered, + MANAGING_DAO_METADATA, + uploadToIPFS, } from '../helpers'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { @@ -53,6 +55,35 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log( `Registered the (managingDAO: ${managingDAOAddress}) on (DAORegistry: ${daoRegistryAddress}), see (tx: ${registerTx.hash})` ); + + // Set Metadata for the Managing DAO + const managingDaoContract = await ethers.getContractAt( + 'DAO', + managingDAOAddress + ); + + const metadataCIDPath = await uploadToIPFS( + JSON.stringify(MANAGING_DAO_METADATA), + network.name + ); + + const SET_METADATA_PERMISSION = ethers.utils.id('SET_METADATA_PERMISSION'); + + await managingDaoContract.grant( + managingDAOAddress, + deployer, + SET_METADATA_PERMISSION + ); + + await managingDaoContract.setMetadata( + ethers.utils.hexlify(ethers.utils.toUtf8Bytes(`ipfs://${metadataCIDPath}`)) + ); + + await managingDaoContract.revoke( + managingDAOAddress, + deployer, + SET_METADATA_PERMISSION + ); }; export default func; func.tags = ['RegisterManagingDAO']; From 37914c1f7df74961652972e682f451e061eef803 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Tue, 28 Feb 2023 14:37:28 +0400 Subject: [PATCH 2/2] better grant --- .../00_grant-permissions.ts | 6 ++++++ .../20_register-managing-dao-on-dao-registry.ts | 14 -------------- .../40_revoke-permissions.ts | 6 ++++++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/contracts/deploy/40_finalize-managing-dao/00_grant-permissions.ts b/packages/contracts/deploy/40_finalize-managing-dao/00_grant-permissions.ts index df709dbec..51719308e 100644 --- a/packages/contracts/deploy/40_finalize-managing-dao/00_grant-permissions.ts +++ b/packages/contracts/deploy/40_finalize-managing-dao/00_grant-permissions.ts @@ -47,6 +47,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { who: {name: 'Deployer', address: deployer}, permission: 'APPLY_INSTALLATION_PERMISSION', }, + { + operation: Operation.Grant, + where: {name: 'DAO', address: managingDAOAddress}, + who: {name: 'Deployer', address: deployer}, + permission: 'SET_METADATA_PERMISSION', + }, ]; await managePermissions(managingDaoContract, grantPermissions); }; diff --git a/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts b/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts index 5847352e7..1b3ae8a92 100644 --- a/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts +++ b/packages/contracts/deploy/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts @@ -67,23 +67,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { network.name ); - const SET_METADATA_PERMISSION = ethers.utils.id('SET_METADATA_PERMISSION'); - - await managingDaoContract.grant( - managingDAOAddress, - deployer, - SET_METADATA_PERMISSION - ); - await managingDaoContract.setMetadata( ethers.utils.hexlify(ethers.utils.toUtf8Bytes(`ipfs://${metadataCIDPath}`)) ); - - await managingDaoContract.revoke( - managingDAOAddress, - deployer, - SET_METADATA_PERMISSION - ); }; export default func; func.tags = ['RegisterManagingDAO']; diff --git a/packages/contracts/deploy/40_finalize-managing-dao/40_revoke-permissions.ts b/packages/contracts/deploy/40_finalize-managing-dao/40_revoke-permissions.ts index 0d9a18fc5..eb1bc582f 100644 --- a/packages/contracts/deploy/40_finalize-managing-dao/40_revoke-permissions.ts +++ b/packages/contracts/deploy/40_finalize-managing-dao/40_revoke-permissions.ts @@ -58,6 +58,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { who: {name: 'Deployer', address: deployer}, permission: 'ROOT_PERMISSION', }, + { + operation: Operation.Revoke, + where: {name: 'DAO', address: managingDAOAddress}, + who: {name: 'Deployer', address: deployer}, + permission: 'SET_METADATA_PERMISSION', + }, ]; await managePermissions(managingDaoContract, revokePermissions);