Skip to content

Commit

Permalink
feat: modify the update plugin script to get the addresses from the c…
Browse files Browse the repository at this point in the history
…ommons config or the env file
  • Loading branch information
clauBv23 committed Jan 24, 2025
1 parent 382bed0 commit d582907
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions packages/contracts/deploy/30_upgrade_repo/_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit d582907

Please sign in to comment.