From 68f8cc992004f402b91399abb98f19555720dad8 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 24 Jan 2025 12:12:02 +0100 Subject: [PATCH 01/20] feat: import the Placeholder to de able to deploy it --- packages/contracts/src/mocks/Migration.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/contracts/src/mocks/Migration.sol b/packages/contracts/src/mocks/Migration.sol index 6d0dab69..248fc785 100644 --- a/packages/contracts/src/mocks/Migration.sol +++ b/packages/contracts/src/mocks/Migration.sol @@ -16,6 +16,8 @@ pragma solidity ^0.8.8; /* solhint-disable no-unused-import */ import {DAO} from "@aragon/osx/core/dao/DAO.sol"; +import {PlaceholderSetup} from "@aragon/osx/framework/plugin/repo/placeholder/PlaceholderSetup.sol"; + import {PluginRepo} from "@aragon/osx-v1.3.0/framework/plugin/repo/PluginRepo.sol"; import {ProxyFactory} from "@aragon/osx-commons-contracts/src/utils/deployment/ProxyFactory.sol"; From 6d34798b4854738694b1764a766599d71821ece2 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 24 Jan 2025 12:12:37 +0100 Subject: [PATCH 02/20] feat: update the scripts to be able to get the plugin reo and the plugin repo address from the env vars --- .../deploy/10_create_repo/11_create_repo.ts | 91 +++++++++++++++---- .../deploy/20_new_version/23_publish.ts | 21 ++++- packages/contracts/utils/helpers.ts | 56 +++++++++--- 3 files changed, 133 insertions(+), 35 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index caf42237..2541d2f3 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -18,6 +18,7 @@ import { PluginRepo__factory, PluginRepoFactory__factory, } from '@aragon/osx-ethers'; +import {ethers} from 'hardhat'; import {DeployFunction} from 'hardhat-deploy/types'; import {HardhatRuntimeEnvironment} from 'hardhat/types'; import path from 'path'; @@ -27,6 +28,7 @@ import path from 'path'; * @param {HardhatRuntimeEnvironment} hre */ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + // todo change this log console.log( `Creating the '${pluginEnsDomain( hre @@ -36,23 +38,52 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const [deployer] = await hre.ethers.getSigners(); // Get the Aragon `PluginRepoFactory` from the `osx-commons-configs` - const productionNetworkName = getProductionNetworkName(hre); - const network = getNetworkNameByAlias(productionNetworkName); - if (network === null) { - throw new UnsupportedNetworkError(productionNetworkName); - } - const networkDeployments = getLatestNetworkDeployment(network); - if (networkDeployments === null) { - throw `Deployments are not available on network ${network}.`; + let pluginRepoFactoryAddress; + let subdomainRegistrar; + if (process.env.PLUGIN_REPO_FACTORY_ADDRESS) { + // use this factory + pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + + const pluginRepoFactory = PluginRepoFactory__factory.connect( + process.env.PLUGIN_REPO_FACTORY_ADDRESS, + deployer + ); + + const pluginRepoRegistry = PluginRepoRegistry__factory.connect( + await pluginRepoFactory.pluginRepoRegistry(), + deployer + ); + subdomainRegistrar = await pluginRepoRegistry.subdomainRegistrar(); + } else { + // get the factory from osx-commons-configs deployments + const productionNetworkName = getProductionNetworkName(hre); + const network = getNetworkNameByAlias(productionNetworkName); + if (network === null) { + throw new UnsupportedNetworkError(productionNetworkName); + } + const networkDeployments = getLatestNetworkDeployment(network); + if (networkDeployments === null) { + throw `Deployments are not available on network ${network}.`; + } + pluginRepoFactoryAddress = networkDeployments.PluginRepoFactory.address; + + subdomainRegistrar = + networkDeployments.PluginENSSubdomainRegistrarProxy.address; } + // subdomain will depend on if the framework has the ens or not + const subdomain = + subdomainRegistrar !== ethers.constants.AddressZero + ? PLUGIN_REPO_ENS_SUBDOMAIN_NAME + : 'empty'; // todo set to empty when is possible + const pluginRepoFactory = PluginRepoFactory__factory.connect( - networkDeployments.PluginRepoFactory.address, + pluginRepoFactoryAddress, deployer ); // Create the `PluginRepo` through the Aragon `PluginRepoFactory` const tx = await pluginRepoFactory.createPluginRepo( - PLUGIN_REPO_ENS_SUBDOMAIN_NAME, + subdomain, deployer.address ); @@ -90,24 +121,46 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => { console.log(`\n🏗️ ${path.basename(__filename)}:`); // Check if the ens record exists already - const {pluginRepo, ensDomain} = await findPluginRepo(hre); + let pluginRepoAddress; + let ensDomain = ''; + if ( + !process.env.PLUGIN_REPO_ADDRESS || + process.env.PLUGIN_REPO_ADDRESS === ethers.constants.AddressZero + ) { + // try getting the plugin repo from the ens + const res = await findPluginRepo(hre); + pluginRepoAddress = res.pluginRepo?.address; + ensDomain = res.ensDomain; + } else { + // use the provided plugin repo address + pluginRepoAddress = process.env.PLUGIN_REPO_ADDRESS; - if (pluginRepo !== null) { console.log( - `ENS name '${ensDomain}' was claimed already at '${ - pluginRepo.address - }' on network '${getProductionNetworkName(hre)}'. Skipping deployment...` + `Plugin Repo already deployed at '${pluginRepoAddress}' on network '${getProductionNetworkName( + hre + )}'. Skipping deployment...` + ); + return true; + } + + if (pluginRepoAddress) { + console.log( + `ENS name '${ensDomain}' was claimed already at '${pluginRepoAddress}' on network '${getProductionNetworkName( + hre + )}'. Skipping deployment...` ); + // todo if the plugin repo was already published should it be verified? hre.aragonToVerifyContracts.push({ - address: pluginRepo.address, + address: pluginRepoAddress, args: [], }); - return true; } else { - console.log(`ENS name '${ensDomain}' is unclaimed. Deploying...`); - + // todo change this log + console.log( + `ENS name '${ensDomain}' is unclaimed. Deploying Plugin Repo...` + ); return false; } }; diff --git a/packages/contracts/deploy/20_new_version/23_publish.ts b/packages/contracts/deploy/20_new_version/23_publish.ts index b784f1a0..8aa78581 100644 --- a/packages/contracts/deploy/20_new_version/23_publish.ts +++ b/packages/contracts/deploy/20_new_version/23_publish.ts @@ -140,11 +140,24 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { [] ) ) { - const placeholderSetup = getLatestContractAddress('PlaceholderSetup', hre); + let placeholderSetup = getLatestContractAddress('PlaceholderSetup', hre); + if (placeholderSetup == '') { - throw new Error( - 'Aborting. Placeholder setup not present in this network' - ); + // deploy placeholder setup + const {deploy} = deployments; + const res = await deploy(PLUGIN_SETUP_CONTRACT_NAME, { + from: deployer.address, + args: [], + log: true, + }); + + placeholderSetup = res.address; + + // Queue the placeholder for verification + hre.aragonToVerifyContracts.push({ + address: placeholderSetup, + args: [], + }); } if (latestBuild == 0 && VERSION.build > 1) { for (let i = 0; i < VERSION.build - 1; i++) { diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 83d5306a..01fe038a 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -15,6 +15,8 @@ import { PluginRepo, PluginRepoEvents, PluginRepo__factory, + PluginRepoFactory__factory, + PluginRepoRegistry__factory, } from '@aragon/osx-ethers'; import {setBalance} from '@nomicfoundation/hardhat-network-helpers'; import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; @@ -69,21 +71,51 @@ export async function findPluginRepo( hre: HardhatRuntimeEnvironment ): Promise<{pluginRepo: PluginRepo | null; ensDomain: string}> { const [deployer] = await hre.ethers.getSigners(); - const productionNetworkName: string = getProductionNetworkName(hre); - const network = getNetworkNameByAlias(productionNetworkName); - if (network === null) { - throw new UnsupportedNetworkError(productionNetworkName); - } - const networkDeployments = getLatestNetworkDeployment(network); - if (networkDeployments === null) { - throw `Deployments are not available on network ${network}.`; + let subdomainRegistrarAddress; + if ( + process.env.PLUGIN_REPO_FACTORY_ADDRESS && + process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero + ) { + // get ENS registrar from the plugin factory provided + const pluginRepoFactory = PluginRepoFactory__factory.connect( + process.env.PLUGIN_REPO_FACTORY_ADDRESS, + deployer + ); + + const pluginRepoRegistry = PluginRepoRegistry__factory.connect( + await pluginRepoFactory.pluginRepoRegistry(), + deployer + ); + + subdomainRegistrarAddress = await pluginRepoRegistry.subdomainRegistrar(); + } else { + // get ENS registrar from the commons configs deployments + const productionNetworkName: string = getProductionNetworkName(hre); + + const network = getNetworkNameByAlias(productionNetworkName); + if (network === null) { + throw new UnsupportedNetworkError(productionNetworkName); + } + const networkDeployments = getLatestNetworkDeployment(network); + if (networkDeployments === null) { + throw `Deployments are not available on network ${network}.`; + } + + subdomainRegistrarAddress = + networkDeployments.PluginENSSubdomainRegistrarProxy.address; } - const registrar = ENSSubdomainRegistrar__factory.connect( - networkDeployments.PluginENSSubdomainRegistrarProxy.address, - deployer - ); + let registrar; + if (subdomainRegistrarAddress === ethers.constants.AddressZero) { + // the network does not support ENS + return {pluginRepo: null, ensDomain: ''}; + } else { + registrar = ENSSubdomainRegistrar__factory.connect( + subdomainRegistrarAddress, + deployer + ); + } // Check if the ens record exists already const ens = ENS__factory.connect(await registrar.ens(), deployer); From 382bed0c59822ccc1a955da6cd59c68a5ce24a30 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 24 Jan 2025 12:35:13 +0100 Subject: [PATCH 03/20] feat: some cleaning --- packages/contracts/deploy/10_create_repo/11_create_repo.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index 2541d2f3..b0c17e83 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -40,12 +40,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Get the Aragon `PluginRepoFactory` from the `osx-commons-configs` let pluginRepoFactoryAddress; let subdomainRegistrar; - if (process.env.PLUGIN_REPO_FACTORY_ADDRESS) { + if ( + process.env.PLUGIN_REPO_FACTORY_ADDRESS && + process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero + ) { // use this factory pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; const pluginRepoFactory = PluginRepoFactory__factory.connect( - process.env.PLUGIN_REPO_FACTORY_ADDRESS, + pluginRepoFactoryAddress, deployer ); From d5829070419152703dea1202dea268369a0709c0 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 24 Jan 2025 12:36:10 +0100 Subject: [PATCH 04/20] feat: modify the update plugin script to get the addresses from the commons config or the env file --- .../deploy/30_upgrade_repo/_common.ts | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/contracts/deploy/30_upgrade_repo/_common.ts b/packages/contracts/deploy/30_upgrade_repo/_common.ts index 1070dcec..e5f55140 100644 --- a/packages/contracts/deploy/30_upgrade_repo/_common.ts +++ b/packages/contracts/deploy/30_upgrade_repo/_common.ts @@ -4,8 +4,13 @@ import { getNetworkNameByAlias, } from '@aragon/osx-commons-configs'; import {UnsupportedNetworkError} from '@aragon/osx-commons-sdk'; -import {PluginRepo, PluginRepo__factory} from '@aragon/osx-ethers'; +import { + PluginRepo, + PluginRepo__factory, + PluginRepoFactory__factory, +} from '@aragon/osx-ethers'; import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; +import {ethers} from 'hardhat'; import {DeployFunction} from 'hardhat-deploy/types'; import {HardhatRuntimeEnvironment} from 'hardhat/types'; import path from 'path'; @@ -30,10 +35,6 @@ export async function fetchData( if (network === null) { throw new UnsupportedNetworkError(productionNetworkName); } - const networkDeployments = getLatestNetworkDeployment(network); - if (networkDeployments === null) { - throw `Deployments are not available on network ${network}.`; - } // Get PluginRepo const {pluginRepo, ensDomain} = await findPluginRepo(hre); @@ -46,10 +47,29 @@ export async function fetchData( ); // Get the latest `PluginRepo` implementation as the upgrade target - const latestPluginRepoImplementation = PluginRepo__factory.connect( - networkDeployments.PluginRepoBase.address, - deployer - ); + let latestPluginRepoImplementation; + if ( + process.env.PLUGIN_REPO_FACTORY_ADDRESS && + process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero + ) { + const pluginRepoFactory = PluginRepoFactory__factory.connect( + process.env.PLUGIN_REPO_FACTORY_ADDRESS, + deployer + ); + latestPluginRepoImplementation = PluginRepo__factory.connect( + await pluginRepoFactory.pluginRepoBase(), + deployer + ); + } else { + const networkDeployments = getLatestNetworkDeployment(network); + if (networkDeployments === null) { + throw `Deployments are not available on network ${network}.`; + } + latestPluginRepoImplementation = PluginRepo__factory.connect( + networkDeployments.PluginRepoBase.address, + deployer + ); + } // Get the current OSX protocol version from the current plugin repo implementation let current: SemVer; From cfeedfc803178aedf6fe318258cda7bd14521173 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Mon, 27 Jan 2025 11:50:20 +0400 Subject: [PATCH 05/20] better approach --- packages/contracts/deploy/00_info/01_info.ts | 21 +++--- .../deploy/10_create_repo/11_create_repo.ts | 73 ++++++++----------- .../deploy/20_new_version/23_publish.ts | 31 +++----- .../deploy/30_upgrade_repo/_common.ts | 13 ++-- packages/contracts/deploy/helpers.ts | 16 ++++ packages/contracts/utils/helpers.ts | 33 ++++++--- 6 files changed, 98 insertions(+), 89 deletions(-) diff --git a/packages/contracts/deploy/00_info/01_info.ts b/packages/contracts/deploy/00_info/01_info.ts index d6f6acaa..73743d46 100644 --- a/packages/contracts/deploy/00_info/01_info.ts +++ b/packages/contracts/deploy/00_info/01_info.ts @@ -4,6 +4,7 @@ import { getProductionNetworkName, isLocal, } from '../../utils/helpers'; +import {forkNetwork} from '../helpers'; import {getNetworkByNameOrAlias} from '@aragon/osx-commons-configs'; import {UnsupportedNetworkError} from '@aragon/osx-commons-sdk'; import {DeployFunction} from 'hardhat-deploy/types'; @@ -20,7 +21,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log(`\n✨ ${path.basename(__filename)}:`); const [deployer] = await hre.ethers.getSigners(); - if (isLocal(hre)) { + + if (process.env.FORKING_RPC_URL) { + await forkNetwork(hre, process.env.FORKING_RPC_URL); + } else if (isLocal(hre)) { const productionNetworkName: string = getProductionNetworkName(hre); console.log( @@ -32,16 +36,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { if (networkConfig === null) { throw new UnsupportedNetworkError(productionNetworkName); } - await hre.network.provider.request({ - method: 'hardhat_reset', - params: [ - { - forking: { - jsonRpcUrl: networkConfig.url, - }, - }, - ], - }); + if (!networkConfig.url) { + throw new Error('RPC Url on network not defined'); + } + + await forkNetwork(hre, networkConfig.url); } else { console.log(`Production deployment on network '${hre.network.name}'.`); } diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index b0c17e83..70334814 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -37,16 +37,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const [deployer] = await hre.ethers.getSigners(); - // Get the Aragon `PluginRepoFactory` from the `osx-commons-configs` - let pluginRepoFactoryAddress; + let pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; let subdomainRegistrar; - if ( - process.env.PLUGIN_REPO_FACTORY_ADDRESS && - process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero - ) { - // use this factory - pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + if (pluginRepoFactoryAddress) { + // use this factory const pluginRepoFactory = PluginRepoFactory__factory.connect( pluginRepoFactoryAddress, deployer @@ -77,7 +72,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const subdomain = subdomainRegistrar !== ethers.constants.AddressZero ? PLUGIN_REPO_ENS_SUBDOMAIN_NAME - : 'empty'; // todo set to empty when is possible + : ''; const pluginRepoFactory = PluginRepoFactory__factory.connect( pluginRepoFactoryAddress, @@ -104,7 +99,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ); console.log( - `PluginRepo '${pluginEnsDomain(hre)}' deployed at '${pluginRepo.address}'.` + `PluginRepo ${ + subdomainRegistrar !== ethers.constants.AddressZero + } ? '${pluginEnsDomain(hre)}' : ${''} deployed at '${pluginRepo.address}'.` ); hre.aragonToVerifyContracts.push({ @@ -123,47 +120,35 @@ func.tags = ['CreateRepo']; func.skip = async (hre: HardhatRuntimeEnvironment) => { console.log(`\n🏗️ ${path.basename(__filename)}:`); - // Check if the ens record exists already - let pluginRepoAddress; - let ensDomain = ''; - if ( - !process.env.PLUGIN_REPO_ADDRESS || - process.env.PLUGIN_REPO_ADDRESS === ethers.constants.AddressZero - ) { - // try getting the plugin repo from the ens - const res = await findPluginRepo(hre); - pluginRepoAddress = res.pluginRepo?.address; - ensDomain = res.ensDomain; - } else { - // use the provided plugin repo address - pluginRepoAddress = process.env.PLUGIN_REPO_ADDRESS; - - console.log( - `Plugin Repo already deployed at '${pluginRepoAddress}' on network '${getProductionNetworkName( - hre - )}'. Skipping deployment...` - ); - return true; - } + // try getting the plugin repo. + const res = await findPluginRepo(hre); + let pluginRepoAddress = res.pluginRepo?.address; + let ensDomain = res.ensDomain; if (pluginRepoAddress) { - console.log( - `ENS name '${ensDomain}' was claimed already at '${pluginRepoAddress}' on network '${getProductionNetworkName( - hre - )}'. Skipping deployment...` - ); + if (ensDomain != '') { + console.log( + `ENS name '${ensDomain}' was claimed already at '${pluginRepoAddress}' on network '${getProductionNetworkName( + hre + )}'. Skipping deployment...` + ); + } else { + console.log( + `Plugin Repo already deployed at '${pluginRepoAddress}' on network '${getProductionNetworkName( + hre + )}'. Skipping deployment...` + ); + } - // todo if the plugin repo was already published should it be verified? hre.aragonToVerifyContracts.push({ address: pluginRepoAddress, args: [], }); + return true; - } else { - // todo change this log - console.log( - `ENS name '${ensDomain}' is unclaimed. Deploying Plugin Repo...` - ); - return false; } + + console.log('Deploying Plugin Repo'); + + return false; }; diff --git a/packages/contracts/deploy/20_new_version/23_publish.ts b/packages/contracts/deploy/20_new_version/23_publish.ts index 8aa78581..ed5a8ed9 100644 --- a/packages/contracts/deploy/20_new_version/23_publish.ts +++ b/packages/contracts/deploy/20_new_version/23_publish.ts @@ -76,7 +76,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Get PluginRepo const {pluginRepo, ensDomain} = await findPluginRepo(hre); if (pluginRepo === null) { - throw `PluginRepo '${ensDomain}' does not exist yet.`; + throw `Can't find Plugin Repo...`; } // Check release number @@ -140,26 +140,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { [] ) ) { - let placeholderSetup = getLatestContractAddress('PlaceholderSetup', hre); - - if (placeholderSetup == '') { - // deploy placeholder setup - const {deploy} = deployments; - const res = await deploy(PLUGIN_SETUP_CONTRACT_NAME, { - from: deployer.address, - args: [], - log: true, - }); - - placeholderSetup = res.address; - - // Queue the placeholder for verification - hre.aragonToVerifyContracts.push({ - address: placeholderSetup, - args: [], - }); - } if (latestBuild == 0 && VERSION.build > 1) { + // We are publishing the first version as build > 1. + // So we need to publish placeholders first.. + let placeholderSetup = + process.env.PLACEHOLDER_SETUP ?? + getLatestContractAddress('PlaceholderSetup', hre); + + if (!ethers.utils.isAddress(placeholderSetup)) { + ('Aborting. Placeholder setup not present in this network or in .env or is not an address'); + } + for (let i = 0; i < VERSION.build - 1; i++) { console.log('Publishing placeholder', i + 1); await createVersion( diff --git a/packages/contracts/deploy/30_upgrade_repo/_common.ts b/packages/contracts/deploy/30_upgrade_repo/_common.ts index e5f55140..6d6b8d2f 100644 --- a/packages/contracts/deploy/30_upgrade_repo/_common.ts +++ b/packages/contracts/deploy/30_upgrade_repo/_common.ts @@ -48,12 +48,15 @@ export async function fetchData( // Get the latest `PluginRepo` implementation as the upgrade target let latestPluginRepoImplementation; - if ( - process.env.PLUGIN_REPO_FACTORY_ADDRESS && - process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero - ) { + let pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + + if (pluginRepoFactoryAddress) { + if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { + throw new Error('Plugin Repo Factory in .env is not of type Address'); + } + const pluginRepoFactory = PluginRepoFactory__factory.connect( - process.env.PLUGIN_REPO_FACTORY_ADDRESS, + pluginRepoFactoryAddress, deployer ); latestPluginRepoImplementation = PluginRepo__factory.connect( diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index 04713a76..c84d5927 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -29,3 +29,19 @@ export function getLatestContractAddress( } return ''; } + +export async function forkNetwork( + hre: HardhatRuntimeEnvironment, + fork_url: string +) { + await hre.network.provider.request({ + method: 'hardhat_reset', + params: [ + { + forking: { + jsonRpcUrl: fork_url, + }, + }, + ], + }); +} diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 01fe038a..8c4a17c3 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -72,14 +72,29 @@ export async function findPluginRepo( ): Promise<{pluginRepo: PluginRepo | null; ensDomain: string}> { const [deployer] = await hre.ethers.getSigners(); - let subdomainRegistrarAddress; if ( - process.env.PLUGIN_REPO_FACTORY_ADDRESS && - process.env.PLUGIN_REPO_FACTORY_ADDRESS !== ethers.constants.AddressZero + process.env.PLUGIN_REPO_ADDRESS && + ethers.utils.isAddress(process.env.PLUGIN_REPO_ADDRESS) ) { + return { + pluginRepo: PluginRepo__factory.connect( + process.env.PLUGIN_REPO_ADDRESS, + deployer + ), + ensDomain: '', + }; + } + + let subdomainRegistrarAddress; + let pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + + if (pluginRepoFactoryAddress) { + if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { + throw new Error('Plugin Repo Factory in .env is not of type Address'); + } // get ENS registrar from the plugin factory provided const pluginRepoFactory = PluginRepoFactory__factory.connect( - process.env.PLUGIN_REPO_FACTORY_ADDRESS, + pluginRepoFactoryAddress, deployer ); @@ -110,13 +125,13 @@ export async function findPluginRepo( if (subdomainRegistrarAddress === ethers.constants.AddressZero) { // the network does not support ENS return {pluginRepo: null, ensDomain: ''}; - } else { - registrar = ENSSubdomainRegistrar__factory.connect( - subdomainRegistrarAddress, - deployer - ); } + registrar = ENSSubdomainRegistrar__factory.connect( + subdomainRegistrarAddress, + deployer + ); + // Check if the ens record exists already const ens = ENS__factory.connect(await registrar.ens(), deployer); const ensDomain = pluginEnsDomain(hre); From 7101b932db9e65819b47968f848737017423f67a Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 27 Jan 2025 11:44:12 +0100 Subject: [PATCH 06/20] feat: early revert if the plugin repo env var is not an address --- packages/contracts/utils/helpers.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 8c4a17c3..cdb1dd8f 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -72,10 +72,11 @@ export async function findPluginRepo( ): Promise<{pluginRepo: PluginRepo | null; ensDomain: string}> { const [deployer] = await hre.ethers.getSigners(); - if ( - process.env.PLUGIN_REPO_ADDRESS && - ethers.utils.isAddress(process.env.PLUGIN_REPO_ADDRESS) - ) { + if (process.env.PLUGIN_REPO_ADDRESS) { + if (!ethers.utils.isAddress(process.env.PLUGIN_REPO_ADDRESS)) { + throw new Error('Plugin Repo in .env is not of type Address'); + } + return { pluginRepo: PluginRepo__factory.connect( process.env.PLUGIN_REPO_ADDRESS, From f5a2402f0f6f3cafa0af7d38f69d98fb4f151bc8 Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 27 Jan 2025 11:46:28 +0100 Subject: [PATCH 07/20] fix lint --- packages/contracts/deploy/10_create_repo/11_create_repo.ts | 4 ++-- packages/contracts/deploy/20_new_version/23_publish.ts | 2 +- packages/contracts/deploy/30_upgrade_repo/_common.ts | 2 +- packages/contracts/utils/helpers.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index 70334814..2fdf9205 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -122,8 +122,8 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => { // try getting the plugin repo. const res = await findPluginRepo(hre); - let pluginRepoAddress = res.pluginRepo?.address; - let ensDomain = res.ensDomain; + const pluginRepoAddress = res.pluginRepo?.address; + const ensDomain = res.ensDomain; if (pluginRepoAddress) { if (ensDomain != '') { diff --git a/packages/contracts/deploy/20_new_version/23_publish.ts b/packages/contracts/deploy/20_new_version/23_publish.ts index ed5a8ed9..bb68a8b3 100644 --- a/packages/contracts/deploy/20_new_version/23_publish.ts +++ b/packages/contracts/deploy/20_new_version/23_publish.ts @@ -143,7 +143,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { if (latestBuild == 0 && VERSION.build > 1) { // We are publishing the first version as build > 1. // So we need to publish placeholders first.. - let placeholderSetup = + const placeholderSetup = process.env.PLACEHOLDER_SETUP ?? getLatestContractAddress('PlaceholderSetup', hre); diff --git a/packages/contracts/deploy/30_upgrade_repo/_common.ts b/packages/contracts/deploy/30_upgrade_repo/_common.ts index 6d6b8d2f..d6a79bd8 100644 --- a/packages/contracts/deploy/30_upgrade_repo/_common.ts +++ b/packages/contracts/deploy/30_upgrade_repo/_common.ts @@ -48,7 +48,7 @@ export async function fetchData( // Get the latest `PluginRepo` implementation as the upgrade target let latestPluginRepoImplementation; - let pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + const pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; if (pluginRepoFactoryAddress) { if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index cdb1dd8f..6ae94026 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -87,7 +87,7 @@ export async function findPluginRepo( } let subdomainRegistrarAddress; - let pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; + const pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; if (pluginRepoFactoryAddress) { if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { From 4b5dfebc8da2294ebd0822cfea78b525c6fc2175 Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 27 Jan 2025 11:48:59 +0100 Subject: [PATCH 08/20] fix lint --- packages/contracts/utils/helpers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 6ae94026..29129d85 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -122,13 +122,12 @@ export async function findPluginRepo( networkDeployments.PluginENSSubdomainRegistrarProxy.address; } - let registrar; if (subdomainRegistrarAddress === ethers.constants.AddressZero) { // the network does not support ENS return {pluginRepo: null, ensDomain: ''}; } - registrar = ENSSubdomainRegistrar__factory.connect( + const registrar = ENSSubdomainRegistrar__factory.connect( subdomainRegistrarAddress, deployer ); From 4d11538601b1e3766c5857be48840cc1ddeebe51 Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Mon, 27 Jan 2025 16:01:04 +0400 Subject: [PATCH 09/20] add comments --- packages/contracts/deploy/10_create_repo/11_create_repo.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index 70334814..22bdbf36 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -41,6 +41,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { let subdomainRegistrar; if (pluginRepoFactoryAddress) { + if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { + throw new Error('Plugin Repo Factory in .env is not of type Address'); + } // use this factory const pluginRepoFactory = PluginRepoFactory__factory.connect( pluginRepoFactoryAddress, @@ -101,7 +104,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log( `PluginRepo ${ subdomainRegistrar !== ethers.constants.AddressZero - } ? '${pluginEnsDomain(hre)}' : ${''} deployed at '${pluginRepo.address}'.` + ? 'with ens:' + pluginEnsDomain(hre) + : 'without ens' + } deployed at '${pluginRepo.address}'.` ); hre.aragonToVerifyContracts.push({ From 4e15e0295b9c8cebdafb163ffc421b70a7d74232 Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 27 Jan 2025 13:49:31 +0100 Subject: [PATCH 10/20] feat: ad is valid function to check if the address have the address type and are not ero address --- .../deploy/10_create_repo/11_create_repo.ts | 3 ++- .../deploy/20_new_version/23_publish.ts | 9 +++++++-- .../deploy/30_upgrade_repo/_common.ts | 12 ++++++++--- packages/contracts/utils/helpers.ts | 20 +++++++++++++++---- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index 323e459d..fb491b8e 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -3,6 +3,7 @@ import { findPluginRepo, getProductionNetworkName, pluginEnsDomain, + isValidAddress, } from '../../utils/helpers'; import { getLatestNetworkDeployment, @@ -41,7 +42,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { let subdomainRegistrar; if (pluginRepoFactoryAddress) { - if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { + if (!isValidAddress(pluginRepoFactoryAddress)) { throw new Error('Plugin Repo Factory in .env is not of type Address'); } // use this factory diff --git a/packages/contracts/deploy/20_new_version/23_publish.ts b/packages/contracts/deploy/20_new_version/23_publish.ts index bb68a8b3..876f3e62 100644 --- a/packages/contracts/deploy/20_new_version/23_publish.ts +++ b/packages/contracts/deploy/20_new_version/23_publish.ts @@ -12,6 +12,7 @@ import { impersonatedManagementDaoSigner, isLocal, pluginEnsDomain, + isValidAddress, } from '../../utils/helpers'; import {getLatestContractAddress} from '../helpers'; import {PLUGIN_REPO_PERMISSIONS, uploadToPinata} from '@aragon/osx-commons-sdk'; @@ -38,6 +39,7 @@ async function createVersion( ethers.utils.hexlify(ethers.utils.toUtf8Bytes(buildMetadataURI)), ethers.utils.hexlify(ethers.utils.toUtf8Bytes(releaseMetadataURI)) ); + await tx.wait(); } @@ -147,8 +149,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { process.env.PLACEHOLDER_SETUP ?? getLatestContractAddress('PlaceholderSetup', hre); - if (!ethers.utils.isAddress(placeholderSetup)) { - ('Aborting. Placeholder setup not present in this network or in .env or is not an address'); + if (!isValidAddress(placeholderSetup)) { + throw new Error( + 'Aborting. Placeholder setup not present in this network or in .env or is not a valid address (is not an address or is address zero)' + ); } for (let i = 0; i < VERSION.build - 1; i++) { @@ -164,6 +168,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } } + // Create the new version await createVersion( pluginRepo, VERSION.release, diff --git a/packages/contracts/deploy/30_upgrade_repo/_common.ts b/packages/contracts/deploy/30_upgrade_repo/_common.ts index d6a79bd8..5fd4e9ca 100644 --- a/packages/contracts/deploy/30_upgrade_repo/_common.ts +++ b/packages/contracts/deploy/30_upgrade_repo/_common.ts @@ -1,4 +1,8 @@ -import {findPluginRepo, getProductionNetworkName} from '../../utils/helpers'; +import { + findPluginRepo, + getProductionNetworkName, + isValidAddress, +} from '../../utils/helpers'; import { getLatestNetworkDeployment, getNetworkNameByAlias, @@ -51,8 +55,10 @@ export async function fetchData( const pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; if (pluginRepoFactoryAddress) { - if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { - throw new Error('Plugin Repo Factory in .env is not of type Address'); + if (!isValidAddress(pluginRepoFactoryAddress)) { + throw new Error( + 'Plugin Repo Factory in .env is not a valid address (is not an address or is address zero)' + ); } const pluginRepoFactory = PluginRepoFactory__factory.connect( diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index 29129d85..ff4ad649 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -73,8 +73,10 @@ export async function findPluginRepo( const [deployer] = await hre.ethers.getSigners(); if (process.env.PLUGIN_REPO_ADDRESS) { - if (!ethers.utils.isAddress(process.env.PLUGIN_REPO_ADDRESS)) { - throw new Error('Plugin Repo in .env is not of type Address'); + if (!isValidAddress(process.env.PLUGIN_REPO_ADDRESS)) { + throw new Error( + 'Plugin Repo in .env is not a valid address (is not an address or is address zero)' + ); } return { @@ -90,8 +92,10 @@ export async function findPluginRepo( const pluginRepoFactoryAddress = process.env.PLUGIN_REPO_FACTORY_ADDRESS; if (pluginRepoFactoryAddress) { - if (!ethers.utils.isAddress(pluginRepoFactoryAddress)) { - throw new Error('Plugin Repo Factory in .env is not of type Address'); + if (!isValidAddress(pluginRepoFactoryAddress)) { + throw new Error( + 'Plugin Repo Factory in .env is not valid address (is not an address or is address zero)' + ); } // get ENS registrar from the plugin factory provided const pluginRepoFactory = PluginRepoFactory__factory.connect( @@ -291,5 +295,13 @@ export async function createVersion( return tx; } +export function isValidAddress(address: string): boolean { + // check if the address is of type address and not zero address + + return ( + ethers.utils.isAddress(address) && address !== ethers.constants.AddressZero + ); +} + export const AragonOSxAsciiArt = " ____ _____ \n /\\ / __ \\ / ____| \n / \\ _ __ __ _ __ _ ___ _ __ | | | | (_____ __ \n / /\\ \\ | '__/ _` |/ _` |/ _ \\| '_ \\ | | | |\\___ \\ \\/ / \n / ____ \\| | | (_| | (_| | (_) | | | | | |__| |____) > < \n /_/ \\_\\_| \\__,_|\\__, |\\___/|_| |_| \\____/|_____/_/\\_\\ \n __/ | \n |___/ \n"; From a5209244cdb89e558490beba51998e0a69c52324 Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 27 Jan 2025 13:52:55 +0100 Subject: [PATCH 11/20] fix: remove not needed import --- packages/contracts/deploy/30_upgrade_repo/_common.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts/deploy/30_upgrade_repo/_common.ts b/packages/contracts/deploy/30_upgrade_repo/_common.ts index 5fd4e9ca..b7313211 100644 --- a/packages/contracts/deploy/30_upgrade_repo/_common.ts +++ b/packages/contracts/deploy/30_upgrade_repo/_common.ts @@ -14,7 +14,6 @@ import { PluginRepoFactory__factory, } from '@aragon/osx-ethers'; import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; -import {ethers} from 'hardhat'; import {DeployFunction} from 'hardhat-deploy/types'; import {HardhatRuntimeEnvironment} from 'hardhat/types'; import path from 'path'; From 0c8c40f7c9d5a69536b8adfb3bba0bb970932442 Mon Sep 17 00:00:00 2001 From: Claudia Date: Tue, 28 Jan 2025 11:07:50 +0100 Subject: [PATCH 12/20] fix: remove placeholder import since it is not needed --- packages/contracts/src/mocks/Migration.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts/src/mocks/Migration.sol b/packages/contracts/src/mocks/Migration.sol index 248fc785..8e6a3d2c 100644 --- a/packages/contracts/src/mocks/Migration.sol +++ b/packages/contracts/src/mocks/Migration.sol @@ -16,7 +16,6 @@ pragma solidity ^0.8.8; /* solhint-disable no-unused-import */ import {DAO} from "@aragon/osx/core/dao/DAO.sol"; -import {PlaceholderSetup} from "@aragon/osx/framework/plugin/repo/placeholder/PlaceholderSetup.sol"; import {PluginRepo} from "@aragon/osx-v1.3.0/framework/plugin/repo/PluginRepo.sol"; import {ProxyFactory} from "@aragon/osx-commons-contracts/src/utils/deployment/ProxyFactory.sol"; From 26ee0fc3376e83d09b907d2c561457e336b3a192 Mon Sep 17 00:00:00 2001 From: Claudia Date: Tue, 28 Jan 2025 11:08:34 +0100 Subject: [PATCH 13/20] fix --- packages/contracts/src/mocks/Migration.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts/src/mocks/Migration.sol b/packages/contracts/src/mocks/Migration.sol index 8e6a3d2c..6d0dab69 100644 --- a/packages/contracts/src/mocks/Migration.sol +++ b/packages/contracts/src/mocks/Migration.sol @@ -16,7 +16,6 @@ pragma solidity ^0.8.8; /* solhint-disable no-unused-import */ import {DAO} from "@aragon/osx/core/dao/DAO.sol"; - import {PluginRepo} from "@aragon/osx-v1.3.0/framework/plugin/repo/PluginRepo.sol"; import {ProxyFactory} from "@aragon/osx-commons-contracts/src/utils/deployment/ProxyFactory.sol"; From 01f845910d1fba14752536a455261619bdbd51a3 Mon Sep 17 00:00:00 2001 From: Claudia Date: Wed, 29 Jan 2025 14:57:11 +0100 Subject: [PATCH 14/20] feat: add script to store the deployed plugin repo address on a json file --- .../deploy/10_create_repo/11_create_repo.ts | 9 ++++++ packages/contracts/deploy/helpers.ts | 32 +++++++++++++++++++ packages/contracts/plugin-settings.ts | 8 ++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index fb491b8e..efaa6972 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -5,6 +5,7 @@ import { pluginEnsDomain, isValidAddress, } from '../../utils/helpers'; +import {savePluginRepoAddress} from '../helpers'; import { getLatestNetworkDeployment, getNetworkNameByAlias, @@ -114,6 +115,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { address: pluginRepo.address, args: [], }); + + savePluginRepoAddress( + hre, + pluginRepo.address, + await pluginRepoFactory.pluginRepoBase(), + tx.hash, + tx.blockNumber + ); }; export default func; diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index c84d5927..9849522c 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -1,3 +1,4 @@ +import {DEPLOYMENT_JSON_PATH, PLUGIN_CONTRACT_NAME} from '../plugin-settings'; import {isLocal} from '../utils/helpers'; import { getLatestNetworkDeployment, @@ -45,3 +46,34 @@ export async function forkNetwork( ], }); } + +export function savePluginRepoAddress( + hre: HardhatRuntimeEnvironment, + pluginRepoAddress: string, + pluginRepoImplementationAddress: string, + txHash: string, + blockNumber: number | undefined +) { + // Write plugin repo address to file + const fs = require('fs'); + const outputPath = DEPLOYMENT_JSON_PATH; + + const addressInformation = { + [PLUGIN_CONTRACT_NAME + 'RepoProxy']: { + address: pluginRepoAddress, + blockNumber: blockNumber, + deploymentTx: txHash, + }, + [PLUGIN_CONTRACT_NAME + 'RepoImplementation']: { + address: pluginRepoImplementationAddress, + blockNumber: null, + deploymentTx: null, + }, + }; + + fs.writeFileSync(outputPath, JSON.stringify(addressInformation, null, 2)); + console.log(`Plugin repo addresses saved to ${outputPath}`); +} + +// hh-deploy cannot process files without default exports +export default async () => {}; diff --git a/packages/contracts/plugin-settings.ts b/packages/contracts/plugin-settings.ts index f9eaf335..75d5f684 100644 --- a/packages/contracts/plugin-settings.ts +++ b/packages/contracts/plugin-settings.ts @@ -3,12 +3,18 @@ import releaseMetadata from './src/release-metadata.json'; import {isZkSync} from './utils/zkSync'; import {VersionTag} from '@aragon/osx-commons-sdk'; import hre from 'hardhat'; +import path from 'path'; + +export const DEPLOYMENT_JSON_PATH = path.join( + __dirname, + './deployed-contracts.json' +); export const PLUGIN_CONTRACT_NAME = 'Admin'; export const PLUGIN_SETUP_CONTRACT_NAME = isZkSync(hre.network.name) ? 'AdminSetupZkSync' : 'AdminSetup'; -export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'admin'; // 'admin.plugin.dao.eth' +export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'admin5'; // 'admin.plugin.dao.eth' // Specify the version of your plugin that you are currently working on. The first version is v1.1. // For more details, visit https://devs.aragon.org/docs/osx/how-it-works/framework/plugin-management/plugin-repo. From 8a7ddfe3513a3a8025ffbd4cb20bdb490d60f008 Mon Sep 17 00:00:00 2001 From: Claudia Date: Wed, 29 Jan 2025 15:03:22 +0100 Subject: [PATCH 15/20] fix --- packages/contracts/deploy/10_create_repo/11_create_repo.ts | 1 - packages/contracts/deploy/helpers.ts | 1 - packages/contracts/plugin-settings.ts | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index efaa6972..c5f357d0 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -117,7 +117,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); savePluginRepoAddress( - hre, pluginRepo.address, await pluginRepoFactory.pluginRepoBase(), tx.hash, diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index 9849522c..51b44405 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -48,7 +48,6 @@ export async function forkNetwork( } export function savePluginRepoAddress( - hre: HardhatRuntimeEnvironment, pluginRepoAddress: string, pluginRepoImplementationAddress: string, txHash: string, diff --git a/packages/contracts/plugin-settings.ts b/packages/contracts/plugin-settings.ts index 75d5f684..4cb9adbe 100644 --- a/packages/contracts/plugin-settings.ts +++ b/packages/contracts/plugin-settings.ts @@ -14,7 +14,7 @@ export const PLUGIN_CONTRACT_NAME = 'Admin'; export const PLUGIN_SETUP_CONTRACT_NAME = isZkSync(hre.network.name) ? 'AdminSetupZkSync' : 'AdminSetup'; -export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'admin5'; // 'admin.plugin.dao.eth' +export const PLUGIN_REPO_ENS_SUBDOMAIN_NAME = 'admin'; // 'admin.plugin.dao.eth' // Specify the version of your plugin that you are currently working on. The first version is v1.1. // For more details, visit https://devs.aragon.org/docs/osx/how-it-works/framework/plugin-management/plugin-repo. From 66d4d4200d88f90db1166deacc7bdeaeea1c10d0 Mon Sep 17 00:00:00 2001 From: Claudia Date: Wed, 29 Jan 2025 15:29:21 +0100 Subject: [PATCH 16/20] fix: update the function for a more generic one --- .../deploy/10_create_repo/11_create_repo.ts | 28 ++++++++--- packages/contracts/deploy/helpers.ts | 46 +++++++++++-------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index c5f357d0..66c8f379 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -1,11 +1,14 @@ -import {PLUGIN_REPO_ENS_SUBDOMAIN_NAME} from '../../plugin-settings'; +import { + PLUGIN_REPO_ENS_SUBDOMAIN_NAME, + PLUGIN_CONTRACT_NAME, +} from '../../plugin-settings'; import { findPluginRepo, getProductionNetworkName, pluginEnsDomain, isValidAddress, } from '../../utils/helpers'; -import {savePluginRepoAddress} from '../helpers'; +import {saveToDeployedJson} from '../helpers'; import { getLatestNetworkDeployment, getNetworkNameByAlias, @@ -116,11 +119,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { args: [], }); - savePluginRepoAddress( - pluginRepo.address, - await pluginRepoFactory.pluginRepoBase(), - tx.hash, - tx.blockNumber + saveToDeployedJson( + [ + { + name: PLUGIN_CONTRACT_NAME + 'PluginRepo', + address: pluginRepo.address, + blockNumber: tx.blockNumber, + txHash: tx.hash, + }, + { + name: PLUGIN_CONTRACT_NAME + 'PluginRepoImplementation', + address: await pluginRepoFactory.pluginRepoBase(), + blockNumber: null, + txHash: null, + }, + ], + true ); }; diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index 51b44405..be23fc43 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -1,4 +1,4 @@ -import {DEPLOYMENT_JSON_PATH, PLUGIN_CONTRACT_NAME} from '../plugin-settings'; +import {DEPLOYMENT_JSON_PATH} from '../plugin-settings'; import {isLocal} from '../utils/helpers'; import { getLatestNetworkDeployment, @@ -47,30 +47,38 @@ export async function forkNetwork( }); } -export function savePluginRepoAddress( - pluginRepoAddress: string, - pluginRepoImplementationAddress: string, - txHash: string, - blockNumber: number | undefined +export type AddressInfo = { + name: string; + address: string; + blockNumber: number | undefined | null; + txHash: string | undefined | null; +}; + +export function saveToDeployedJson( + addressesInfo: AddressInfo[], + newDeployment: boolean = false ) { // Write plugin repo address to file const fs = require('fs'); const outputPath = DEPLOYMENT_JSON_PATH; - const addressInformation = { - [PLUGIN_CONTRACT_NAME + 'RepoProxy']: { - address: pluginRepoAddress, - blockNumber: blockNumber, - deploymentTx: txHash, - }, - [PLUGIN_CONTRACT_NAME + 'RepoImplementation']: { - address: pluginRepoImplementationAddress, - blockNumber: null, - deploymentTx: null, - }, - }; + // Read existing JSON file + let existingData: {[key: string]: AddressInfo} = {}; + + if (fs.existsSync(outputPath) && !newDeployment) { + const fileContent = fs.readFileSync(outputPath, 'utf8'); + existingData = JSON.parse(fileContent); + } + + for (const addressInfo of addressesInfo) { + existingData[addressInfo.name] = { + address: addressInfo.address, + blockNumber: addressInfo.blockNumber, + txHash: addressInfo.txHash, + }; + } - fs.writeFileSync(outputPath, JSON.stringify(addressInformation, null, 2)); + fs.writeFileSync(outputPath, JSON.stringify(existingData, null, 2)); console.log(`Plugin repo addresses saved to ${outputPath}`); } From bb8b56f5fdff599272ad2c505e75b1db0c1d2a65 Mon Sep 17 00:00:00 2001 From: Claudia Date: Wed, 29 Jan 2025 15:30:19 +0100 Subject: [PATCH 17/20] fix --- packages/contracts/deploy/helpers.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index be23fc43..8de57073 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -58,7 +58,6 @@ export function saveToDeployedJson( addressesInfo: AddressInfo[], newDeployment: boolean = false ) { - // Write plugin repo address to file const fs = require('fs'); const outputPath = DEPLOYMENT_JSON_PATH; From 80c283f9151b97396303ea1b163c31123356feba Mon Sep 17 00:00:00 2001 From: Claudia Date: Thu, 30 Jan 2025 17:10:45 +0100 Subject: [PATCH 18/20] fix json key name --- packages/contracts/deploy/10_create_repo/11_create_repo.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contracts/deploy/10_create_repo/11_create_repo.ts b/packages/contracts/deploy/10_create_repo/11_create_repo.ts index 66c8f379..a6652449 100644 --- a/packages/contracts/deploy/10_create_repo/11_create_repo.ts +++ b/packages/contracts/deploy/10_create_repo/11_create_repo.ts @@ -111,7 +111,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { subdomainRegistrar !== ethers.constants.AddressZero ? 'with ens:' + pluginEnsDomain(hre) : 'without ens' - } deployed at '${pluginRepo.address}'.` + } deployed at '${pluginRepo.address}'.` ); hre.aragonToVerifyContracts.push({ @@ -122,13 +122,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { saveToDeployedJson( [ { - name: PLUGIN_CONTRACT_NAME + 'PluginRepo', + name: PLUGIN_CONTRACT_NAME + 'RepoProxy', address: pluginRepo.address, blockNumber: tx.blockNumber, txHash: tx.hash, }, { - name: PLUGIN_CONTRACT_NAME + 'PluginRepoImplementation', + name: PLUGIN_CONTRACT_NAME + 'RepoImplementation', address: await pluginRepoFactory.pluginRepoBase(), blockNumber: null, txHash: null, From c70fad6725579635493834c7ae447fe1b868a083 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 31 Jan 2025 13:43:01 +0100 Subject: [PATCH 19/20] feat: add flow to provide the management dao address via env var --- .../40_conclude/41_transfer_ownership.ts | 2 +- packages/contracts/utils/helpers.ts | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/contracts/deploy/40_conclude/41_transfer_ownership.ts b/packages/contracts/deploy/40_conclude/41_transfer_ownership.ts index aac32467..935fb83a 100644 --- a/packages/contracts/deploy/40_conclude/41_transfer_ownership.ts +++ b/packages/contracts/deploy/40_conclude/41_transfer_ownership.ts @@ -30,7 +30,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ); const permissions: DAOStructs.MultiTargetPermissionStruct[] = [ - // Grant to the managment DAO + // Grant to the management DAO { operation: Operation.Grant, where: pluginRepo.address, diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index ff4ad649..ef12be48 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -128,6 +128,8 @@ export async function findPluginRepo( if (subdomainRegistrarAddress === ethers.constants.AddressZero) { // the network does not support ENS + + // todo if the network does not support ENS, should try to get the plugin repo from the deployments return {pluginRepo: null, ensDomain: ''}; } @@ -165,6 +167,21 @@ export async function getManagementDao( hre: HardhatRuntimeEnvironment ): Promise { const [deployer] = await hre.ethers.getSigners(); + + const managementDaoAddress = process.env.MANAGEMENT_DAO_ADDRESS; + + if (managementDaoAddress) { + // getting the management DAO from the env var + if (!isValidAddress(managementDaoAddress)) { + throw new Error( + 'Management DAO address in .env is not valid address (is not an address or is address zero)' + ); + } + + return DAO__factory.connect(managementDaoAddress, deployer); + } + + // getting the management DAO from the deployments in common configs const productionNetworkName = getProductionNetworkName(hre); const network = getNetworkNameByAlias(productionNetworkName); if (network === null) { @@ -175,6 +192,11 @@ export async function getManagementDao( throw `Deployments are not available on network ${network}.`; } + console.log( + 'NOT ENV VAR MANAGEMENT DAO ADDRESS', + networkDeployments.ManagementDAOProxy.address + ); + return DAO__factory.connect( networkDeployments.ManagementDAOProxy.address, deployer From 899e4a28ce68156aa6ee553a1814d1a99147d0ef Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 31 Jan 2025 13:45:23 +0100 Subject: [PATCH 20/20] fix: remove not needed log --- packages/contracts/utils/helpers.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/contracts/utils/helpers.ts b/packages/contracts/utils/helpers.ts index ef12be48..874b6265 100644 --- a/packages/contracts/utils/helpers.ts +++ b/packages/contracts/utils/helpers.ts @@ -192,11 +192,6 @@ export async function getManagementDao( throw `Deployments are not available on network ${network}.`; } - console.log( - 'NOT ENV VAR MANAGEMENT DAO ADDRESS', - networkDeployments.ManagementDAOProxy.address - ); - return DAO__factory.connect( networkDeployments.ManagementDAOProxy.address, deployer