From 171469d1076139dec79ea257e9e6ee8013f81e0b Mon Sep 17 00:00:00 2001 From: Rajath Alex Date: Sun, 17 Dec 2023 18:16:35 -0500 Subject: [PATCH] DuplicateSubmission --- src/token-voting/LlamaTokenCaster.sol | 13 +++++-------- test/token-voting/LlamaERC20TokenCaster.t.sol | 4 ++-- test/token-voting/LlamaERC721TokenCaster.t.sol | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/token-voting/LlamaTokenCaster.sol b/src/token-voting/LlamaTokenCaster.sol index 9180140..072bfaf 100644 --- a/src/token-voting/LlamaTokenCaster.sol +++ b/src/token-voting/LlamaTokenCaster.sol @@ -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); @@ -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(); @@ -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(); diff --git a/test/token-voting/LlamaERC20TokenCaster.t.sol b/test/token-voting/LlamaERC20TokenCaster.t.sol index a7c32e5..011eb6f 100644 --- a/test/token-voting/LlamaERC20TokenCaster.t.sol +++ b/test/token-voting/LlamaERC20TokenCaster.t.sol @@ -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); } @@ -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); } diff --git a/test/token-voting/LlamaERC721TokenCaster.t.sol b/test/token-voting/LlamaERC721TokenCaster.t.sol index 62bec13..36e5dda 100644 --- a/test/token-voting/LlamaERC721TokenCaster.t.sol +++ b/test/token-voting/LlamaERC721TokenCaster.t.sol @@ -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); } @@ -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); }