Skip to content

Commit

Permalink
Added Timelock contract deploy to governor deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jferas authored and apbendi committed Jul 29, 2024
1 parent 38b0e78 commit 0c705cd
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 34 deletions.
35 changes: 24 additions & 11 deletions script/DeployZkGovOpsGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import * as hre from "hardhat";
// to. The values used in the script at the time of deployment can be checked in along with the deployment artifacts
// produced by running the scripts.
const contractName = "ZkGovOpsGovernor";
const tokenAddress = "0x99E12239CBf8112fBB3f7Fd473d0558031abcbb5"; // TODO: We'll need to deploy this contract first to get the actual address
const timeLockAddress = "0x55bE1B079b53962746B2e86d12f158a41DF294A6"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 60 * 24; // Initially 1 days worth of seconds
const votingPeriod = 60 * 60 * 24 * 7; // Initially 7 days worth of seconds
const proposalThreshold = 1100; // TODO: need real values for these
const initialQuorum = 1200;
const initialLateQuorum = 60 * 60 * 24; // Initially 1 days worth of seconds
const tokenAddress = "0x0c7aA7b953217E8409D3280215293036cEd702A9"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 15; // For test purposes, 15 minutes
const votingPeriod = 60 * 15; // For test purposes, 15 minutes
const proposalThreshold = 10; // For testing purposes, actual deployment will need real values
const initialQuorum = 100; // For testing purposes, actual deployment will need real values
const initialLateQuorum = 60 * 15; // For test purposes, 15 minutes
const initialGuardian = "0xCE9e6063674DC585F6F3c7eaBe82B9936143Ba6C"; // TODO: We'll need a real address for this.. currently using a hardhat placeholder
async function main() {
dotEnvConfig();
Expand All @@ -23,11 +22,20 @@ async function main() {
throw "Please set DEPLOYER_PRIVATE_KEY in your .env file";
}

console.log("Deploying " + contractName + "...");

const zkWallet = new Wallet(deployerPrivateKey);
const deployer = new Deployer(hre, zkWallet);

// deploy timelock controller for the GovOps governor
console.log(`Deploying ${contractName} TimelockController contract...`);
const timelockContract = await deployer.loadArtifact("TimelockController");
const adminAddress = await zkWallet.getAddress();
const timelockConstructorArgs = [0, [], [], adminAddress];
const timelock = await deployer.deploy(timelockContract, timelockConstructorArgs);
const timeLockAddress = await timelock.getAddress();
console.log(`${contractName} Governor TimelockController contract was deployed to ${timeLockAddress}`);

console.log("Deploying " + contractName + "...");

const contract = await deployer.loadArtifact(contractName);
const constructorArgs = [{
name: contractName,
Expand All @@ -42,13 +50,18 @@ async function main() {
}];
const govOpsGovernor = await deployer.deploy(contract, constructorArgs);

console.log("constructor args:" + govOpsGovernor.interface.encodeDeploy(constructorArgs));

const contractAddress = await govOpsGovernor.getAddress();
console.log(`${contractName} was deployed to ${contractAddress}`);

const theToken = await govOpsGovernor.token();
console.log(`The Token is set to: ${theToken}`);

await timelock.grantRole(await timelock.PROPOSER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.CANCELLER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.EXECUTOR_ROLE(), contractAddress);
console.log(`Timelock PROPOSER, CANCELLER, and EXECUTOR roles granted to ${contractName} contract`);
await timelock.renounceRole(await timelock.TIMELOCK_ADMIN_ROLE(), adminAddress);
console.log(`ADMIN Role renounced for ${contractName} TimelockController contract (now self-administered)`);
}

main().catch((error) => {
Expand Down
37 changes: 25 additions & 12 deletions script/DeployZkProtocolGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import * as hre from "hardhat";
// to. The values used in the script at the time of deployment can be checked in along with the deployment artifacts
// produced by running the scripts.
const contractName = "ZkProtocolGovernor";
const tokenAddress = "0x99E12239CBf8112fBB3f7Fd473d0558031abcbb5"; // TODO: We'll need to deploy this contract first to get the actual address
const timeLockAddress = "0x55bE1B079b53962746B2e86d12f158a41DF294A6"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 60 * 24; // Initially 1 days worth of seconds
const votingPeriod = 60 * 60 * 24 * 7; // Initially 7 days worth of seconds
const proposalThreshold = 1100; // TODO: need real values for these
const initialQuorum = 1200;
const initialLateQuorum = 60 * 60 * 24; // Initially 1 days worth of seconds
const tokenAddress = "0x0c7aA7b953217E8409D3280215293036cEd702A9"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 15; // For test purposes, 15 minutes
const votingPeriod = 60 * 15; // For test purposes, 15 minutes
const proposalThreshold = 10; // For testing purposes, actual deployment will need real values
const initialQuorum = 100; // For testing purposes, actual deployment will need real values
const initialLateQuorum = 60 * 15; // For test purposes, 15 minutes

async function main() {
dotEnvConfig();
Expand All @@ -23,22 +22,36 @@ async function main() {
throw "Please set DEPLOYER_PRIVATE_KEY in your .env file";
}

console.log("Deploying " + contractName + "...");

const zkWallet = new Wallet(deployerPrivateKey);
const deployer = new Deployer(hre, zkWallet);

// deploy timelock controller for the protocol governor
console.log(`Deploying ${contractName} TimelockController contract...`);
const timelockContract = await deployer.loadArtifact("TimelockController");
const adminAddress = await zkWallet.getAddress();
const timelockConstructorArgs = [0, [], [], adminAddress];
const timelock = await deployer.deploy(timelockContract, timelockConstructorArgs);
const timeLockAddress = await timelock.getAddress();
console.log(`${contractName} TimelockController contract was deployed to ${timeLockAddress}`);

console.log("Deploying " + contractName + "...");

const contract = await deployer.loadArtifact(contractName);
const constructorArgs = [contractName, tokenAddress, timeLockAddress, votingDelay, votingPeriod, proposalThreshold, initialQuorum, initialLateQuorum];
const protocolGovernor = await deployer.deploy(contract, constructorArgs);

console.log("constructor args:" + protocolGovernor.interface.encodeDeploy(constructorArgs));

const contractAddress = await protocolGovernor.getAddress();
console.log(`${contractName} was deployed to ${contractAddress}`);

const theToken = await protocolGovernor.token();
console.log(`The Token is set to: ${theToken}`);
console.log(`The ${contractName} Token is set to: ${theToken}`);

await timelock.grantRole(await timelock.PROPOSER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.CANCELLER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.EXECUTOR_ROLE(), contractAddress);
console.log(`Timelock PROPOSER, CANCELLER, and EXECUTOR roles granted to ${contractName} contract`);
await timelock.renounceRole(await timelock.TIMELOCK_ADMIN_ROLE(), adminAddress);
console.log(`ADMIN Role renounced for ${contractName} TimelockController contract (now self-administered)`);
}

main().catch((error) => {
Expand Down
35 changes: 24 additions & 11 deletions script/DeployZkTokenGovernor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import * as hre from "hardhat";
// to. The values used in the script at the time of deployment can be checked in along with the deployment artifacts
// produced by running the scripts.
const contractName = "ZkTokenGovernor";
const tokenAddress = "0x99E12239CBf8112fBB3f7Fd473d0558031abcbb5"; // TODO: We'll need to deploy this contract first to get the actual address
const timeLockAddress = "0x55bE1B079b53962746B2e86d12f158a41DF294A6"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 60 * 24; // Initially 1 days worth of seconds
const votingPeriod = 60 * 60 * 24 * 7; // Initially 7 days worth of seconds
const proposalThreshold = 1100; // TODO: need real values for these
const initialQuorum = 1200;
const initialLateQuorum = 60 * 60 * 24; // Initially 1 days worth of seconds
const tokenAddress = "0x0c7aA7b953217E8409D3280215293036cEd702A9"; // TODO: We'll need to deploy this contract first to get the actual address
const votingDelay = 60 * 15; // For test purposes, 15 minutes
const votingPeriod = 60 * 15; // For test purposes, 15 minutes
const proposalThreshold = 10; // For testing purposes, actual deployment will need real values
const initialQuorum = 100; // For testing purposes, actual deployment will need real values
const initialLateQuorum = 60 * 15; // For test purposes, 15 minutes
const vetoGuardian = "0xCE9e6063674DC585F6F3c7eaBe82B9936143Ba6C"; // TODO: We'll need a real address for this.. currently using a hardhat placeholder
const proposeGuardian = "0xCE9e6063674DC585F6F3c7eaBe82B9936143Ba6C"; // TODO: We'll need a real address for this.. currently using a hardhat placeholder
const initialIsProposeGuarded = false;
Expand All @@ -25,11 +24,20 @@ async function main() {
throw "Please set DEPLOYER_PRIVATE_KEY in your .env file";
}

console.log("Deploying " + contractName + "...");

const zkWallet = new Wallet(deployerPrivateKey);
const deployer = new Deployer(hre, zkWallet);

// deploy timelock controller for the token governor
console.log(`Deploying ${contractName} TimelockController contract...`);
const timelockContract = await deployer.loadArtifact("TimelockController");
const adminAddress = await zkWallet.getAddress();
const timelockConstructorArgs = [0, [], [], adminAddress];
const timelock = await deployer.deploy(timelockContract, timelockConstructorArgs);
const timeLockAddress = await timelock.getAddress();
console.log(`${contractName} TimelockController contract was deployed to ${timeLockAddress}`);

console.log("Deploying " + contractName + "...");

const contract = await deployer.loadArtifact(contractName);
const argStruct = {
name: contractName,
Expand All @@ -47,13 +55,18 @@ async function main() {
const constructorArgs = [argStruct];
const tokenGovernor = await deployer.deploy(contract, constructorArgs);

console.log("constructor args:" + tokenGovernor.interface.encodeDeploy(constructorArgs));

const contractAddress = await tokenGovernor.getAddress();
console.log(`${contractName} was deployed to ${contractAddress}`);

const theToken = await tokenGovernor.token();
console.log(`The Token is set to: ${theToken}`);

await timelock.grantRole(await timelock.PROPOSER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.CANCELLER_ROLE(), contractAddress);
await timelock.grantRole(await timelock.EXECUTOR_ROLE(), contractAddress);
console.log(`Timelock PROPOSER, CANCELLER, and EXECUTOR roles granted to ${contractName} contract`);
await timelock.renounceRole(await timelock.TIMELOCK_ADMIN_ROLE(), adminAddress);
console.log(`ADMIN Role renounced for ${contractName} TimelockController contract (now self-administered)`);
}

main().catch((error) => {
Expand Down

0 comments on commit 0c705cd

Please sign in to comment.