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 Improvements in Delay Module #29

Merged
merged 21 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 .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: 16
node-version: 20
- uses: actions/cache@v2
with:
path: "**/node_modules"
Expand Down
2 changes: 1 addition & 1 deletion contracts/Delay.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.8.0;

import {Enum, Modifier} from "@gnosis.pm/zodiac/contracts/core/Modifier.sol";
import {Enum, Modifier} from "@gnosis-guild/zodiac-core/contracts/core/Modifier.sol";

contract Delay is Modifier {
event DelaySetup(
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TestFactory.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;

import {ModuleProxyFactory} from "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol";
import {ModuleProxyFactory} from "@gnosis-guild/zodiac-core/contracts/factory/ModuleProxyFactory.sol";

contract TestFactory is ModuleProxyFactory {}
14 changes: 10 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import 'hardhat-gas-reporter'
import dotenv from 'dotenv'
import { HttpNetworkUserConfig } from 'hardhat/types'

import './tasks/deploy'
import './tasks/deploy-mastercopy'

dotenv.config()

import "./tasks/deploy-mastercopies";
import "./tasks/deploy-mastercopy";
import "./tasks/extract-mastercopy";
import "./tasks/verify-mastercopies";
import "./tasks/verify-mastercopy";

const { INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY } = process.env

const sharedNetworkConfig: HttpNetworkUserConfig = {
Expand All @@ -35,7 +38,6 @@ export default {
},
},
},
defaultNetwork: 'hardhat',
networks: {
hardhat: {
allowUnlimitedContractSize: true,
Expand Down Expand Up @@ -86,6 +88,10 @@ export default {
...sharedNetworkConfig,
url: 'https://rpc-mainnet.maticvigil.com',
},
sepolia: {
...sharedNetworkConfig,
url: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
},
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
Expand Down
2,670 changes: 2,670 additions & 0 deletions mastercopies.json

Large diffs are not rendered by default.

63 changes: 33 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"build": "hardhat compile",
"test": "hardhat test",
"coverage": "hardhat coverage",
"deploy": "yarn hardhat deploy",
"extract:mastercopy": "yarn run build && yarn hardhat extract:mastercopy",
"deploy:mastercopies": "yarn hardhat deploy:mastercopies --network",
"deploy:mastercopy": "yarn hardhat deploy:mastercopy --network",
"verify:mastercopies": "yarn hardhat verify:mastercopies --network",
"verify:mastercopy": "yarn hardhat verify:mastercopy --network",
"prepack": "yarn run clean && yarn run build",
"prepare": "yarn run clean && yarn run build",
"lint": "yarn lint:sol && yarn lint:ts",
Expand All @@ -27,39 +30,39 @@
"author": "auryn.macmillan@gnosis.io",
"license": "MIT",
"devDependencies": {
"@gnosis-guild/zodiac-core": "^2.0.2",
"@gnosis.pm/safe-contracts": "1.3.0",
"@gnosis.pm/zodiac": "3.4.1",
"@nomicfoundation/hardhat-chai-matchers": "2.0.2",
"@nomicfoundation/hardhat-ethers": "^3.0.4",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7",
"@nomicfoundation/hardhat-toolbox": "3.0.0",
"@nomicfoundation/hardhat-verify": "2.0.0",
"@openzeppelin/contracts": "^5.0.0",
"@safe-global/safe-singleton-factory": "^1.0.15",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/mocha": "^10.0.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@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/mocha": "^10.0.7",
"@types/node": "^20.5.6",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"chai": "^4.3.7",
"dotenv": "^16.0.3",
"eslint-config-prettier": "^9.0.0",
"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.25.4",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^8.6.0",
"ethers": "^6.8.1",
"hardhat-gas-reporter": "^1.0.9",
"hardhat": "^2.19.0",
"prettier-plugin-solidity": "^1.1.3",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
"solhint-plugin-prettier": "0.0.5",
"solhint": "3.6.2",
"solidity-coverage": "^0.8.2",
"ts-node": "^10.9.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.2.1",
"ethers": "^6.13.2",
"hardhat": "^2.22.7",
"hardhat-gas-reporter": "^2.2.0",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.3.1",
"rimraf": "^6.0.0",
"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.1.6"
"typescript": "5.5.4"
}
}
19 changes: 19 additions & 0 deletions tasks/create-EIP1193.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { EIP1193Provider } from '@gnosis-guild/zodiac-core'
import { Signer } from 'ethers'
import { EthereumProvider } from 'hardhat/types'

export function createEIP1193(
provider: EthereumProvider,
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 })
},
}
}
44 changes: 44 additions & 0 deletions tasks/deploy-mastercopies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { task } from 'hardhat/config'

import { readMastercopies, deployMastercopy } from '@gnosis-guild/zodiac-core'
import { createEIP1193 } from './create-EIP1193'

task(
'deploy:mastercopies',
'For every version entry on the artifacts file, deploys a mastercopy into the current network'
).setAction(async (_, hre) => {
const [signer] = await hre.ethers.getSigners()
const provider = createEIP1193(hre.network.provider, signer)
for (const mastercopy of readMastercopies()) {
const {
contractName,
contractVersion,
factory,
bytecode,
constructorArgs,
salt,
} = mastercopy

const { address, noop } = await deployMastercopy({
factory,
bytecode,
constructorArgs,
salt,
provider,
onStart: () => {
console.log(
`⏳ ${contractName}@${contractVersion}: Deployment starting...`
)
},
})
if (noop) {
console.log(
`🔄 ${contractName}@${contractVersion}: Already deployed at ${address}`
)
} else {
console.log(
`🚀 ${contractName}@${contractVersion}: Successfully deployed at ${address}`
)
}
}
})
79 changes: 44 additions & 35 deletions tasks/deploy-mastercopy.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
import { AbiCoder, ZeroHash } from 'ethers'
import { task } from 'hardhat/config'
import { task, types } from 'hardhat/config'

import { deployViaFactory } from './eip2470'
import { deployMastercopy, readMastercopies } from '@gnosis-guild/zodiac-core'
import { createEIP1193 } from './create-EIP1193'

const AddressOne = '0x0000000000000000000000000000000000000001'

task('deploy:mastercopy', 'Deploys and verifies Delay mastercopy').setAction(
async (_, hre) => {
const [deployer] = await hre.ethers.getSigners()

const Delay = await hre.ethers.getContractFactory('Delay')

const args = AbiCoder.defaultAbiCoder().encode(
['address', 'address', 'address', 'uint256', 'uint256'],
[AddressOne, AddressOne, AddressOne, 0, 0]
)

const creationBytecode = `${Delay.bytecode}${args.substring(2)}`
const salt = ZeroHash
const address = await deployViaFactory(creationBytecode, salt, deployer)

if (hre.network.name == 'hardhat') {
return
}

console.log('Waiting 1 minute before etherscan verification start...')
// Etherscan needs some time to process before trying to verify.
await new Promise((resolve) => setTimeout(resolve, 60000))

await hre.run('verify:verify', {
address,
constructorArguments: [AddressOne, AddressOne, AddressOne, 0, 0],
})
}
task(
'deploy:mastercopy',
'For every version entry on the artifacts file, deploys a mastercopy into the current network'
)

export {}
.addOptionalParam(
'contractVersion',
'The specific version of the contract to deploy',
'latest', // Default value
types.string
)
.setAction(async ({ contractVersion }, hre) => {
const [signer] = await hre.ethers.getSigners()
const provider = createEIP1193(hre.network.provider, signer)

for (const mastercopy of readMastercopies({ contractVersion })) {
const {
contractName,
contractVersion,
factory,
bytecode,
constructorArgs,
salt,
} = mastercopy
const { address, noop } = await deployMastercopy({
factory,
bytecode,
constructorArgs,
salt,
provider,
onStart: () => {
console.log(
`⏳ ${contractName}@${contractVersion}: Deployment starting...`
)
},
})
if (noop) {
console.log(
`🔄 ${contractName}@${contractVersion}: Already deployed at ${address}`
)
}
}
})
62 changes: 0 additions & 62 deletions tasks/deploy.ts

This file was deleted.

Loading
Loading