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

Moloch rage quit #32

Open
wants to merge 28 commits into
base: moloch-rage-quit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c32ae3e
add Moloch Rage Quit challenge description
KcPele May 30, 2024
f335446
add Moloch Rage Quit challenge description
KcPele May 30, 2024
adcf396
simple challange
KcPele May 30, 2024
2fb44ed
simple challange solution
KcPele May 30, 2024
a512149
complex challenge
KcPele May 30, 2024
787309d
added some test
KcPele May 30, 2024
0af893c
added some test
KcPele May 31, 2024
7f6d4ca
completed test
KcPele Jun 1, 2024
8a9c30c
feat: complete smart contract test
KcPele Jun 1, 2024
b248d9a
feat: complete smart contract test
KcPele Jun 1, 2024
accb922
feat: complete smart contract test
KcPele Jun 1, 2024
5825570
fix:resolved errors and made changes
KcPele Jun 4, 2024
f6c4832
updated contract
KcPele Jun 19, 2024
0b42398
updated contract
KcPele Jun 19, 2024
3bfee27
updated contract
KcPele Jun 19, 2024
5467799
test for proposal creation
KcPele Jul 9, 2024
d76f4f7
fix:executeProposal
KcPele Jul 9, 2024
04117ae
fix:addMember and removeMember
KcPele Jul 9, 2024
1714fda
fix:addMember and removeMember
KcPele Jul 9, 2024
aaf7327
fix:addMember and removeMember
KcPele Jul 9, 2024
1d39abe
fix:proposal creation
KcPele Jul 9, 2024
19c2d05
fix:proposal creation
KcPele Jul 9, 2024
51dc03f
fix:contract execution
KcPele Jul 9, 2024
eea0065
fix:contract execution
KcPele Jul 9, 2024
a87fe85
fix:added test and fixed addMember function
KcPele Jul 18, 2024
59f2654
fix:added test and fixed addMember function
KcPele Jul 18, 2024
610bdff
fix:rageQuite
KcPele Jul 18, 2024
cbcd8b0
fix:rageQuite
KcPele Jul 18, 2024
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
25 changes: 0 additions & 25 deletions packages/foundry/contracts/MaliciousContract.sol
KcPele marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

30 changes: 3 additions & 27 deletions packages/foundry/contracts/MolochRageQuit.sol
KcPele marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

////////////////////
// Imports
////////////////////
import "@openzeppelin/contracts/access/Ownable.sol";

////////////////////
Copy link
Collaborator

Choose a reason for hiding this comment

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

These errors should be defined inside the contract. I realize the layout guidelines are confusing as it lists contracts below errors but what this means is contracts variables defined inside the contract.

// Errors
Expand All @@ -25,7 +21,7 @@ error MemberExists();
////////////////////
KcPele marked this conversation as resolved.
Show resolved Hide resolved
// Contract
////////////////////
contract MolochRageQuit is Ownable {
contract MolochRageQuit {
///////////////////
// Type Declarations
///////////////////
Expand Down Expand Up @@ -214,7 +210,7 @@ contract MolochRageQuit is Ownable {
* - Mark the address as a member.
* Emits a `MemberAdded` event.
*/
function addMember(address newMember) external onlyOwner {
function addMember(address newMember) external {
if (members[newMember]) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is the only thing keeping someone from executing the proposal multiple times. But what if I get in at a low share price and Rage Quit at a high share price? Then I can become a member again at my low share price by reexecuting my old proposal! I could do this over and over until the contract was drained.

revert MemberExists();
}
Expand All @@ -230,28 +226,8 @@ contract MolochRageQuit is Ownable {
* - Mark the member as not a member.
* Emits an `MemberRemoved` event.
*/
function removeMember(address member) external onlyOwner {
function removeMember(address member) external {
members[member] = false;
emit MemberRemoved(member);
}

/**
* @dev Withdraw ETH from the DAO.
* @param amount The amount of ETH to withdraw.
* Requirements:
* - Only callable by the owner.
* - Revert with `InsufficientETH` if the amount exceeds the contract's balance.
* - Revert with `FailedTransfer` if the transfer fails.
*/
function withdraw(uint256 amount) public onlyOwner {
if (amount > address(this).balance) {
revert InsufficientETH();
}
(bool sent, ) = payable(msg.sender).call{value: amount}("");
if (!sent) {
revert FailedTransfer();
}

emit Withdrawal(msg.sender, amount);
}
}
16 changes: 0 additions & 16 deletions packages/foundry/test/MolochRageQuit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,6 @@ contract MolochRageQuitTest is Test {
dao.vote(1);
}

//Test that the Withdrawal event is emitted
function testWithdraw() public {
// Setup proposal and voting
dao.propose(PROPOSAL_AMOUNT, PROPOSAL_SHARES);
dao.vote(1);
vm.prank(member1);
dao.vote(1);
dao.exchangeShares{value: PROPOSAL_AMOUNT}(1);
// Ensure DAO contract has the ETH
assertEq(address(dao).balance, PROPOSAL_AMOUNT);
vm.expectEmit(true, true, true, true);
emit Withdrawal(owner, 0.2 ether);
dao.withdraw(0.2 ether);
assertEq(address(dao).balance, PROPOSAL_AMOUNT - 0.2 ether);
}

// Function to receive Ether. msg.data must be empty
receive() external payable {}

Expand Down