Skip to content

Commit

Permalink
feat: adds proposeUpgradeWithApproval
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoFerraz committed Nov 27, 2023
1 parent 6fad6b6 commit f71d6ce
Show file tree
Hide file tree
Showing 12 changed files with 827 additions and 1,442 deletions.
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/VioletID.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ error BatchSetStatusArrayMismatch();
* - Upgradeable
* - Ethereum Access Token compatible
*/
contract VioletID is
contract VioletIDv1_4_0 is

Check warning on line 26 in contracts/VioletID.sol

View workflow job for this annotation

GitHub Actions / ci

Contract name must be in CamelCase
Initializable,
AccessControlUpgradeable,
PausableUpgradeable,
Expand Down
9 changes: 7 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@nomicfoundation/hardhat-ledger";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-etherscan";
import "@nomicfoundation/hardhat-verify";
import "@openzeppelin/hardhat-upgrades";
import { config as dotenvConfig } from "dotenv";
import * as ethers from "ethers";
Expand Down Expand Up @@ -90,6 +90,11 @@ const config: HardhatUserConfig = {
excludeContracts: [],
src: "./contracts",
},
defender: {
apiKey: process.env.DEFENDER_API_KEY || "",
apiSecret: process.env.DEFENDER_API_SECRET || "",
useDefenderDeploy: true,
},
etherscan: {
apiKey: {
arbitrumOne: process.env.ARBISCAN_API_KEY || "",
Expand Down Expand Up @@ -120,7 +125,7 @@ const config: HardhatUserConfig = {
optimism: getChainConfig("optimism-mainnet"),
optimismGoerli: {
...getChainConfig("optimism-goerli"),
gasPrice: ethers.utils.parseUnits("2", "gwei").toNumber(),
gasPrice: Number(ethers.parseUnits("2", "gwei")),
},
polygon: getChainConfig("polygon-mainnet"),
polygonMumbai: getChainConfig("polygon-mumbai"),
Expand Down
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,34 @@
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-ledger": "^1.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@openzeppelin/hardhat-upgrades": "^1.28.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-ledger": "^1.0.1",
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.1",
"@openzeppelin/hardhat-upgrades": "^2.4.1",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@typechain/ethers-v5": "^10.2.1",
"@typechain/hardhat": "^6.1.6",
"@types/chai": "^4.3.4",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.11",
"@types/fs-extra": "^9.0.13",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"@violetprotocol/ethereum-access-token-helpers": "^0.2.0",
"chai": "^4.3.7",
"chai": "^4.3.10",
"commitizen": "^4.2.5",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.0.3",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^5.7.2",
"ethers": "^6.8.1",
"fs-extra": "^10.1.0",
"hardhat": "^2.17.1",
"hardhat": "^2.19.1",
"hardhat-dependency-compiler": "^1.1.3",
"hardhat-gas-reporter": "^1.0.9",
"husky": "^8.0.2",
Expand All @@ -53,11 +54,11 @@
"shx": "^0.3.4",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.8.3",
"solidity-coverage": "^0.8.5",
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1",
"typechain": "^8.3.1",
"typescript": "^4.9.3"
"typechain": "^8.3.2",
"typescript": "^5.3.2"
},
"files": [
"contracts",
Expand Down Expand Up @@ -89,7 +90,7 @@
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
"postinstall": "husky install && DOTENV_CONFIG_PATH=./.env.example yarn typechain",
"postinstall": "DOTENV_CONFIG_PATH=./.env.example yarn typechain",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable",
"prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yml}\"",
Expand Down
19 changes: 19 additions & 0 deletions tasks/deploy/proposeUpgradeWithApproval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

task("proposeUpgradeWithApproval").setAction(async function (_taskArguments: TaskArguments, { ethers, defender, artifacts }) {
const newVIDContract = await ethers.getContractFactoryFromArtifact(await artifacts.readArtifact("VioletIDv1_4_0"));
try {
const response = await defender.proposeUpgradeWithApproval(
// Sepolia previous VID contract
"0xE62C5A18Fb0e5f9b01bE9fAc679040e142e0e1FC",
newVIDContract,
);
console.log(response);
} catch (error) {
console.log(error);
}
console.log("Task complete ✅");
});

export default {};
Empty file added tasks/deploy/upgrade.ts
Empty file.
19 changes: 19 additions & 0 deletions tasks/deploy/validate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

task("validateUpgrade")
.addParam("referenceAddress", "Address of the original VioletID")
.setAction(async function (_taskArguments: TaskArguments, { ethers, upgrades }) {
const newVIDContract = await ethers.getContractFactory("VioletIDv1_4_0");
try {
const response = await upgrades.validateUpgrade(_taskArguments.referenceAddress, newVIDContract, {
kind: "uups",
});
console.log(response);
} catch (error) {
console.log(error);
}
console.log("Task complete ✅");
});

export default {};
21 changes: 21 additions & 0 deletions tasks/deploy/validateUpgradeSafety.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { validateUpgradeSafety } from "@openzeppelin/upgrades-core";
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

task("validateUpgradeSafety")
.addParam("referenceName", "Address of the original VioletID")
.setAction(async function (_taskArguments: TaskArguments) {
try {
const response = await validateUpgradeSafety(
"artifacts/build-info",
"VioletIDv1_4_0",
_taskArguments.referenceName,
);
console.log(JSON.stringify(response));
} catch (error) {
console.log(error);
}
console.log("Task complete ✅");
});

export default {};
13 changes: 12 additions & 1 deletion tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import accounts from "./accounts";
import proposeUpgradeWithApproval from "./deploy/proposeUpgradeWithApproval";
import validate from "./deploy/validate";
import validateUpgradeSafety from "./deploy/validateUpgradeSafety";
import deployVioletID from "./deploy/violetID";
import grantRole from "./grantRole";
import renounceRole from "./renounceRole";

export { accounts, deployVioletID, grantRole, renounceRole };
export {
accounts,
deployVioletID,
grantRole,
renounceRole,
validate,
validateUpgradeSafety,
proposeUpgradeWithApproval,
};
Loading

0 comments on commit f71d6ce

Please sign in to comment.