Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
DuplicateSubmission
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrajath committed Dec 17, 2023
1 parent 4e647ad commit 171469d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
13 changes: 5 additions & 8 deletions src/token-voting/LlamaTokenCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,15 @@ contract LlamaTokenCaster is Initializable {
/// @dev Thrown when a user tries to cast a vote but has already casted.
error AlreadyCastedVote();

/// @dev Thrown when a user tries to cast approval but the casts have already been submitted to `LlamaCore`.
error AlreadySubmittedApproval();

/// @dev Thrown when a user tries to cast disapproval but the casts have already been submitted to `LlamaCore.
error AlreadySubmittedDisapproval();

/// @dev Thrown when a user tries to cast (dis)approval but the action cannot be submitted yet.
error CannotSubmitYet();

/// @dev Thrown when a user tries to cast a vote or veto but the casting period has ended.
error CastingPeriodOver();

/// @dev Thrown when a user tries to submit a cast (dis)approval to `LlamaCore` more than once.
error DuplicateSubmission();

/// @dev Thrown when a user tries to cast a vote or veto but the against surpasses for.
error ForDoesNotSurpassAgainst(uint256 castsFor, uint256 castsAgainst);

Expand Down Expand Up @@ -315,7 +312,7 @@ contract LlamaTokenCaster is Initializable {
function submitApproval(ActionInfo calldata actionInfo) external {
Action memory action = llamaCore.getAction(actionInfo.id);

if (casts[actionInfo.id].approvalSubmitted) revert AlreadySubmittedApproval();
if (casts[actionInfo.id].approvalSubmitted) revert DuplicateSubmission();
// Reverts if clock or CLOCK_MODE() has changed
tokenAdapter.checkIfInconsistentClock();

Expand Down Expand Up @@ -351,7 +348,7 @@ contract LlamaTokenCaster is Initializable {
function submitDisapproval(ActionInfo calldata actionInfo) external {
Action memory action = llamaCore.getAction(actionInfo.id);

if (casts[actionInfo.id].disapprovalSubmitted) revert AlreadySubmittedDisapproval();
if (casts[actionInfo.id].disapprovalSubmitted) revert DuplicateSubmission();
// Reverts if clock or CLOCK_MODE() has changed
tokenAdapter.checkIfInconsistentClock();

Expand Down
4 changes: 2 additions & 2 deletions test/token-voting/LlamaERC20TokenCaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ contract SubmitApprovals is LlamaERC20TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC20TokenCaster.submitApproval(actionInfo);

vm.expectRevert(LlamaTokenCaster.AlreadySubmittedApproval.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateSubmission.selector);
llamaERC20TokenCaster.submitApproval(actionInfo);
}

Expand Down Expand Up @@ -717,7 +717,7 @@ contract SubmitDisapprovals is LlamaERC20TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC20TokenCaster.submitDisapproval(actionInfo);

vm.expectRevert(LlamaTokenCaster.AlreadySubmittedDisapproval.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateSubmission.selector);
llamaERC20TokenCaster.submitDisapproval(actionInfo);
}

Expand Down
4 changes: 2 additions & 2 deletions test/token-voting/LlamaERC721TokenCaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ contract SubmitApprovals is LlamaERC721TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC721TokenCaster.submitApproval(actionInfo);

vm.expectRevert(LlamaTokenCaster.AlreadySubmittedApproval.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateSubmission.selector);
llamaERC721TokenCaster.submitApproval(actionInfo);
}

Expand Down Expand Up @@ -667,7 +667,7 @@ contract SubmitDisapprovals is LlamaERC721TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC721TokenCaster.submitDisapproval(actionInfo);

vm.expectRevert(LlamaTokenCaster.AlreadySubmittedDisapproval.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateSubmission.selector);
llamaERC721TokenCaster.submitDisapproval(actionInfo);
}

Expand Down

0 comments on commit 171469d

Please sign in to comment.