Skip to content

Commit

Permalink
Revert "F/deploy script"
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaniza authored Mar 8, 2024
1 parent b70df43 commit 56eecc2
Show file tree
Hide file tree
Showing 17 changed files with 198 additions and 1,307 deletions.
6 changes: 1 addition & 5 deletions packages/contracts/deploy/00_info/01_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
isLocal,
} from '../../utils/helpers';
import {getNetworkByNameOrAlias} from '@aragon/osx-commons-configs';
import {UnsupportedNetworkError} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import path from 'path';
Expand All @@ -27,10 +26,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);

// Fork the network provided in the `.env` file
const networkConfig = getNetworkByNameOrAlias(productionNetworkName);
if (networkConfig === null) {
throw new UnsupportedNetworkError(productionNetworkName);
}
const networkConfig = getNetworkByNameOrAlias(productionNetworkName)!;
await hre.network.provider.request({
method: 'hardhat_reset',
params: [
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/deploy/10_create_repo/11_create_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);

console.log(
`PluginRepo '${pluginEnsDomain(hre)}' deployed at '${pluginRepo.address}'.`
`'${pluginEnsDomain(hre)}' PluginRepo deployed at: ${pluginRepo.address}.`
);

hre.aragonToVerifyContracts.push({
Expand Down
46 changes: 3 additions & 43 deletions packages/contracts/deploy/20_new_version/21_setup.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import governanceERC20Artifact from '../../artifacts/src/ERC20/governance/GovernanceERC20.sol/GovernanceERC20.json';
import governanceWrappedERC20Artifact from '../../artifacts/src/ERC20/governance/GovernanceWrappedERC20.sol/GovernanceWrappedERC20.json';
import {
GOVERNANCE_ERC20_DEPLOY_ARGS,
GOVERNANCE_WRAPPED_ERC20_DEPLOY_ARGS,
PLUGIN_SETUP_CONTRACT_NAME,
} from '../../plugin-settings';
import {
GOVERNANCE_ERC20_CONTRACT_NAME,
GOVERNANCE_WRAPPED_ERC20_CONTRACT_NAME,
} from '../../plugin-settings';
import {PLUGIN_SETUP_CONTRACT_NAME} from '../../plugin-settings';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import path from 'path';

/**
* Deploys the plugin setup contract with the plugin implementation inside.
* In the case of the token voting plugin, we also need to deploy the governance ERC20
* and the wrapped variants.
* @param {HardhatRuntimeEnvironment} hre
*/
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand All @@ -26,39 +14,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deploy} = deployments;
const {deployer} = await getNamedAccounts();

// Deploy the bases for the TokenVotingSetup
const governanceERC20DeployResult = await deploy(
GOVERNANCE_ERC20_CONTRACT_NAME,
{
contract: governanceERC20Artifact,
from: deployer,
args: GOVERNANCE_ERC20_DEPLOY_ARGS,
log: true,
}
);

const governanceWrappedERC20DeployResult = await deploy(
GOVERNANCE_WRAPPED_ERC20_CONTRACT_NAME,
{
contract: governanceWrappedERC20Artifact,
from: deployer,
args: GOVERNANCE_WRAPPED_ERC20_DEPLOY_ARGS,
log: true,
}
);

const res = await deploy(PLUGIN_SETUP_CONTRACT_NAME, {
await deploy(PLUGIN_SETUP_CONTRACT_NAME, {
from: deployer,
args: [
governanceERC20DeployResult.address,
governanceWrappedERC20DeployResult.address,
],
args: [],
log: true,
});

console.log(
`Deployed contract '${PLUGIN_SETUP_CONTRACT_NAME}' at ${res.address}.`
);
};

export default func;
Expand Down
37 changes: 5 additions & 32 deletions packages/contracts/deploy/20_new_version/22_setup_conclude.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
GOVERNANCE_ERC20_CONTRACT_NAME,
GOVERNANCE_ERC20_DEPLOY_ARGS,
GOVERNANCE_WRAPPED_ERC20_CONTRACT_NAME,
GOVERNANCE_WRAPPED_ERC20_DEPLOY_ARGS,
PLUGIN_SETUP_CONTRACT_NAME,
} from '../../plugin-settings';
import {TokenVotingSetup__factory, TokenVoting__factory} from '../../typechain';
import {PLUGIN_SETUP_CONTRACT_NAME} from '../../plugin-settings';
import {MyPluginSetup__factory, MyPlugin__factory} from '../../typechain';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import path from 'path';
Expand All @@ -23,45 +17,24 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Get the plugin setup address
const setupDeployment = await deployments.get(PLUGIN_SETUP_CONTRACT_NAME);
const setup = TokenVotingSetup__factory.connect(
const setup = MyPluginSetup__factory.connect(
setupDeployment.address,
deployer
);
// Get the plugin implementation address
const implementation = TokenVoting__factory.connect(
const implementation = MyPlugin__factory.connect(
await setup.implementation(),
deployer
);

const governanceERC20DeployResult = await deployments.get(
GOVERNANCE_ERC20_CONTRACT_NAME
);
const governanceWrappedERC20DeployResult = await deployments.get(
GOVERNANCE_WRAPPED_ERC20_CONTRACT_NAME
);

// Queue the plugin setup and implementation for verification on the block explorers
hre.aragonToVerifyContracts.push({
address: setup.address,
args: setupDeployment.args,
});

hre.aragonToVerifyContracts.push({
address: implementation.address,
args: [
governanceERC20DeployResult.address,
governanceWrappedERC20DeployResult.address,
],
});

hre.aragonToVerifyContracts.push({
address: governanceERC20DeployResult.address,
args: GOVERNANCE_ERC20_DEPLOY_ARGS,
});

hre.aragonToVerifyContracts.push({
address: governanceWrappedERC20DeployResult.address,
args: GOVERNANCE_WRAPPED_ERC20_DEPLOY_ARGS,
args: [],
});
};

Expand Down
74 changes: 15 additions & 59 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import {
METADATA,
PLUGIN_CONTRACT_NAME,
PLUGIN_REPO_ENS_SUBDOMAIN_NAME,
PLUGIN_SETUP_CONTRACT_NAME,
VERSION,
} from '../../plugin-settings';
import {
findPluginRepo,
getPastVersionCreatedEvents,
impersonatedManagementDaoSigner,
isLocal,
pluginEnsDomain,
} from '../../utils/helpers';
import {
PLUGIN_REPO_PERMISSIONS,
toHex,
uploadToIPFS,
} from '@aragon/osx-commons-sdk';
import {writeFile} from 'fs/promises';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import path from 'path';
Expand Down Expand Up @@ -81,42 +77,25 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);
}

if (setup == undefined || setup?.receipt == undefined) {
throw Error('setup deployment unavailable');
}

const isDeployerMaintainer = await pluginRepo.isGranted(
pluginRepo.address,
deployer.address,
PLUGIN_REPO_PERMISSIONS.MAINTAINER_PERMISSION_ID,
[]
);

// If this is a local deployment and the deployer doesn't have `MAINTAINER_PERMISSION_ID` permission
// we impersonate the management DAO for integration testing purposes.
const signer =
isDeployerMaintainer || !isLocal(hre)
? deployer
: await impersonatedManagementDaoSigner(hre);

// Check if the signer has the permission to maintain the plugin repo
// Create Version
if (
await pluginRepo.isGranted(
await pluginRepo.callStatic.isGranted(
pluginRepo.address,
signer.address,
deployer.address,
PLUGIN_REPO_PERMISSIONS.MAINTAINER_PERMISSION_ID,
[]
)
) {
// Create the new version
const tx = await pluginRepo
.connect(signer)
.createVersion(
VERSION.release,
setup.address,
toHex(buildMetadataURI),
toHex(releaseMetadataURI)
);
const tx = await pluginRepo.createVersion(
VERSION.release,
setup.address,
toHex(buildMetadataURI),
toHex(releaseMetadataURI)
);

if (setup == undefined || setup?.receipt == undefined) {
throw Error('setup deployment unavailable');
}

await tx.wait();

Expand All @@ -131,31 +110,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
`Published ${PLUGIN_SETUP_CONTRACT_NAME} at ${setup.address} in PluginRepo ${PLUGIN_REPO_ENS_SUBDOMAIN_NAME} at ${pluginRepo.address}.`
);
} else {
// The deployer does not have `MAINTAINER_PERMISSION_ID` permission and we are not deploying to a production network,
// so we write the data into a file for a management DAO member to create a proposal from it.
const data = {
proposalTitle: `Publish '${PLUGIN_CONTRACT_NAME}' plugin v${VERSION.release}.${VERSION.build}`,
proposalSummary: `Publishes v${VERSION.release}.${VERSION.build} of the '${PLUGIN_CONTRACT_NAME}' plugin in the '${ensDomain}' plugin repo.`,
proposalDescription: `Publishes the '${PLUGIN_SETUP_CONTRACT_NAME}' deployed at '${setup.address}'
as v${VERSION.release}.${VERSION.build} in the '${ensDomain}' plugin repo at '${pluginRepo.address}',
with release metadata '${releaseMetadataURI}' and (immutable) build metadata '${buildMetadataURI}'.`,
actions: [
{
to: pluginRepo.address,
createVersion: {
_release: VERSION.release,
_pluginSetup: setup.address,
_buildMetadata: toHex(buildMetadataURI),
_releaseMetadata: toHex(releaseMetadataURI),
},
},
],
};

const path = `./createVersionProposalData-${hre.network.name}.json`;
await writeFile(path, JSON.stringify(data, null, 2));
console.log(
`Saved data to '${path}'. Use this to create a proposal on the managing DAO calling the 'createVersion' function on the ${ensDomain} plugin repo deployed at ${pluginRepo.address}.`
throw Error(
`The new version cannot be published because the deployer ('${deployer.address}') is lacking the ${PLUGIN_REPO_PERMISSIONS.MAINTAINER_PERMISSION_ID} permission on repo (${pluginRepo.address}).`
);
}
};
Expand Down
Loading

0 comments on commit 56eecc2

Please sign in to comment.