Skip to content

Commit

Permalink
Feat: Deployment tasks (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrzn committed Sep 1, 2021
1 parent 89b95ac commit 65007e4
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules/
env/
.env
.history
coverage*
coverage*
deployments
2 changes: 1 addition & 1 deletion docs/setup_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ There are different services available for this such as the [OpenZepplin Defende

### Deploy a master copy

If the contract get an update, you can deploy a new version of a Master Copy using the hardhat task `deployMasterCopy`. An example of the command would be: `yarn hardhat --network rinkeby deployMasterCopy`
The master copy contracts can be deployed through `yarn deploy` command. Note that this only should be done if the DaoModule contracts gets an update and the ones referred on the (zodiac repository)[https://github.com/gnosis/zodiac/blob/master/src/factory/constants.ts] should be used.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"build": "hardhat compile",
"test": "hardhat test",
"deploy": "hardhat deploy --network",
"coverage": "hardhat coverage",
"lint": "yarn lint:sol && yarn lint:ts",
"lint:sol": "solhint 'contracts/**/*.sol'",
Expand Down
28 changes: 28 additions & 0 deletions src/deploy/deploy_modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const FIRST_ADDRESS = "0x0000000000000000000000000000000000000001";

const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();
const { deploy } = deployments;
const args = [FIRST_ADDRESS, FIRST_ADDRESS, FIRST_ADDRESS, 1, 0, 60, 0, 0];

await deploy("DaoModuleERC20", {
from: deployer,
args,
log: true,
deterministicDeployment: true,
});

await deploy("DaoModuleETH", {
from: deployer,
args,
log: true,
deterministicDeployment: true,
});
};

deploy.tags = ["dao-module"];
export default deploy;
32 changes: 32 additions & 0 deletions src/deploy/verify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { TASK_ETHERSCAN_VERIFY } from "hardhat-deploy";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { run } = hre;
if (!["rinkeby", "mainnet"].includes(hre.network.name)) {
return;
}

if (!process.env.INFURA_KEY) {
console.log(
`Could not find Infura key in env, unable to connect to network ${hre.network.name}`
);
return;
}

console.log("Verification of DAO Modules in etherscan...");
console.log("Waiting for 1 minute before verifying contracts...");
// Etherscan needs some time to process before trying to verify.
await new Promise((resolve) => setTimeout(resolve, 60000));

console.log("Starting to verify now");

await run(TASK_ETHERSCAN_VERIFY, {
apiKey: process.env.ETHERSCAN_KEY_API,
license: "GPL-3.0",
solcInput: true,
forceLicense: true, // we need this because contracts license is LGPL-3.0-only
});
};
export default func;
17 changes: 0 additions & 17 deletions src/tasks/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,4 @@ task("createDaoTemplate", "Creates a question template on the oracle address")
console.log("Template id:", id);
});

task("deployMasterCopy", "deploy a master copy of DAO Module").setAction(
async (_, hardhatRuntime) => {
const [caller] = await hardhatRuntime.ethers.getSigners();
console.log("Using the account:", caller.address);
const Module = await hardhatRuntime.ethers.getContractFactory("DaoModule");
const module = await Module.deploy(FIRST_ADDRESS, FIRST_ADDRESS, ZERO_ADDRESS, 1, 0, 60, 0, 0);

await module.deployTransaction.wait(3);

console.log("Module deployed to:", module.address);
await hardhatRuntime.run("verify:verify", {
address: module.address,
constructorArguments: [FIRST_ADDRESS, FIRST_ADDRESS, ZERO_ADDRESS, 1, 0, 60, 0, 0],
});
}
);

export { };

0 comments on commit 65007e4

Please sign in to comment.