Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Migration to Zodiac Core and Task Enhancements in Zodiac Mod Starter Kit #8

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
GOERLI_URL=https://eth-goerli.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
SEPOLIA_URL=https://eth-sepolia.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
node-version: 20
- uses: actions/cache@v2
with:
path: "**/node_modules"
Expand Down
2 changes: 1 addition & 1 deletion contracts/MyModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

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

contract MyModule is Module {
address public button;
Expand Down
19 changes: 14 additions & 5 deletions deploy/01_mastercopy_module.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { ZeroHash } from "ethers"
import { DeployFunction } from "hardhat-deploy/types"
import { HardhatRuntimeEnvironment } from "hardhat/types"
import { createFactory, deployViaFactory } from "../factories/eip2470"
import { deployFactories, deployMastercopy } from "@gnosis-guild/zodiac-core"

import createAdapter from "./eip1193"
import MODULE_CONTRACT_ARTIFACT from "../artifacts/contracts/MyModule.sol/MyModule.json"

const FirstAddress = "0x0000000000000000000000000000000000000001"

const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, ethers } = hre
const { deployer: deployerAddress } = await getNamedAccounts()
const deployer = await ethers.getSigner(deployerAddress)

await createFactory(deployer)
const provider = createAdapter({
provider: hre.network.provider,
signer: await ethers.getSigner(deployerAddress),
})

await deployFactories({ provider })

const MyModule = await ethers.getContractFactory("MyModule")
const tx = await MyModule.getDeployTransaction(FirstAddress, FirstAddress)

const mastercopy = await deployViaFactory({ bytecode: tx.data, salt: ZeroHash }, deployer)
const { address: mastercopy } = await deployMastercopy({
bytecode: MyModule.bytecode,
constructorArgs: { types: ["address", "address"], values: [FirstAddress, FirstAddress] },
salt: ZeroHash,
provider,
})

hre.deployments.save("MyModuleMastercopy", {
abi: MODULE_CONTRACT_ARTIFACT.abi,
Expand Down
39 changes: 16 additions & 23 deletions deploy/03_proxy_module.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
import { ZeroHash } from "ethers"
import { DeployFunction } from "hardhat-deploy/types"
import { HardhatRuntimeEnvironment } from "hardhat/types"

import { createFactory, deployModAsProxy } from "../factories/moduleProxyFactory"

import MODULE_CONTRACT_ARTIFACT from "../artifacts/contracts/MyModule.sol/MyModule.json"
import createAdapter from "./eip1193"
import { deployFactories, deployProxy } from "@gnosis-guild/zodiac-core"

const deploy: DeployFunction = async function ({
deployments,
getNamedAccounts,
ethers,
getChainId,
network,
}: HardhatRuntimeEnvironment) {
console.log("Deploying MyModule Proxy")
const { deployer: deployerAddress } = await getNamedAccounts()
const deployer = await ethers.getSigner(deployerAddress)

const buttonDeployment = await deployments.get("Button")
const testAvatarDeployment = await deployments.get("TestAvatar")

const myModuleMastercopyDeployment = await deployments.get("MyModuleMastercopy")

/// const chainId = await getChainId()
// const network: SupportedNetworks = Number(chainId)
// if ((await ethers.provider.getCode(ContractAddresses[network][KnownContracts.FACTORY])) === "0x") {
// // the Module Factory should already be deployed to all supported chains
// // if you are deploying to a chain where its not deployed yet (most likely locale test chains), run deployModuleFactory from the zodiac package
// throw Error("The Module Factory is not deployed on this network. Please deploy it first.")
// }

const provider = createAdapter({
provider: network.provider,
signer: await ethers.getSigner(deployerAddress),
})

console.log("buttonDeployment.address:", buttonDeployment.address)

// Deploys the ModuleFactory (and the Singleton factory) if it is not already deployed
const factory = await createFactory(deployer)
const { transaction } = await deployModAsProxy(
factory,
myModuleMastercopyDeployment.address,
{
await deployFactories({ provider })
const { address: myModuleProxyAddress } = await deployProxy({
mastercopy: myModuleMastercopyDeployment.address,
setupArgs: {
values: [testAvatarDeployment.address, buttonDeployment.address],
types: ["address", "address"],
},
ZeroHash,
)
const deploymentTransaction = await deployer.sendTransaction(transaction)
const receipt = (await deploymentTransaction.wait())!
const myModuleProxyAddress = receipt.logs[1].address
saltNonce: 0,
provider,
})

console.log("MyModule minimal proxy deployed to:", myModuleProxyAddress)

deployments.save("MyModuleProxy", {
Expand Down
21 changes: 21 additions & 0 deletions deploy/eip1193.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Signer } from "ethers"
import { EIP1193Provider } from "@gnosis-guild/zodiac-core"

export default function createAdapter({
provider,
signer,
}: {
provider: EIP1193Provider
signer: Signer
}): EIP1193Provider {
return {
request: async ({ method, params }) => {
if (method == "eth_sendTransaction") {
const { hash } = await signer.sendTransaction((params as any[])[0])
return hash
}

return provider.request({ method, params })
},
}
}
56 changes: 0 additions & 56 deletions factories/eip2470.ts

This file was deleted.

58 changes: 0 additions & 58 deletions factories/moduleProxyFactory.ts

This file was deleted.

4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dotenv.config()
const config: HardhatUserConfig = {
solidity: "0.8.22",
networks: {
goerli: {
url: process.env.GOERLI_URL || "",
sepolia: {
url: process.env.SEPOLIA_URL || "",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
Expand Down
58 changes: 28 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,39 @@
},
"homepage": "https://github.com/gnosis/zodiac-mod-starter-kit",
"devDependencies": {
"@gnosis.pm/safe-contracts": "^1.3.0",
"@gnosis.pm/zodiac": "4.0.3",
"@gnosis-guild/zodiac-core": "^2.0.1",
"@gnosis.pm/safe-contracts": "1.3.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@nomicfoundation/hardhat-ethers": "3.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7",
"@nomicfoundation/hardhat-toolbox": "4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@openzeppelin/contracts": "^5.0.0",
"@openzeppelin/contracts-upgradeable": "^5.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.6",
"@nomicfoundation/hardhat-ignition": "^0.15.5",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.9",
"@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",
"@types/mocha": "^10.0.7",
"@types/node": "^20.5.6",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"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.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.0.0",
"ethers": "^6.9.2",
"dotenv": "^16.4.5",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.2.1",
"ethers": "^6.13.2",
"hardhat": "^2.14.0",
"hardhat-deploy": "^0.11.28",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^3.0.3",
"hardhat-deploy": "^0.12.0",
"hardhat-gas-reporter": "^2.2.0",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^4.0.0",
"solidity-coverage": "^0.8.4",
"ts-node": "^10.9.1",
"typechain": "^8.3.2",
"typescript": "^5.2.2"
"solhint": "5.0.2",
"solhint-plugin-prettier": "0.1.0",
"solidity-coverage": "^0.8.12",
"ts-node": "^10.9.2",
"typechain": "^8.1.1",
"typescript": "5.5.4"
}
}
Loading
Loading