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

Feat: get deploymet needed addresses from env vars #42

Merged
merged 15 commits into from
Feb 18, 2025
Merged
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
18 changes: 14 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GENERAL

## The network used for testing purposes
NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "baseMainnet", "arbitrum"]
NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon"]

## To upload the metadata for deployed contracts
PUB_PINATA_JWT=
Expand All @@ -24,12 +24,22 @@ POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASESCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# SUBGRAPH
## Deployment addresses
# Note that addresses will be also used for testing so ensure they are valid on the network you are running the forking tests on.

## The Graph credentials
GRAPH_KEY="zzzzzzzzzzzz"
# optional, address if not provided will get it from the latest deployment on the network or from the ens registrar
# defined in the framework if it supports it. In case it is not found will create a new one.
PLUGIN_REPO_ADDRESS=0x0000000000000000000000000000000000000000
# not optional, if not provided will not be able to deploy the plugin or run the forking tests.
PLUGIN_REPO_FACTORY_ADDRESS=0x0000000000000000000000000000000000000000
# optional, only needed when a latest versions of the plugin are going to be deploy on a new network.
PLACEHOLDER_SETUP=0x0000000000000000000000000000000000000000
# not optional, if not provided will not be able to transfer the ownership of the plugin when deploying
# the plugin or running the forking tests.
MANAGEMENT_DAO_ADDRESS=0x0000000000000000000000000000000000000000

## Subgraph
GRAPH_KEY="zzzzzzzzzzzz"
SUBGRAPH_NAME="osx"
SUBGRAPH_VERSION="v1.0.0"
SUBGRAPH_NETWORK_NAME="mainnet" # ["mainnet", "sepolia", "polygon", "base", "arbitrum"]
2 changes: 2 additions & 0 deletions .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ jobs:
run: 'yarn coverage'
env:
NETWORK_NAME: ${{ vars.NETWORK_NAME }}
PLUGIN_REPO_FACTORY_ADDRESS: ${{ vars.PLUGIN_REPO_FACTORY_ADDRESS }}
MANAGEMENT_DAO_ADDRESS: ${{ vars.MANAGEMENT_DAO_ADDRESS }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
64 changes: 30 additions & 34 deletions packages/contracts/deploy/10_create_repo/11_create_repo.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import {PLUGIN_REPO_ENS_SUBDOMAIN_NAME} from '../../plugin-settings';
import {
PLUGIN_REPO_ENS_SUBDOMAIN_NAME,
PLUGIN_REPO_PROXY_NAME,
} from '../../plugin-settings';
import {
findPluginRepo,
getProductionNetworkName,
pluginEnsDomain,
getPluginRepoFactory,
frameworkSupportsENS,
} from '../../utils/helpers';
import {
getLatestNetworkDeployment,
getNetworkNameByAlias,
} from '@aragon/osx-commons-configs';
import {
UnsupportedNetworkError,
findEventTopicLog,
} from '@aragon/osx-commons-sdk';
import {findEventTopicLog} from '@aragon/osx-commons-sdk';
import {
PluginRepoRegistryEvents,
PluginRepoRegistry__factory,
PluginRepo__factory,
PluginRepoFactory__factory,
} from '@aragon/osx-ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand All @@ -27,32 +24,21 @@ import path from 'path';
* @param {HardhatRuntimeEnvironment} hre
*/
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(
`Creating the '${pluginEnsDomain(
hre
)}' plugin repo through Aragon's 'PluginRepoFactory'...`
);
console.log(`Creating plugin repo through Aragon's 'PluginRepoFactory'...`);

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}.`;
}
const pluginRepoFactory = PluginRepoFactory__factory.connect(
networkDeployments.PluginRepoFactory.address,
deployer
);
// Get the Aragon `PluginRepoFactory`
const pluginRepoFactory = await getPluginRepoFactory(hre);

// if the framework supports ENS, use the subdomain from the `./plugin-settings.ts` file
// otherwise, use an empty string
const supportsENS = await frameworkSupportsENS(pluginRepoFactory);
const subdomain = supportsENS ? PLUGIN_REPO_ENS_SUBDOMAIN_NAME : '';

// Create the `PluginRepo` through the Aragon `PluginRepoFactory`
const tx = await pluginRepoFactory.createPluginRepo(
PLUGIN_REPO_ENS_SUBDOMAIN_NAME,
subdomain,
deployer.address
);

Expand All @@ -69,8 +55,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
deployer
);

// Save the plugin repo deployment
await hre.deployments.save(PLUGIN_REPO_PROXY_NAME, {
abi: PluginRepo__factory.abi,
address: pluginRepo.address,
receipt: await tx.wait(),
transactionHash: tx.hash,
});

console.log(
`PluginRepo '${pluginEnsDomain(hre)}' deployed at '${pluginRepo.address}'.`
`PluginRepo ${
supportsENS ? 'with ens:' + pluginEnsDomain(hre) : 'without ens'
} deployed at '${pluginRepo.address}'.`
);

hre.aragonToVerifyContracts.push({
Expand All @@ -90,11 +86,11 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => {
console.log(`\n🏗️ ${path.basename(__filename)}:`);

// Check if the ens record exists already
const {pluginRepo, ensDomain} = await findPluginRepo(hre);
const {pluginRepo} = await findPluginRepo(hre);

if (pluginRepo !== null) {
console.log(
`ENS name '${ensDomain}' was claimed already at '${
`Plugin Repo already deployed at '${
pluginRepo.address
}' on network '${getProductionNetworkName(hre)}'. Skipping deployment...`
);
Expand All @@ -106,7 +102,7 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => {

return true;
} else {
console.log(`ENS name '${ensDomain}' is unclaimed. Deploying...`);
console.log('Deploying Plugin Repo');

return false;
}
Expand Down
19 changes: 12 additions & 7 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
impersonatedManagementDaoSigner,
isLocal,
pluginEnsDomain,
isValidAddress,
} from '../../utils/helpers';
import {getLatestContractAddress} from '../helpers';
import {PLUGIN_REPO_PERMISSIONS, uploadToPinata} from '@aragon/osx-commons-sdk';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {writeFile} from 'fs/promises';
Expand Down Expand Up @@ -146,13 +146,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
[]
)
) {
const placeholderSetup = getLatestContractAddress('PlaceholderSetup', hre);
if (placeholderSetup == '' && !isLocal(hre)) {
throw new Error(
'Aborting. Placeholder setup not present in this network'
);
}
if (latestBuild == 0 && VERSION.build > 1) {
// We are publishing the first version as build > 1.
// So we need to publish placeholders first..
const placeholderSetup = process.env.PLACEHOLDER_SETUP;

if (!placeholderSetup || !isValidAddress(placeholderSetup)) {
throw new Error(
'Aborting. Placeholder setup not defined 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++) {
console.log('Publishing placeholder', i + 1);
await createVersion(
Expand All @@ -166,6 +170,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}
}

// create the new version
await createVersion(
pluginRepo,
VERSION.release,
Expand Down
17 changes: 8 additions & 9 deletions packages/contracts/deploy/30_upgrade_repo/_common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {findPluginRepo, getProductionNetworkName} from '../../utils/helpers';
import {
getLatestNetworkDeployment,
getNetworkNameByAlias,
} from '@aragon/osx-commons-configs';
findPluginRepo,
getProductionNetworkName,
getPluginRepoFactory,
} from '../../utils/helpers';
import {getNetworkNameByAlias} from '@aragon/osx-commons-configs';
import {UnsupportedNetworkError} from '@aragon/osx-commons-sdk';
import {PluginRepo, PluginRepo__factory} from '@aragon/osx-ethers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
Expand Down Expand Up @@ -30,10 +31,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,8 +43,10 @@ export async function fetchData(
);

// Get the latest `PluginRepo` implementation as the upgrade target
const pluginRepoFactory = await getPluginRepoFactory(hre);

const latestPluginRepoImplementation = PluginRepo__factory.connect(
networkDeployments.PluginRepoBase.address,
await pluginRepoFactory.pluginRepoBase(),
deployer
);

Expand Down
31 changes: 0 additions & 31 deletions packages/contracts/deploy/helpers.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/contracts/plugin-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {isZkSync} from './utils/zkSync';
import {VersionTag} from '@aragon/osx-commons-sdk';
import hre from 'hardhat';

export const PLUGIN_REPO_PROXY_NAME = 'AdminRepoProxy';
export const PLUGIN_CONTRACT_NAME = 'Admin';
export const PLUGIN_SETUP_CONTRACT_NAME = isZkSync(hre.network.name)
? 'AdminSetupZkSync'
Expand Down
Loading
Loading