Skip to content

Commit

Permalink
chore: Rename Tx to Proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
samperkinsdev committed Sep 4, 2023
1 parent 577ec18 commit cc729c0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Chamber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ contract Chamber is IChamber, LinkedList, ReentrancyGuard, Context, ERC721Holder
}

/// @inheritdoc IChamber
function createTx(address[] memory _target, uint256[] memory _value, bytes[] memory _data) external {
function createProposal(address[] memory _target, uint256[] memory _value, bytes[] memory _data) external {
if(IERC721(memberToken).balanceOf(_msgSender()) < 1) revert insufficientBalance();

proposalCount++;
Expand All @@ -143,7 +143,7 @@ contract Chamber is IChamber, LinkedList, ReentrancyGuard, Context, ERC721Holder
}

/// @inheritdoc IChamber
function approveTx(uint256 _proposalId, uint256 _tokenId) external {
function approveProposal(uint256 _proposalId, uint256 _tokenId) external {
if(_msgSender() != IERC721(memberToken).ownerOf(_tokenId)) revert invalidApproval("Sender isn't owner");
if(proposals[_proposalId].state != State.Initialized) revert invalidApproval("Proposal isn't Initialized");
if(voted[_proposalId][_tokenId]) revert invalidApproval("TokenID aleready voted");
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/IChamber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ interface IChamber {
* @param _proposalId The ID of the proposal to approve
* @param _tokenId The ID of the NFT to vote
*/
function approveTx(uint256 _proposalId, uint256 _tokenId) external;
function approveProposal(uint256 _proposalId, uint256 _tokenId) external;

/**
* @notice create Proposal function
* @param _target The address of contract to send transaction
* @param _value The uint256 amount of ETH to send with transaction
* @param _data The bytes[] of transaction data
*/
function createTx(address[] memory _target, uint256[] memory _value, bytes[] memory _data) external;
function createProposal(address[] memory _target, uint256[] memory _value, bytes[] memory _data) external;

/**
* @notice Stakes a given amount of "stakingToken" against the provided NFT ID
Expand Down
8 changes: 4 additions & 4 deletions test/Chamber.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ contract ChamberTest is Test, TestUtilities {
valueArray[2] = 10 ether;
valueArray[3] = 5 ether;

chamber.createTx(targetArray, valueArray, dataArray);
chamber.createProposal(targetArray, valueArray, dataArray);

// Approve Proposal

chamber.approveTx(1, 3);
chamber.approveTx(1, 2);
chamber.approveProposal(1, 3);
chamber.approveProposal(1, 2);

// Execute Proposal

chamber.approveTx(1, 1);
chamber.approveProposal(1, 1);

}

Expand Down
20 changes: 10 additions & 10 deletions test/lifecycle/ProposalCycle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ contract ProposalTest is Test {
targetArray1[0] = address(chamber);
valueArray1[0] = 1 ether;

chamber.createTx(targetArray1, valueArray1, dataArray1);
chamber.createProposal(targetArray1, valueArray1, dataArray1);
assertEq(chamber.proposalCount(), 1);

// 2. nft holder without stake should not be able to approve transaction
vm.expectRevert();
chamber.approveTx(1, 8);
chamber.approveProposal(1, 8);

// 3. nft holder should not be able to approve transaction using unowned tokenId
vm.expectRevert();
chamber.approveTx(1, 5);
chamber.approveProposal(1, 5);

vm.stopPrank();

Expand Down Expand Up @@ -167,33 +167,33 @@ contract ProposalTest is Test {
valueArray[5] = 0;
valueArray[6] = 0;

chamber.createTx(targetArray, valueArray, dataArray);
chamber.createProposal(targetArray, valueArray, dataArray);
assertEq(chamber.proposalCount(), 2);
(votes, state) = chamber.proposals(2);
assertEq(votes, 0);
assertTrue(state == IChamber.State.Initialized);

// 4. nft holder should not be able to approve if not a leader
vm.expectRevert();
chamber.approveTx(1, 1);
chamber.approveProposal(1, 1);
vm.stopPrank();

// 5. Leaders should be able to approve transaction
vm.prank(danny);
chamber.approveTx(2, 5);
chamber.approveProposal(2, 5);
(votes, state) = chamber.proposals(2);
assertEq(votes, 1);
assertTrue(state == IChamber.State.Initialized);

vm.prank(shifty);
chamber.approveTx(2, 6);
chamber.approveProposal(2, 6);
(votes, state) = chamber.proposals(2);
assertEq(votes, 2);
assertTrue(state == IChamber.State.Initialized);

// 6. Quorum of leaders should execute proposal
vm.prank(blackbeard);
chamber.approveTx(2, 7);
chamber.approveProposal(2, 7);
(votes, state) = chamber.proposals(2);
assertEq(votes, 3);
assertTrue(state == IChamber.State.Executed);
Expand All @@ -211,14 +211,14 @@ contract ProposalTest is Test {
assertEq(chamber.getUserStakeIndividualNFT(bones, 1), 43333 ether);

vm.expectRevert();
chamber.approveTx(1, 1);
chamber.approveProposal(1, 1);
vm.stopPrank();

// 8. nft holder that unstaked erc20 should be able to approve
vm.startPrank(jack);
chamber.unstake(33333 ether, 4);
helperLogger();
chamber.approveTx(1, 4);
chamber.approveProposal(1, 4);
vm.stopPrank();
}
}

0 comments on commit cc729c0

Please sign in to comment.