From a6bbe9e1f790d61f900c5c91b4e52078192e19f2 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Fri, 26 May 2023 21:33:46 +0000 Subject: [PATCH] init Signed-off-by: AlienTornadosaurusHex <> --- .env.example | 3 ++ .gitignore | 5 +- foundry.toml | 12 +++-- package.json | 15 ++++-- remappings.txt | 9 ++++ src/base/TornadoProposal.sol | 39 +++++++++++++++ src/common/BaseProposal.sol | 24 --------- src/common/interfaces/IERC20.sol | 11 ----- src/common/interfaces/IGnosisSafe.sol | 70 +++++++++++++++++++++++++++ src/common/interfaces/IGovernance.sol | 11 +---- src/common/test/Common.sol | 3 +- 11 files changed, 149 insertions(+), 53 deletions(-) create mode 100644 .env.example create mode 100644 remappings.txt create mode 100644 src/base/TornadoProposal.sol delete mode 100644 src/common/BaseProposal.sol delete mode 100644 src/common/interfaces/IERC20.sol create mode 100644 src/common/interfaces/IGnosisSafe.sol diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ecd9cc1 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +MAINNET_RPC_URL= +PRIVATE_KEY= +ETHERSCAN_KEY= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6beb3e4..e72d065 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,7 @@ docs/ .env # Node modules -node_modules \ No newline at end of file +node_modules/ + +# yarn +yarn.lock \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 8920d49..acb113d 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,8 +1,14 @@ [profile.default] -solc-version = "0.8.20" +# General src = 'src' out = 'out' libs = ["node_modules", "lib"] -chain_id = 1 + +# Compiler +auto_detect_solc = true optimizer = true -optimizer-runs = 10_000_000 \ No newline at end of file +optimizer-runs = 1_000_000 + +# Network +chain_id = 1 +rpc_endpoints = { mainnet = "${MAINNET_RPC_URL}" } \ No newline at end of file diff --git a/package.json b/package.json index 4f844c1..5168fbc 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,17 @@ { - "name": "governance-proposal-template", + "name": "proposal-template", "version": "1.0.0", - "repository": "https://git.tornado.ws/AlienTornadosaurusHex/governance-proposal-template", + "repository": "https://git.tornado.ws/AlienTornadosaurusHex/proposal-template", "author": "AlienTornadosaurusHex", "license": "MIT", - "private": false + "private": false, + "dependencies": { + "@ensdomains/ens-contracts": "^0.0.21", + "@openzeppelin/contracts": "^4.9.0", + "@openzeppelin/upgrades-core": "^1.26.2" + }, + "optionalDependencies": { + "@gnosis.pm/ido-contracts": "^0.5.0", + "@gnosis.pm/safe-contracts": "1.3.0" + } } diff --git a/remappings.txt b/remappings.txt new file mode 100644 index 0000000..055d9d8 --- /dev/null +++ b/remappings.txt @@ -0,0 +1,9 @@ +src/=src/ +common/=src/common/ +forge-std/=lib/forge-std/src/ + +@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ +@openzeppelin/upgrades/=node_modules/@openzeppelin/upgrades-core/ +@ens/contracts/=node_modules/@ensdomains/ens-contracts/contracts/ +@gnosis/contracts/=node_modules/@gnosis.pm/safe-contracts/contracts/ +@gnosis/ido-contracts/=node_modules/@gnosis.pm/ido-contracts/contracts/ diff --git a/src/base/TornadoProposal.sol b/src/base/TornadoProposal.sol new file mode 100644 index 0000000..970283f --- /dev/null +++ b/src/base/TornadoProposal.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.19; + +import {ENS} from "@ens/contracts/registry/ENS.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import {IGovernance} from "common/interfaces/IGovernance.sol"; +import {IGnosisSafe} from "common/interfaces/IGnosisSafe.sol"; + +contract TornadoProposal { + function getMultisig() internal pure returns (IGnosisSafe) { + return IGnosisSafe(0xb04E030140b30C27bcdfaafFFA98C57d80eDa7B4); + } + + function getEns() internal pure returns (ENS) { + return ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e); + } + + function getTornToken() internal pure returns (IERC20) { + return IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C); + } + + function getGovernance() internal pure returns (IGovernance) { + return IGovernance(getGovernanceProxyAddress()); + } + + function getGovernanceProxyAddress() internal pure returns (address) { + return 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce; + } + + function getStakingProxyAddress() internal pure returns (address) { + return 0x2FC93484614a34f26F7970CBB94615bA109BB4bf; + } + + function getRegistryProxyAddress() internal pure returns (address) { + return 0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2; + } +} diff --git a/src/common/BaseProposal.sol b/src/common/BaseProposal.sol deleted file mode 100644 index 6b0eca7..0000000 --- a/src/common/BaseProposal.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.20; - -import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; -import { LoopbackProxy } from "../v1/LoopbackProxy.sol"; -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { Address } from "@openzeppelin/contracts/utils/Address.sol"; - -import { GovernancePatchUpgrade } from "./GovernancePatchUpgrade.sol"; -import { TornadoStakingRewards } from "./TornadoStakingRewards.sol"; -import { RelayerRegistry } from "./RelayerRegistry.sol"; - -contract BaseProposal { - function getGovernanceProxyAddress() internal pure returns (address memory) { - return "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce"; - } - function getStakingProxyAddress() internal pure returns (address memory) { - return "0x2FC93484614a34f26F7970CBB94615bA109BB4bf"; - } - function getRegistryProxyAddress() internal pure returns (address memory) { - return "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2"; - } -} \ No newline at end of file diff --git a/src/common/interfaces/IERC20.sol b/src/common/interfaces/IERC20.sol deleted file mode 100644 index 8223042..0000000 --- a/src/common/interfaces/IERC20.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma solidity ^0.8.20; - -interface IERC20 { - function transfer(address to, uint256 amount) external returns (bool); - - function transferFrom(address from, address to, uint256 amount) external returns (bool); - - function balanceOf(address owner) external returns (uint256); - - function approve(address spender, uint256 amount) external; -} diff --git a/src/common/interfaces/IGnosisSafe.sol b/src/common/interfaces/IGnosisSafe.sol new file mode 100644 index 0000000..43b5a54 --- /dev/null +++ b/src/common/interfaces/IGnosisSafe.sol @@ -0,0 +1,70 @@ +pragma solidity ^0.8.19; + +interface IGnosisSafe { + enum Operation { + Call, + DelegateCall + } + + function setup( + address[] calldata _owners, + uint256 _threshold, + address to, + bytes calldata data, + address fallbackHandler, + address paymentToken, + uint256 payment, + address payable paymentReceiver + ) external; + + function execTransaction( + address to, + uint256 value, + bytes calldata data, + Operation operation, + uint256 safeTxGas, + uint256 baseGas, + uint256 gasPrice, + address gasToken, + address payable refundReceiver, + bytes calldata signatures + ) external returns (bool success); + + function requiredTxGas(address to, uint256 value, bytes calldata data, Operation operation) + external + returns (uint256); + + function approveHash(bytes32 hashToApprove) external; + + function signMessage(bytes calldata _data) external; + + function isValidSignature(bytes calldata _data, bytes calldata _signature) external returns (bytes4); + + function getMessageHash(bytes memory message) external view returns (bytes32); + + function encodeTransactionData( + address to, + uint256 value, + bytes memory data, + Operation operation, + uint256 safeTxGas, + uint256 baseGas, + uint256 gasPrice, + address gasToken, + address refundReceiver, + uint256 _nonce + ) external view returns (bytes memory); + + function getTransactionHash( + address to, + uint256 value, + bytes memory data, + Operation operation, + uint256 safeTxGas, + uint256 baseGas, + uint256 gasPrice, + address gasToken, + address refundReceiver, + uint256 _nonce + ) external view returns (bytes32); +} diff --git a/src/common/interfaces/IGovernance.sol b/src/common/interfaces/IGovernance.sol index a3657a1..e2c668d 100644 --- a/src/common/interfaces/IGovernance.sol +++ b/src/common/interfaces/IGovernance.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; struct Proposal { // Creator of the proposal @@ -23,7 +23,6 @@ struct Proposal { interface IGovernance { function initialized() external view returns (bool); function initializing() external view returns (bool); - function EXECUTION_DELAY() external view returns (uint256); function EXECUTION_EXPIRATION() external view returns (uint256); function QUORUM_VOTES() external view returns (uint256); @@ -32,18 +31,12 @@ interface IGovernance { function VOTING_PERIOD() external view returns (uint256); function CLOSING_PERIOD() external view returns (uint256); function VOTE_EXTEND_TIME() external view returns (uint256); - function torn() external view returns (address); - function proposals(uint256 index) external view returns (Proposal memory); - function lockedBalance(address account) external view returns (uint256); - function propose(address target, string memory description) external returns (uint256); - function castVote(uint256 proposalId, bool support) external; - function lock(address owner, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; - + function lockWithApproval(uint256 amount) external; function execute(uint256 proposalId) external payable; } diff --git a/src/common/test/Common.sol b/src/common/test/Common.sol index 43ec321..9df7357 100644 --- a/src/common/test/Common.sol +++ b/src/common/test/Common.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; contract Common { uint256 constant TEST_PRIVATE_KEY_ONE = 0x66ddbd7cbe4a566df405f6ded0b908c669f88cdb1656380c050e3a457bd21df0; @@ -31,4 +31,3 @@ contract Common { uint16 constant PERMIT_FUNC_SELECTOR = uint16(0x1901); } -