Skip to content

Commit

Permalink
store detailed deployed contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekard0 committed Nov 21, 2024
1 parent 8fe579e commit 3e94c4a
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ yarn-error.log*
deployments
deployments-zk
deployed_contracts.json
deployed_contracts_detailed.json
managingDAOTX.json

# generated
Expand Down
47 changes: 26 additions & 21 deletions packages/contracts/deploy/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const ENS_PUBLIC_RESOLVERS: {[key: string]: string} = {
goerli: '0x19c2d5d0f035563344dbb7be5fd09c8dad62b001',
mainnet: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41',
sepolia: '0x8FADE66B79cC9f707aB26799354482EB93a5B7dD',
holesky: '0x9010A27463717360cAD99CEA8bD39b8705CCA238'
holesky: '0x9010A27463717360cAD99CEA8bD39b8705CCA238',
};

export const DAO_PERMISSIONS = [
Expand Down Expand Up @@ -224,7 +224,11 @@ export async function createPluginRepo(
);
const found = events.filter(event => event?.args?.subdomain == pluginName);
if (found && found.length == 1) {
hre.aragonPluginRepos[pluginName] = found[0].args.pluginRepo;
hre.aragonPluginRepos[pluginName] = {
address: found[0].args.pluginRepo,
blockNumber: found[0].blockNumber,
transactionHash: found[0].transactionHash || null,
};
return;
}
throw new Error(
Expand All @@ -247,7 +251,8 @@ export async function createPluginRepo(
console.log(
`Creating & registering repo for ${pluginName} with tx ${tx.hash}`
);
await tx.wait();

const receipt = await tx.wait();

const event = await findEventTopicLog<PluginRepoRegisteredEvent>(
tx,
Expand All @@ -256,7 +261,11 @@ export async function createPluginRepo(
);
const repoAddress = event.args.pluginRepo;

hre.aragonPluginRepos[pluginName] = repoAddress;
hre.aragonPluginRepos[pluginName] = {
address: repoAddress,
blockNumber: receipt.blockNumber,
transactionHash: tx.hash,
};

console.log(
`Created & registered repo for ${pluginName} at address: ${repoAddress}` //, with contentURI ${ethers.utils.toUtf8String(releaseMetadata)}`
Expand Down Expand Up @@ -363,7 +372,7 @@ export async function populatePluginRepo(

for (let i = 1; i < latestBuildNumber; i++) {
await createVersion(
hre.aragonPluginRepos[pluginRepoName],
hre.aragonPluginRepos[pluginRepoName].address,
placeholderSetup,
releaseNumber,
i,
Expand All @@ -376,7 +385,7 @@ export async function populatePluginRepo(

// create latest builds
await createVersion(
hre.aragonPluginRepos[pluginRepoName],
hre.aragonPluginRepos[pluginRepoName].address,
latestVersion.pluginSetupContract,
releaseNumber,
latestBuildNumber,
Expand Down Expand Up @@ -653,29 +662,25 @@ export function getManagingDAOMultisigAddress(
}

export async function getPSPAddress(hre: HardhatRuntimeEnvironment) {
let name = 'PluginSetupProcessor'
if(ZK_SYNC_NETWORKS.includes(hre.network.name)) {
name = 'PluginSetupProcessorUpgradeable'
let name = 'PluginSetupProcessor';
if (ZK_SYNC_NETWORKS.includes(hre.network.name)) {
name = 'PluginSetupProcessorUpgradeable';
}

const address = await getContractAddress(
name,
hre
);
const address = await getContractAddress(name, hre);

return address;
}

export async function getTokenVotingSetupAddress(hre: HardhatRuntimeEnvironment) {
let name = 'TokenVotingSetup'
if(ZK_SYNC_NETWORKS.includes(hre.network.name)) {
name = 'TokenVotingSetupZkSync'
export async function getTokenVotingSetupAddress(
hre: HardhatRuntimeEnvironment
) {
let name = 'TokenVotingSetup';
if (ZK_SYNC_NETWORKS.includes(hre.network.name)) {
name = 'TokenVotingSetupZkSync';
}

const address = await getContractAddress(
name,
hre
);
const address = await getContractAddress(name, hre);

return address;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/deploy/new/10_framework/00_ens_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const {network} = hre;

console.log(`\nOn Network: `, network.name);

// Prepare ENS.
const daoDomain =
process.env[`${network.name.toUpperCase()}_DAO_ENS_DOMAIN`] || '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const pluginRepoBase = await pluginRepoFactory.pluginRepoBase();

hre.aragonToVerifyContracts.push({
address: hre.aragonPluginRepos['address-list-voting'],
address: hre.aragonPluginRepos['address-list-voting'].address,
args: [pluginRepoBase, initializeData],
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const pluginRepoBase = await pluginRepoFactory.pluginRepoBase();

hre.aragonToVerifyContracts.push({
address: hre.aragonPluginRepos['token-voting'],
address: hre.aragonPluginRepos['token-voting'].address,
args: [pluginRepoBase, initializeData],
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const pluginRepoBase = await pluginRepoFactory.pluginRepoBase();

hre.aragonToVerifyContracts.push({
address: hre.aragonPluginRepos['admin'],
address: hre.aragonPluginRepos['admin'].address,
args: [pluginRepoBase, initializeData],
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const pluginRepoBase = await pluginRepoFactory.pluginRepoBase();

hre.aragonToVerifyContracts.push({
address: hre.aragonPluginRepos['multisig'],
address: hre.aragonPluginRepos['multisig'].address,
args: [pluginRepoBase, initializeData],
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {DAO__factory, PluginRepo__factory} from '../../../typechain';
import {Operation} from '../../../utils/types';
import {getContractAddress, getPSPAddress, managePermissions, Permission} from '../../helpers';
import {
getContractAddress,
getPSPAddress,
managePermissions,
Permission,
} from '../../helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

Expand Down Expand Up @@ -60,7 +65,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Grant `ROOT_PERMISSION`, `MAINTAINER_PERMISSION` and `UPGRADE_REPO_PERMISSION` to `managingDao` on the permission manager of each PluginRepo.
for (const repoName in hre.aragonPluginRepos) {
const repoAddress = hre.aragonPluginRepos[repoName];
const repoAddress = hre.aragonPluginRepos[repoName].address;

// if repoAddress empty, the deployment must have been marked as skipped.
if (repoAddress === '') continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
'0x'
);

console.log(`\nShould set metadata of ManagementDAO:`, hasMetadataPermission);

if (hasMetadataPermission) {
const setMetadataTX = await managingDaoContract.setMetadata(
ethers.utils.hexlify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import {findEvent} from '../../../utils/event';
import {getNamedTypesFromMetadata} from '../../../utils/metadata';
import {hashHelpers} from '../../../utils/psp';
import {Operation} from '../../../utils/types';
import {checkPermission, getContractAddress, getPSPAddress} from '../../helpers';
import {
checkPermission,
getContractAddress,
getPSPAddress,
} from '../../helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`\nInstall Multisig plugin on the ManagementDAO.`);

const {ethers, network} = hre;
const [deployer] = await ethers.getSigners();

Expand Down Expand Up @@ -55,7 +61,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);

// Get `PluginSetupProcessor` address.
const pspAddress = await getPSPAddress(hre)
const pspAddress = await getPSPAddress(hre);

// Get `PluginSetupProcessor` contract.
const pspContract = PluginSetupProcessor__factory.connect(
Expand All @@ -64,7 +70,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);

// Install multisig build 2
const multisigRepoAddress = hre.aragonPluginRepos['multisig'];
const multisigRepoAddress = hre.aragonPluginRepos['multisig'].address;
const versionTag = {
release: 1,
build: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Revoke `ROOT_PERMISSION`, `MAINTAINER_PERMISSION` and `UPGRADE_REPO_PERMISSION` from `Deployer` on the permission manager of each PluginRepo.
for (const repoName in hre.aragonPluginRepos) {
const repoAddress = hre.aragonPluginRepos[repoName];
const repoAddress = hre.aragonPluginRepos[repoName].address;

// if repoAddress empty, the deployment must have been marked as skipped.
if (repoAddress === '') continue;
Expand Down
7 changes: 3 additions & 4 deletions packages/contracts/deploy/new/50_save-contract-addresses.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {promises as fs} from 'fs';
import { DAORegistry } from '../../typechain';
import {DAORegistry} from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nPrinting deployed contracts.');
Expand Down Expand Up @@ -38,15 +38,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

for (const pluginRepo in aragonPluginRepos) {
deployedContractAddresses[`${pluginRepo}-repo`] =
aragonPluginRepos[pluginRepo];
console.log(`${pluginRepo}-repo: ${aragonPluginRepos[pluginRepo]}`);
aragonPluginRepos[pluginRepo].address;
console.log(`${pluginRepo}-repo: ${aragonPluginRepos[pluginRepo].address}`);
}

await fs.writeFile(
'deployed_contracts.json',
JSON.stringify(deployedContractAddresses, null, 2)
);

};
export default func;
func.tags = ['New', 'Conclude'];
Expand Down
83 changes: 83 additions & 0 deletions packages/contracts/deploy/new/51_save-contract-addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {promises as fs} from 'fs';
import {DAOFactory} from '../../typechain';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('\nPrinting deployed contracts.');
const {deployments, aragonPluginRepos, ethers} = hre;

const deployedContracts = await deployments.all();
const deployedContractDetails: {[index: string]: any} = {};

for (const deploymentName in deployedContracts) {
// Skip proxies because they are included twice
if (!deploymentName.endsWith('_Proxy')) {
const deployment = deployedContracts[deploymentName];
const {address, transactionHash, receipt} = deployment;

const contractDetails = {
address,
blockNumber: receipt?.blockNumber || null,
deploymentTx: transactionHash || null,
};

switch (deploymentName) {
case 'DAO':
deployedContractDetails['managingDAO'] = contractDetails;
console.log(`Managing DAO: ${JSON.stringify(contractDetails)}`);
break;
case 'DAO_Implementation':
deployedContractDetails['managingDAOImplementation'] =
contractDetails;
console.log(
`Managing DAO Implementation: ${JSON.stringify(contractDetails)}`
);
break;
case 'DAOFactory':
deployedContractDetails[deploymentName] = contractDetails;
console.log(`${deploymentName}: ${JSON.stringify(contractDetails)}`);

// Call DAOFactory to get daoBase() address
const daoFactory = (await ethers.getContractAt(
'DAOFactory',
address
)) as DAOFactory;
const daoBaseAddress = await daoFactory.daoBase();

deployedContractDetails['DAOBase'] = {
address: daoBaseAddress,
blockNumber: contractDetails.blockNumber,
deploymentTx: contractDetails.deploymentTx,
};
console.log(`DAOBase: ${daoBaseAddress}`);
break;
default:
deployedContractDetails[deploymentName] = contractDetails;
console.log(`${deploymentName}: ${JSON.stringify(contractDetails)}`);
}
}
}

for (const pluginRepo in aragonPluginRepos) {
deployedContractDetails[`${pluginRepo}-repo`] = {
address: aragonPluginRepos[pluginRepo].address,
blockNumber: aragonPluginRepos[pluginRepo].blockNumber,
deploymentTx: aragonPluginRepos[pluginRepo].transactionHash,
};
console.log(
`${pluginRepo}-repo: ${JSON.stringify(
deployedContractDetails[`${pluginRepo}-repo`]
)}`
);
}

await fs.writeFile(
'deployed_contracts_detailed.json',
JSON.stringify(deployedContractDetails, null, 2)
);
};

export default func;
func.tags = ['New', 'Conclude'];
func.runAtTheEnd = true;
2 changes: 1 addition & 1 deletion packages/contracts/test/core/dao/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ describe('DAO', function () {
});

// TODO:GIORGI skip this since the test focuses on gas costs which is different on zksync.
it('reverts if failure is allowed but not enough gas is provided (one action)', async () => {
it.only('reverts if failure is allowed but not enough gas is provided (one action)', async () => {
const gasConsumer = await hre.wrapper.deploy('GasConsumer');
const GasConsumer = new GasConsumer__factory(signers[0]);

Expand Down
Loading

0 comments on commit 3e94c4a

Please sign in to comment.