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

Commit

Permalink
DuplicateCast
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrajath committed Dec 17, 2023
1 parent aaa93f8 commit 000f432
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions src/token-voting/LlamaTokenCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ contract LlamaTokenCaster is Initializable {
/// @dev Thrown when a user tries to cast a veto but the action is not queued.
error ActionNotQueued();

/// @dev Thrown when a user tries to cast a veto but has already casted.
error AlreadyCastedVeto();

/// @dev Thrown when a user tries to cast a vote but has already casted.
error AlreadyCastedVote();

/// @dev Thrown when a user tries to submit (dis)approval but the casting period has not ended.
error CastingPeriodNotOver();

Expand All @@ -67,6 +61,9 @@ contract LlamaTokenCaster is Initializable {
/// @dev Thrown when a user tries to cast a vote or veto but the delay period has not ended.
error DelayPeriodNotOver();

/// @dev Token holders can only cast once.
error DuplicateCast();

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

Expand All @@ -76,7 +73,9 @@ contract LlamaTokenCaster is Initializable {
/// @dev Thrown when a user tries to submit an approval but there are not enough votes.
error InsufficientVotes(uint256 votes, uint256 threshold);

/// @dev Thrown when a user tries to query checkpoints at non-existant indices.
/// @dev The indices would result in `Panic: Index Out of Bounds`.
/// @dev Thrown when the `end` index is greater than array length or when the `start` index is greater than the `end`
/// index.
error InvalidIndices();

/// @dev Thrown when an invalid `llamaCore` address is passed to the constructor.
Expand Down Expand Up @@ -492,7 +491,7 @@ contract LlamaTokenCaster is Initializable {

actionInfo.strategy.checkIfApprovalEnabled(actionInfo, address(this), role); // Reverts if not allowed.
if (llamaCore.getActionState(actionInfo) != uint8(ActionState.Active)) revert ActionNotActive();
if (casts[actionInfo.id].castVote[caster]) revert AlreadyCastedVote();
if (casts[actionInfo.id].castVote[caster]) revert DuplicateCast();
_preCastAssertions(support);

// Checks to ensure it's the casting period.
Expand Down Expand Up @@ -529,7 +528,7 @@ contract LlamaTokenCaster is Initializable {

actionInfo.strategy.checkIfDisapprovalEnabled(actionInfo, address(this), role); // Reverts if not allowed.
if (llamaCore.getActionState(actionInfo) != uint8(ActionState.Queued)) revert ActionNotQueued();
if (casts[actionInfo.id].castVeto[caster]) revert AlreadyCastedVeto();
if (casts[actionInfo.id].castVeto[caster]) revert DuplicateCast();
_preCastAssertions(support);

// Checks to ensure it's the casting period.
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 @@ -145,7 +145,7 @@ contract CastVote is LlamaERC20TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC20TokenCaster.castVote(actionInfo, uint8(VoteType.For), "");

vm.expectRevert(LlamaTokenCaster.AlreadyCastedVote.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateCast.selector);
llamaERC20TokenCaster.castVote(actionInfo, uint8(VoteType.For), "");
}

Expand Down Expand Up @@ -378,7 +378,7 @@ contract CastVeto is LlamaERC20TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC20TokenCaster.castVeto(actionInfo, uint8(VoteType.For), "");

vm.expectRevert(LlamaTokenCaster.AlreadyCastedVeto.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateCast.selector);
llamaERC20TokenCaster.castVeto(actionInfo, uint8(VoteType.For), "");
}

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 @@ -149,7 +149,7 @@ contract CastVote is LlamaERC721TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC721TokenCaster.castVote(actionInfo, uint8(VoteType.For), "");

vm.expectRevert(LlamaTokenCaster.AlreadyCastedVote.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateCast.selector);
llamaERC721TokenCaster.castVote(actionInfo, uint8(VoteType.For), "");
}

Expand Down Expand Up @@ -356,7 +356,7 @@ contract CastVeto is LlamaERC721TokenCasterTest {
vm.startPrank(tokenHolder1);
llamaERC721TokenCaster.castVeto(actionInfo, uint8(VoteType.For), "");

vm.expectRevert(LlamaTokenCaster.AlreadyCastedVeto.selector);
vm.expectRevert(LlamaTokenCaster.DuplicateCast.selector);
llamaERC721TokenCaster.castVeto(actionInfo, uint8(VoteType.For), "");
}

Expand Down

0 comments on commit 000f432

Please sign in to comment.