Skip to content

Commit

Permalink
Merge pull request #74 from gnosis/update_zodiac
Browse files Browse the repository at this point in the history
Update zodiac
  • Loading branch information
auryn-macmillan authored Aug 15, 2023
2 parents 4399940 + 9a5da8b commit 2118798
Show file tree
Hide file tree
Showing 13 changed files with 1,705 additions and 909 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ packages/exit-app/src/contracts/types

packages/exit-app/.env

node_modules
node_modules

.DS_Store
12 changes: 0 additions & 12 deletions node_modules/.yarn-integrity

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract contract CirculatingSupplyBase is OwnableUpgradeable, ExclusionList {

address public token;

function setUp(bytes memory initializeParams) public {
function setUp(bytes memory initializeParams) public initializer {
(address _owner, address _token, address[] memory _exclusions) = abi
.decode(initializeParams, (address, address, address[]));
__Ownable_init();
Expand All @@ -34,10 +34,10 @@ abstract contract CirculatingSupplyBase is OwnableUpgradeable, ExclusionList {
/// @param prevExclusion Exclusion that pointed to the exclusion to be removed in the linked list
/// @param exclusion Exclusion to be removed
/// @notice This can only be called by the owner
function removeExclusion(address prevExclusion, address exclusion)
public
onlyOwner
{
function removeExclusion(
address prevExclusion,
address exclusion
) public onlyOwner {
_removeExclusion(prevExclusion, exclusion);
}

Expand Down
21 changes: 9 additions & 12 deletions packages/contracts/contracts/ExitModule/ExitERC20Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract ExitERC20 is ExitBase, ReentrancyGuard {
setUp(initParams);
}

function setUp(bytes memory initParams) public override {
function setUp(bytes memory initParams) public override initializer {
(
address _owner,
address _avatar,
Expand Down Expand Up @@ -67,11 +67,10 @@ contract ExitERC20 is ExitBase, ReentrancyGuard {
// @param tokens Array of tokens to claim, ordered lowest to highest
// @notice Will revert if tokens[] is not ordered highest to lowest, contains duplicates,
// includes the designated token or includes denied tokens
function exit(uint256 amountToRedeem, address[] calldata tokens)
external
override
nonReentrant
{
function exit(
uint256 amountToRedeem,
address[] calldata tokens
) external override nonReentrant {
require(
designatedToken.balanceOf(msg.sender) >= amountToRedeem,
"Amount to redeem is greater than balance"
Expand All @@ -94,12 +93,10 @@ contract ExitERC20 is ExitBase, ReentrancyGuard {
_exit(tokens, params);
}

function getExitAmount(uint256 amount, bytes memory params)
internal
pure
override
returns (uint256)
{
function getExitAmount(
uint256 amount,
bytes memory params
) internal pure override returns (uint256) {
(uint256 amountToRedeem, uint256 _circulatingSupply) = abi.decode(
params,
(uint256, uint256)
Expand Down
27 changes: 12 additions & 15 deletions packages/contracts/contracts/ExitModule/ExitERC721Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ contract ExitERC721 is ExitBase, ReentrancyGuard {
setUp(initParams);
}

function setUp(bytes memory initParams) public override {
function setUp(bytes memory initParams) public override initializer {
(
address _owner,
address _avatar,
address _target,
address _collection,
address _circulatingSupply
) = abi.decode(
initParams,
(address, address, address, address, address)
);
initParams,
(address, address, address, address, address)
);
__Ownable_init();
require(_avatar != address(0), "Avatar can not be zero address");
require(_target != address(0), "Target can not be zero address");
Expand All @@ -62,11 +62,10 @@ contract ExitERC721 is ExitBase, ReentrancyGuard {
// @param tokenId of token to be used to exit
// @param tokens Array of tokens to claim, ordered lowest to highest
// @notice Will revert if tokens[] is not ordered highest to lowest, contains duplicates, or includes denied tokens
function exit(uint256 tokenId, address[] calldata tokens)
external
override
nonReentrant
{
function exit(
uint256 tokenId,
address[] calldata tokens
) external override nonReentrant {
require(
collection.ownerOf(tokenId) == msg.sender,
"Only token owner can exit"
Expand All @@ -87,12 +86,10 @@ contract ExitERC721 is ExitBase, ReentrancyGuard {
collection = ERC721Enumerable(_collection);
}

function getExitAmount(uint256 supply, bytes memory params)
internal
pure
override
returns (uint256)
{
function getExitAmount(
uint256 supply,
bytes memory params
) internal pure override returns (uint256) {
uint256 _circulatingSupply = abi.decode(params, (uint256));
return supply / _circulatingSupply;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/contracts/contracts/test/TestAvatar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ contract TestAvatar {
if (operation == 1) (success, ) = to.delegatecall(data);
else (success, ) = to.call{value: value}(data);
}

function execTransactionFromModuleReturnData(
address payable to,
uint256 value,
bytes calldata data,
uint8 operation
) external returns (bool success, bytes memory returnData) {
if (msg.sender != module) revert NotAuthorized(msg.sender);
if (operation == 1) (success, returnData) = to.delegatecall(data);
else (success, returnData) = to.call{value: value}(data);
}
}
10 changes: 5 additions & 5 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"author": "",
"license": "LGPL-3.0+",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "2.0.2",
"@nomiclabs/hardhat-ethers": "2.2.3",
"@nomiclabs/hardhat-etherscan": "2.1.4",
"@nomiclabs/hardhat-waffle": "2.0.1",
"@types/chai": "4.2.21",
Expand All @@ -38,21 +38,21 @@
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-prettier": "3.4.0",
"ethereum-waffle": "3.4.0",
"hardhat": "2.6.4",
"hardhat": "2.16.1",
"hardhat-deploy": "0.8.11",
"prettier": "2.3.2",
"prettier-plugin-solidity": "1.0.0-beta.16",
"solhint": "3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "0.7.17",
"solidity-coverage": "0.8.4",
"ts-node": "10.1.0",
"typescript": "4.3.5",
"yargs": "16.1.1"
},
"dependencies": {
"@gnosis.pm/zodiac": "^1.0.3",
"@gnosis.pm/zodiac": "3.3.6",
"@gnosis.pm/safe-contracts": "1.3.0",
"@openzeppelin/contracts": "^4.2.0",
"ethers": "^5.4.6"
"ethers": "^5.7.2"
}
}
37 changes: 29 additions & 8 deletions packages/contracts/src/deploy/deploy_circulating_supply.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import { deployMastercopy, computeTargetAddress } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import CONTRACT_ARTIFACT from "../../build/artifacts/contracts/CirculatingSupply/CirculatingSupplyERC20.sol/CirculatingSupplyERC20.json";

const SaltZero =
"0x0000000000000000000000000000000000000000000000000000000000000000";
const FirstAddress = "0x0000000000000000000000000000000000000001";

const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();
const { deploy } = deployments;
const args = [FirstAddress, FirstAddress, []];
const { getNamedAccounts } = hre;
const { deployer: deployerAddress } = await getNamedAccounts();
const deployer = hre.ethers.provider.getSigner(deployerAddress);

const CirculatingSupplyERC20 = await hre.ethers.getContractFactory(
"CirculatingSupplyERC20"
);

const args = [FirstAddress, FirstAddress, []];

await deploy("CirculatingSupplyERC20", {
from: deployer,
const { address, isDeployed } = await computeTargetAddress(
deployer,
CirculatingSupplyERC20,
args,
log: true,
deterministicDeployment: true,
SaltZero
);

if (isDeployed) {
console.log("CirculatingSupplyERC20 already deployed to:", address);
} else {
await deployMastercopy(deployer, CirculatingSupplyERC20, args, SaltZero);
console.log("CirculatingSupplyERC20 was deployed to:", address);
}

hre.deployments.save("CirculatingSupplyERC20", {
abi: CONTRACT_ARTIFACT.abi,
address: address,
});
};

Expand Down
28 changes: 0 additions & 28 deletions packages/contracts/src/deploy/deploy_erc20_exit_module.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { computeTargetAddress, deployMastercopy } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import CONTRACT_ARTIFACT from "../../build/artifacts/contracts/ExitModule/ExitERC20Module.sol/ExitERC20.json";

const SaltZero =
"0x0000000000000000000000000000000000000000000000000000000000000000";
const FirstAddress = "0x0000000000000000000000000000000000000001";

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

const ExitERC20 = await hre.ethers.getContractFactory("ExitERC20");

const args = [
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
];
const { address, isDeployed } = await computeTargetAddress(
deployer,
ExitERC20,
args,
SaltZero
);

if (isDeployed) {
console.log("ExitERC20 already deployed to:", address);
} else {
await deployMastercopy(deployer, ExitERC20, args, SaltZero);
console.log("ExitERC20 was deployed to:", address);
}

hre.deployments.save("ExitERC20", {
abi: CONTRACT_ARTIFACT.abi,
address: address,
});
};

deploy.tags = ["exit-module"];
export default deploy;
28 changes: 0 additions & 28 deletions packages/contracts/src/deploy/deploy_erc721_exit_module.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { computeTargetAddress, deployMastercopy } from "@gnosis.pm/zodiac";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import CONTRACT_ARTIFACT from "../../build/artifacts/contracts/ExitModule/ExitERC721Module.sol/ExitERC721.json";

const SaltZero =
"0x0000000000000000000000000000000000000000000000000000000000000000";
const FirstAddress = "0x0000000000000000000000000000000000000001";

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

const ExitERC721 = await hre.ethers.getContractFactory("ExitERC721");

const args = [
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
FirstAddress,
];

const { address, isDeployed } = await computeTargetAddress(
deployer,
ExitERC721,
args,
SaltZero
);

if (isDeployed) {
console.log("ExitERC721 already deployed to:", address);
} else {
await deployMastercopy(deployer, ExitERC721, args, SaltZero);
console.log("ExitERC721 was deployed to:", address);
}

hre.deployments.save("ExitERC721", {
abi: CONTRACT_ARTIFACT.abi,
address: address,
});
};

deploy.tags = ["erc721-exit-module"];
export default deploy;
Loading

1 comment on commit 2118798

@vercel
Copy link

@vercel vercel bot commented on 2118798 Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.