From ef76a65a93f3b7d3d506230f858b0c9165c421f6 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Fri, 26 May 2023 20:35:02 +0000 Subject: [PATCH] init Signed-off-by: AlienTornadosaurusHex <> --- .github/workflows/test.yml | 34 ------------------- .gitignore | 3 ++ foundry.toml | 12 ++++--- package.json | 8 +++++ script/Counter.s.sol | 12 ------- src/Counter.sol | 14 -------- src/common/BaseProposal.sol | 24 +++++++++++++ src/common/interfaces/IERC20.sol | 11 ++++++ src/common/interfaces/IGovernance.sol | 49 +++++++++++++++++++++++++++ src/common/test/Common.sol | 34 +++++++++++++++++++ test/Counter.t.sol | 24 ------------- 11 files changed, 136 insertions(+), 89 deletions(-) delete mode 100644 .github/workflows/test.yml create mode 100644 package.json delete mode 100644 script/Counter.s.sol delete mode 100644 src/Counter.sol create mode 100644 src/common/BaseProposal.sol create mode 100644 src/common/interfaces/IERC20.sol create mode 100644 src/common/interfaces/IGovernance.sol create mode 100644 src/common/test/Common.sol delete mode 100644 test/Counter.t.sol diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 09880b1..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: test - -on: workflow_dispatch - -env: - FOUNDRY_PROFILE: ci - -jobs: - check: - strategy: - fail-fast: true - - name: Foundry project - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Run Forge build - run: | - forge --version - forge build --sizes - id: build - - - name: Run Forge tests - run: | - forge test -vvv - id: test diff --git a/.gitignore b/.gitignore index 85198aa..6beb3e4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ docs/ # Dotenv file .env + +# Node modules +node_modules \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 4ff40c4..8920d49 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,6 +1,8 @@ [profile.default] -src = "src" -out = "out" -libs = ["lib"] - -# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file +solc-version = "0.8.20" +src = 'src' +out = 'out' +libs = ["node_modules", "lib"] +chain_id = 1 +optimizer = true +optimizer-runs = 10_000_000 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4f844c1 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "governance-proposal-template", + "version": "1.0.0", + "repository": "https://git.tornado.ws/AlienTornadosaurusHex/governance-proposal-template", + "author": "AlienTornadosaurusHex", + "license": "MIT", + "private": false +} diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index 0e546ab..0000000 --- a/script/Counter.s.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Script.sol"; - -contract CounterScript is Script { - function setUp() public {} - - function run() public { - vm.broadcast(); - } -} diff --git a/src/Counter.sol b/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/src/Counter.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract Counter { - uint256 public number; - - function setNumber(uint256 newNumber) public { - number = newNumber; - } - - function increment() public { - number++; - } -} diff --git a/src/common/BaseProposal.sol b/src/common/BaseProposal.sol new file mode 100644 index 0000000..6b0eca7 --- /dev/null +++ b/src/common/BaseProposal.sol @@ -0,0 +1,24 @@ +// 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 new file mode 100644 index 0000000..8223042 --- /dev/null +++ b/src/common/interfaces/IERC20.sol @@ -0,0 +1,11 @@ +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/IGovernance.sol b/src/common/interfaces/IGovernance.sol new file mode 100644 index 0000000..a3657a1 --- /dev/null +++ b/src/common/interfaces/IGovernance.sol @@ -0,0 +1,49 @@ +pragma solidity ^0.8.20; + +struct Proposal { + // Creator of the proposal + address proposer; + // target addresses for the call to be made + address target; + // The block at which voting begins + uint256 startTime; + // The block at which voting ends: votes must be cast prior to this block + uint256 endTime; + // Current number of votes in favor of this proposal + uint256 forVotes; + // Current number of votes in opposition to this proposal + uint256 againstVotes; + // Flag marking whether the proposal has been executed + bool executed; + // Flag marking whether the proposal voting time has been extended + // Voting time can be extended once, if the proposal outcome has changed during CLOSING_PERIOD + bool extended; +} + +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); + function PROPOSAL_THRESHOLD() external view returns (uint256); + function VOTING_DELAY() external view returns (uint256); + 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 execute(uint256 proposalId) external payable; +} diff --git a/src/common/test/Common.sol b/src/common/test/Common.sol new file mode 100644 index 0000000..43ec321 --- /dev/null +++ b/src/common/test/Common.sol @@ -0,0 +1,34 @@ +pragma solidity ^0.8.20; + +contract Common { + uint256 constant TEST_PRIVATE_KEY_ONE = 0x66ddbd7cbe4a566df405f6ded0b908c669f88cdb1656380c050e3a457bd21df0; + uint256 constant TEST_PRIVATE_KEY_TWO = 0xa4c8c98120e77741a87a116074a2df4ddb20d1149069290fd4a3d7ee65c55064; + address constant TEST_ADDRESS_ONE = 0x118251976c65AFAf291f5255450ddb5b6A4d8B88; + address constant TEST_ADDRESS_TWO = 0x63aE7d90Eb37ca39FC62dD9991DbEfeE70673a20; + + address constant ADDRESS_TO_STAKE = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045; + uint256 constant STAKE_AMOUNT = 100_000 ether; + + uint256 constant PROPOSAL_DURATION = 7 days; + uint256 constant PROPOSAL_THRESHOLD = 25000 ether; + string constant PROPOSAL_DESCRIPTION = + "{title:'Proposal #22: Test clone of 21 proposal: change locked stake balance directly',description:''}"; + + address constant VERIFIER_ADDRESS = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C; + + bytes32 constant PERMIT_TYPEHASH = + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); + + bytes32 constant EIP712_DOMAIN = keccak256( + abi.encode( + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256(bytes("TornadoCash")), + keccak256(bytes("1")), + 1, + VERIFIER_ADDRESS + ) + ); + + uint16 constant PERMIT_FUNC_SELECTOR = uint16(0x1901); +} + diff --git a/test/Counter.t.sol b/test/Counter.t.sol deleted file mode 100644 index 30235e8..0000000 --- a/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "forge-std/Test.sol"; -import "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function testIncrement() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testSetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -}