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 Bridge Module #24

Merged
merged 8 commits into from
Aug 27, 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: 21
- uses: actions/cache@v2
with:
path: "**/node_modules"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ env/
.env
.history
coverage*
deployments
deployments
typechain-types
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Redirect output to stderr.
exec 1>&2

Expand Down
11 changes: 6 additions & 5 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"plugins": ["prettier-plugin-solidity"]
}
8 changes: 4 additions & 4 deletions contracts/AMBModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;

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


interface IAMB {
function messageSender() external view returns (address);
Expand Down Expand Up @@ -54,7 +55,7 @@ contract AMBModule is Module {
setUp(initParams);
}

function setUp(bytes memory initParams) public override {
function setUp(bytes memory initParams) public override initializer {
(
address _owner,
address _avatar,
Expand All @@ -66,7 +67,6 @@ contract AMBModule is Module {
initParams,
(address, address, address, IAMB, address, bytes32)
);
__Ownable_init();

require(_avatar != address(0), "Avatar can not be zero address");
require(_target != address(0), "Target can not be zero address");
Expand All @@ -76,7 +76,7 @@ contract AMBModule is Module {
controller = _controller;
chainId = _chainId;

transferOwnership(_owner);
_transferOwnership(_owner);

emit AmbModuleSetup(msg.sender, _owner, _avatar, _target);
}
Expand Down
26 changes: 13 additions & 13 deletions contracts/test/Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ pragma solidity >=0.6.0 <0.7.0;
import "@gnosis.pm/mock-contract/contracts/MockContract.sol";

contract Mock is MockContract {
function exec(
address payable to,
uint256 value,
bytes calldata data
) external {
bool success;
bytes memory response;
(success, response) = to.call{value: value}(data);
if (!success) {
assembly {
revert(add(response, 0x20), mload(response))
}
}
function exec(
address payable to,
uint256 value,
bytes calldata data
) external {
bool success;
bytes memory response;
(success, response) = to.call{value: value}(data);
if (!success) {
assembly {
revert(add(response, 0x20), mload(response))
}
}
}
}
56 changes: 28 additions & 28 deletions contracts/test/TestAvatar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
pragma solidity >=0.8.0;

contract TestAvatar {
address public module;
address public module;

receive() external payable {}
receive() external payable {}

function setModule(address _module) external {
module = _module;
}
function setModule(address _module) external {
module = _module;
}

function exec(
address payable to,
uint256 value,
bytes calldata data
) external {
bool success;
bytes memory response;
(success, response) = to.call{value: value}(data);
if (!success) {
assembly {
revert(add(response, 0x20), mload(response))
}
}
function exec(
address payable to,
uint256 value,
bytes calldata data
) external {
bool success;
bytes memory response;
(success, response) = to.call{value: value}(data);
if (!success) {
assembly {
revert(add(response, 0x20), mload(response))
}
}
}

function execTransactionFromModule(
address payable to,
uint256 value,
bytes calldata data,
uint8 operation
) external returns (bool success) {
require(msg.sender == module, "Not authorized");
if (operation == 1) (success, ) = to.delegatecall(data);
else (success, ) = to.call{value: value}(data);
}
function execTransactionFromModule(
address payable to,
uint256 value,
bytes calldata data,
uint8 operation
) external returns (bool success) {
require(msg.sender == module, "Not authorized");
if (operation == 1) (success, ) = to.delegatecall(data);
else (success, ) = to.call{value: value}(data);
}
}
2 changes: 1 addition & 1 deletion contracts/test/TestFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;

import "@gnosis.pm/zodiac/contracts/factory/ModuleProxyFactory.sol";
import "@gnosis-guild/zodiac-core/contracts/factory/ModuleProxyFactory.sol";
74 changes: 58 additions & 16 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "solidity-coverage";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-verify";
import "@nomicfoundation/hardhat-ethers";
import "hardhat-gas-reporter";
import "hardhat-deploy";
import dotenv from "dotenv";
import type { HttpNetworkUserConfig } from "hardhat/types";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import type { HttpNetworkUserConfig } from "hardhat/types";

const argv = yargs
const argv = yargs(hideBin(process.argv))
.option("network", {
type: "string",
default: "hardhat",
describe: "The network to connect to",
})
.help(false)
.version(false).argv;
.version(false)
.parseSync();

// Load environment variables.
dotenv.config();
const { INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK } = process.env;

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

const DEFAULT_MNEMONIC =
"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
Expand All @@ -33,7 +40,7 @@ if (PK) {
};
}

if (["rinkeby", "mainnet"].includes(argv.network) && INFURA_KEY === undefined) {
if (["sepolia", "mainnet"].includes(argv.network) && INFURA_KEY === undefined) {
throw new Error(
`Could not find Infura key in env, unable to connect to network ${argv.network}`
);
Expand All @@ -47,20 +54,31 @@ export default {
sources: "contracts",
},
solidity: {
compilers: [{ version: "0.8.0" }, { version: "0.6.12" }],
compilers: [
{ version: "0.8.20" },
{ version: "0.8.0" },
{ version: "0.6.12" },
],
settings: {
optimizer: {
enabled: true,
runs: 100,
},
},
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 100000000,
gas: 100000000,
},
mainnet: {
...sharedNetworkConfig,
url: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
},
rinkeby: {
sepolia: {
...sharedNetworkConfig,
url: `https://rinkeby.infura.io/v3/${INFURA_KEY}`,
},
goerli: {
...sharedNetworkConfig,
url: `https://goerli.infura.io/v3/${INFURA_KEY}`,
url: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
},
xdai: {
...sharedNetworkConfig,
Expand All @@ -70,6 +88,30 @@ export default {
...sharedNetworkConfig,
url: "https://rpc-mainnet.maticvigil.com",
},
mumbai: {
...sharedNetworkConfig,
url: `https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`,
},
polygon: {
...sharedNetworkConfig,
url: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
},
volta: {
...sharedNetworkConfig,
url: `https://volta-rpc.energyweb.org`,
},
bsc: {
...sharedNetworkConfig,
url: `https://bsc-dataseed.binance.org/`,
},
arbitrum: {
...sharedNetworkConfig,
url: `https://arb1.arbitrum.io/rpc`,
},
avalanche: {
...sharedNetworkConfig,
url: `https://api.avax.network/ext/bc/C/rpc`,
},
},
namedAccounts: {
deployer: 0,
Expand Down
477 changes: 477 additions & 0 deletions mastercopies.json

Large diffs are not rendered by default.

80 changes: 45 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"build": "hardhat compile",
"test": "hardhat test",
"deploy": "hardhat deploy --network",
"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",
"coverage": "hardhat coverage",
"lint": "yarn lint:sol && yarn lint:ts",
"lint:sol": "solhint 'contracts/**/*.sol'",
Expand All @@ -24,45 +29,50 @@
"author": "[email protected]",
"license": "MIT",
"devDependencies": {
"@gnosis.pm/zodiac": "1.0.1",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^2.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.21",
"@types/yargs": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"chai": "^4.2.0",
"@gnosis-guild/zodiac-core": "^2.0.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@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.0",
"@nomicfoundation/ignition-core": "^0.15.5",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.3",
"@types/mocha": "^10.0.7",
"@types/node": "^22.1.0",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^8.0.1",
"chai": "^4.3.7",
"debug": "^4.2.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^8.0.0",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-prettier": "^3.1.4",
"ethereum-waffle": "^3.2.0",
"hardhat": "2.6.4",
"hardhat-deploy": "^0.7.0-beta.38",
"husky": "^5.1.3",
"prettier": "^2.1.2",
"prettier-plugin-solidity": "^1.0.0-alpha.60",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.17",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "^5.2.1",
"hardhat": "^2.22.8",
"hardhat-deploy": "^0.12.4",
"hardhat-gas-reporter": "^2.2.0",
"husky": "^9.1.4",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.1",
"solhint": "^5.0.3",
"solhint-plugin-prettier": "^0.1.0",
"solidity-coverage": "^0.8.12",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.5.4"
},
"dependencies": {
"@gnosis.pm/mock-contract": "^4.0.0",
"@openzeppelin/contracts": "^4.3.1",
"argv": "^0.0.2",
"dotenv": "^8.0.0",
"ethers": "^5.0.19",
"solc": "0.8.1",
"yargs": "^16.1.1"
},
"resolutions": {
"bitcore-lib": "8.25.0"
"@nomicfoundation/hardhat-ethers": "^3.0.6",
"@openzeppelin/contracts": "^5.0.2",
"argv": "^0.0.3",
"dotenv": "^16.4.5",
"ethers": "^6.13.2",
"solc": "^0.8.26",
"yargs": "^17.7.2"
}
}
Loading
Loading