Skip to content

Commit

Permalink
Opti equality with FALSE rather than TRUE (#225)
Browse files Browse the repository at this point in the history
* chore: initial snapshots

* opti: use == FALSE for onlyAuthenticator

* opti: use inequality with FALSE rather than true in signature verifier

* opti: use false inequality in SpaceManager.sol
  • Loading branch information
pscott authored Jun 27, 2023
1 parent 3bc77f3 commit b063080
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/ProposeSigComp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148834
148832
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteSigComp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50277
50313
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteSigCompMetadata.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51827
51856
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteTxComp.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43824
43883
2 changes: 1 addition & 1 deletion .forge-snapshots/VoteTxCompMetadata.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
45415
45467
4 changes: 2 additions & 2 deletions src/Space.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract Space is ISpace, Initializable, IERC4824, UUPSUpgradeable, OwnableUpgra

/// @dev Gates access to whitelisted authenticators only.
modifier onlyAuthenticator() {
if (authenticators[msg.sender] != TRUE) revert AuthenticatorNotWhitelisted();
if (authenticators[msg.sender] == FALSE) revert AuthenticatorNotWhitelisted();
_;
}

Expand Down Expand Up @@ -252,7 +252,7 @@ contract Space is ISpace, Initializable, IERC4824, UUPSUpgradeable, OwnableUpgra
if (block.number >= proposal.maxEndBlockNumber) revert VotingPeriodHasEnded();
if (block.number < proposal.startBlockNumber) revert VotingPeriodHasNotStarted();
if (proposal.finalizationStatus != FinalizationStatus.Pending) revert ProposalFinalized();
if (voteRegistry[proposalId][voter] == TRUE) revert UserAlreadyVoted();
if (voteRegistry[proposalId][voter] != FALSE) revert UserAlreadyVoted();

voteRegistry[proposalId][voter] = TRUE;

Expand Down
4 changes: 2 additions & 2 deletions src/utils/SignatureVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract contract SignatureVerifier is EIP712 {
bytes memory userProposalValidationParams
) = abi.decode(data, (address, string, Strategy, bytes));

if (usedSalts[author][salt] == TRUE) revert SaltAlreadyUsed();
if (usedSalts[author][salt] != FALSE) revert SaltAlreadyUsed();

address recoveredAddress = ECDSA.recover(
_hashTypedDataV4(
Expand Down Expand Up @@ -129,7 +129,7 @@ abstract contract SignatureVerifier is EIP712 {
(address, uint256, Strategy, string)
);

if (usedSalts[author][salt] == TRUE) revert SaltAlreadyUsed();
if (usedSalts[author][salt] != FALSE) revert SaltAlreadyUsed();

address recoveredAddress = ECDSA.recover(
_hashTypedDataV4(
Expand Down
2 changes: 1 addition & 1 deletion src/utils/SpaceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract SpaceManager is OwnableUpgradeable {
/// @notice Enable a space.
/// @param space Address of the space.
function enableSpace(address space) external onlyOwner {
if (space == address(0) || (spaces[space] == TRUE)) revert InvalidSpace();
if (space == address(0) || (spaces[space] != FALSE)) revert InvalidSpace();
spaces[space] = TRUE;
emit SpaceEnabled(space);
}
Expand Down

0 comments on commit b063080

Please sign in to comment.