Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
auryn-macmillan committed Jul 16, 2024
1 parent 649adef commit a385524
Show file tree
Hide file tree
Showing 8 changed files with 1,700 additions and 1,234 deletions.
4 changes: 2 additions & 2 deletions contracts/MyModule.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.9;
pragma solidity >=0.7.0 <0.9.0;

import "@gnosis.pm/zodiac/contracts/core/Module.sol";

Expand All @@ -14,7 +14,7 @@ contract MyModule is Module {
/// @dev Initialize function, will be triggered when a new proxy is deployed
/// @param initializeParams Parameters of initialization encoded
function setUp(bytes memory initializeParams) public override initializer {
__Ownable_init();
__Ownable_init(msg.sender);
(address _owner, address _button) = abi.decode(initializeParams, (address, address));

button = _button;
Expand Down
2 changes: 2 additions & 0 deletions contracts/test/Button.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";

contract Button is Ownable {
constructor() Ownable(msg.sender) {}

event ButtonPushed(address pusher, uint256 pushes);

uint256 public pushes;
Expand Down
15 changes: 8 additions & 7 deletions deploy/01_mastercopy_module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ethers } from "hardhat"
import "hardhat-deploy"
import { DeployFunction } from "hardhat-deploy/types"
import { HardhatRuntimeEnvironment } from "hardhat/types"
Expand All @@ -9,23 +8,25 @@ const FirstAddress = "0x0000000000000000000000000000000000000001"
const Salt = "0x0000000000000000000000000000000000000000000000000000000000000000"

const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const contract = await ethers.getContractFactory("MyModule")
const { getNamedAccounts, ethers } = hre
const { deployer_address } = await getNamedAccounts()
const deployer = await ethers.getSigner(deployer_address)

let address = await deployMastercopy(
hre,
contract,
deployer,
MODULE_CONTRACT_ARTIFACT,
[
FirstAddress, // owner
FirstAddress, // button
],
Salt,
)

if (address === ethers.constants.AddressZero) {
if (address === ethers.ZeroAddress) {
// the mastercopy was already deployed
const target = await computeTargetAddress(
hre,
contract,
deployer,
MODULE_CONTRACT_ARTIFACT,
[
FirstAddress, // owner
FirstAddress, // button
Expand Down
14 changes: 8 additions & 6 deletions deploy/02_test_dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import "hardhat-deploy"
import { DeployFunction } from "hardhat-deploy/types"
import { HardhatRuntimeEnvironment } from "hardhat/types"
import { deployModuleFactory } from "@gnosis.pm/zodiac/dist/src/factory/deployModuleFactory"
import { deployModuleFactory } from "@gnosis.pm/zodiac"
import { ethers } from "ethers"

const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log("Deploying 'external' dependencies (Button and Avatar)")
const { deployments, getNamedAccounts, ethers } = hre
const { deploy } = deployments
const { deployer } = await getNamedAccounts()
const { deployer_address } = await getNamedAccounts()
const deployer = await ethers.provider.getSigner(deployer_address)

// Deploys the ModuleFactory (and the Singleton factory) if it is not already deployed
await deployModuleFactory(hre)
await deployModuleFactory(deployer)

const testAvatarDeployment = await deploy("TestAvatar", {
from: deployer,
from: deployer_address,
})
console.log("TestAvatar deployed to:", testAvatarDeployment.address)

const buttonDeployment = await deploy("Button", {
from: deployer,
from: deployer_address,
})
console.log("Button deployed to:", buttonDeployment.address)

// Make the TestAvatar the owner of the button
const dependenciesDeployerSigner = await ethers.getSigner(deployer)
const dependenciesDeployerSigner = await ethers.getSigner(deployer_address)
const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address, dependenciesDeployerSigner)
const currentOwner = await buttonContract.owner()
if (currentOwner !== testAvatarDeployment.address) {
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dotenv from "dotenv"
import { HardhatUserConfig } from "hardhat/config"
import "@nomiclabs/hardhat-etherscan"
import "@nomicfoundation/hardhat-verify"
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-waffle"
import "@typechain/hardhat"
Expand All @@ -11,7 +11,7 @@ import "hardhat-deploy"
dotenv.config()

const config: HardhatUserConfig = {
solidity: "0.8.9",
solidity: "0.8.22",
networks: {
goerli: {
url: process.env.GOERLI_URL || "",
Expand Down
61 changes: 30 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zodiac-mod-starter-kit",
"version": "0.0.1",
"version": "1.0.0",
"description": "Out of the box starting point for building Zodiac modules",
"repository": {
"type": "git",
Expand All @@ -17,48 +17,47 @@
"gnosis-safe",
"hardhat"
],
"author": "Gnosis Guild / dOrg",
"author": "Gnosis Guild",
"license": "LGPL-3.0",
"bugs": {
"url": "https://github.com/gnosis/zodiac-mod-starter-kit/issues"
},
"homepage": "https://github.com/gnosis/zodiac-mod-starter-kit",
"devDependencies": {
"@gnosis.pm/zodiac": "2.1.2",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-etherscan": "^3.1.3",
"@gnosis.pm/zodiac": "4.0.3",
"@gnosis.pm/safe-contracts": "^1.3.0",
"@openzeppelin/contracts": "^5.0.0",
"@openzeppelin/contracts-upgradeable": "^5.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.3",
"@typechain/ethers-v5": "^10.2.0",
"@typechain/hardhat": "^6.1.5",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.1.0",
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.16.0",
"chai": "^4.3.6",
"dotenv": "^16.0.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.3",
"@types/mocha": "^10.0.0",
"@types/node": "^18.8.5",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"chai": "^4.3.7",
"dotenv": "^16.0.3",
"eslint": "^8.25.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.0.0",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.7.1",
"hardhat": "^2.12.4",
"hardhat-deploy": "^0.11.22",
"ethers": "^6.9.2",
"hardhat": "^2.14.0",
"hardhat-deploy": "^0.11.28",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^2.6.1",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.7",
"solidity-coverage": "^0.8.2",
"prettier": "^3.0.3",
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^4.0.0",
"solidity-coverage": "^0.8.4",
"ts-node": "^10.9.1",
"typechain": "^8.1.1",
"typescript": "^4.9.4"
},
"dependencies": {
"@gnosis.pm/safe-contracts": "^1.3.0",
"@openzeppelin/contracts": "^4.8.0"
"typechain": "^8.3.2",
"typescript": "^5.2.2"
}
}
4 changes: 2 additions & 2 deletions test/myModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const setup = async () => {
const testSigner = await ethers.getSigner(tester)
const buttonDeployment = await deployments.get("Button")
const myModuleProxyDeployment = await deployments.get("MyModuleProxy")
const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address, testSigner)
const myModuleProxyContract = await ethers.getContractAt("MyModule", myModuleProxyDeployment.address, testSigner)
const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address)
const myModuleProxyContract = await ethers.getContractAt("MyModule", myModuleProxyDeployment.address)
return { buttonContract, myModuleProxyContract }
}

Expand Down
Loading

0 comments on commit a385524

Please sign in to comment.