Skip to content

Commit

Permalink
Merge pull request #24 from push-protocol/17-include-upgradeproxy-scr…
Browse files Browse the repository at this point in the history
…ipts

17 include upgradeproxy scripts
  • Loading branch information
zaryab2000 authored Apr 30, 2024
2 parents 40d4349 + ca684ad commit ac6b102
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 12 deletions.
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src = "contracts"
out = "out"
libs = ['node_modules',"lib"]
solc = "0.8.20"
test = 'test'

# file reading permissions
fs_permissions = [{ access = "read", path = "./addresses/addresses.json"}]
Expand Down
18 changes: 14 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module.exports = {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`, // <---- YOUR INFURA ID! (or it won't work)
accounts: [process.env.PRIVATE],
},
polygonMumbai: {
url: `https://rpc-mumbai.maticvigil.com/`, // <---- YOUR INFURA ID! (or it won't work)
polygonAmoy: {
url: `https://rpc-amoy.polygon.technology/`, // <---- YOUR INFURA ID! (or it won't work)
accounts: [process.env.PRIVATE],
},
},
Expand All @@ -46,7 +46,17 @@ module.exports = {
apiKey:{
sepolia: process.env.ETHERSCAN_API,
mainnet: process.env.ETHERSCAN_API,
polygonMumbai: process.env.POLYGONSCAN_API,
}
polygonAmoy: "OKLINK",
},
customChains:[
{
network: "polygonAmoy",
chainId: 80002,
urls: {
apiURL: "https://www.oklink.com/api/explorer/v1/contract/verify/async/api/polygon_amoy",
browserURL: "https://www.oklink.com/amoy"
}
},
]
},
};
20 changes: 12 additions & 8 deletions scripts/deployGovContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ const { fetechFutureContract } = require("./utils/fetechFutureContract");
const { prodConfig, stagingConfig } = require("./utils/gov-config");

// Select the config for Deployment Network:
const config = stagingConfig;
let config;

async function main() {
if (ethers.provider._networkName == "mainnet") {
config = prodConfig;
} else {
config = stagingConfig;
}
console.log(config);
console.log("\x1B[37mDeploying Push Governor Contracts contracts");

const [deployerSigner] = await hre.ethers.getSigners();
Expand All @@ -20,9 +26,9 @@ async function main() {
`\nsigner:\x1B[33m${deployer}\x1B[37m\n`
);

// // Load values for constructor from a ts file deploy.config.ts
const timelock_address = await fetechFutureContract(deployerSigner, 0);
const governance_address = await fetechFutureContract(deployerSigner, 1);
// Load values for constructor from a ts file deploy.config.ts
const timelock_address = await fetechFutureContract(deployerSigner, 1);
const governance_address = await fetechFutureContract(deployerSigner, 3);
const admin_address = governance_address;

const minter = deployer
Expand Down Expand Up @@ -89,8 +95,7 @@ async function deployPushTimelock(admin_address, timelock_address){
console.log("\n Contract Deployed. Copy the command below to Verify Deployed Contract 👇.....")
const verify_str_timelock = `npx hardhat verify ` +
`--network ${hre.network.name} ` +
`--contract "contracts/TimelockController.sol:TimelockController" ` +
`--constructor-args arguments/arguments_timelock_${timelockControllerAddress}.js ` +
`--contract "contracts/PushTimelockController.sol:PushTimelockController" ` +
`${timelockControllerAddress}\n`;
console.log("\n" + verify_str_timelock);

Expand Down Expand Up @@ -188,8 +193,7 @@ async function deployPushGovernor(timelock_address){
const verify_str_governor = `npx hardhat verify ` +
`--network ${hre.network.name} ` +
`--contract "contracts/PushGovernor.sol:PushGovernor" ` +
`--constructor-args arguments/arguments_governor_${governorContractAddress}.js ` +
`${governorContractAddress}\n`;
Z `${governorContractAddress}\n`;
console.log("\n" + verify_str_governor);


Expand Down
84 changes: 84 additions & 0 deletions scripts/upgradeGovContracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const fs = require("fs");
const path = require('path');
const hre = require("hardhat");
const { ethers, upgrades } = require("hardhat");

//Mention the proxy addresses here:
const timelockProxy = "0x01a088518916787cb589c19F8402c050DA7d9FE0";
const governorProxy = "0xed3D0E5517a308E079508536D8EDDFA2b2e46325";

async function main() {
console.log("\x1B[37mDeploying Push Governor Contracts contracts");

const [deployerSigner] = await hre.ethers.getSigners();
const deployer = await deployerSigner.getAddress();

console.log(
// `network:\x1B[36m${hre.network.provider}\x1B[37m`,
`\nsigner:\x1B[33m${deployer}\x1B[37m\n`
);

// Deploy - Verify - Store : TimelockController for Push Dao
await upgradePushTimelock();

// Deploy - Verify - Store : PushGovernor Contracts for Push Dao
await upgradePushGovernor();
}
// Timelock Deployer Function
async function upgradePushTimelock(){
// governor and timelock as proposers and executors to guarantee that the DAO will be able to propose and execute
console.log("\n Starting Push Timelock Contract Upgradation........... \n");

const pushTimelockController = await ethers.getContractFactory("PushTimelockControllerV2");

// Deploy the implementation contract via the OpenZeppelin upgrades plugin
const timelockController = await upgrades.upgradeProxy(
timelockProxy,pushTimelockController
);

await timelockController.waitForDeployment();
const timelockControllerAddress = await timelockController.getAddress();

// VERIFICATION - verify cli command - Use this to RUN verification command
console.log("\n Contract Upgraded. Copy the command below to Verify Deployed Contract 👇.....")
const verify_str_timelock = `npx hardhat verify ` +
`--network ${hre.network.name} ` +
`--contract "contracts/TimelockControllerV2.sol:TimelockControllerV2" ` +
`${timelockControllerAddress}\n`;
console.log("\n" + verify_str_timelock);

console.log("\n ----------- TIMELOCK Contracts Upgraded ----------- \n");
}

// Timelock Deployer Function
async function upgradePushGovernor(timelock_address){
console.log("\n Starting Push Governor Contracts Upgradation........... \n");

const pushGovernor = await ethers.getContractFactory("PushGovernorV2");

// Deploy and upgrade the contract via the OpenZeppelin upgrades plugin
const governorContract = await upgrades.upgradeProxy(
governorProxy,
pushGovernor
);

await governorContract.waitForDeployment();
const governorContractAddress = await governorContract.getAddress();

// VERIFICATION - verify cli command - Use this to RUN verification command
console.log("\n Contract Upgraded. Copy the command below to Verify Deployed Contract 👇.....")
const verify_str_governor = `npx hardhat verify ` +
`--network ${hre.network.name} ` +
`--contract "contracts/PushGovernorV2.sol:PushGovernorV2" ` +
`${governorContractAddress}\n`;
console.log("\n" + verify_str_governor);

console.log("\n ----------- PUSH Governor Contracts Upgraded ----------- \n");
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit ac6b102

Please sign in to comment.