From d5829070419152703dea1202dea268369a0709c0 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 24 Jan 2025 12:36:10 +0100 Subject: [PATCH] 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;