Skip to content

Commit

Permalink
simplified isWithinAllowedRange
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfingNerd committed Jun 17, 2024
1 parent 3911cd4 commit f525e16
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions contracts/ValueGuards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,15 @@ contract ValueGuards is OwnableUpgradeable {
if (allowedRange.range.length == 0) return false;
uint256[] memory range = allowedRange.range;
uint256 currVal = _getValueWithSelector(allowedRange.getter);
bool currValFound = false;

for (uint256 i = 0; i < range.length; i++) {
if (range[i] == currVal) {
currValFound = true;
uint256 leftVal = (i > 0) ? range[i - 1] : range[0];
uint256 rightVal = (i < range.length - 1) ? range[i + 1] : range[range.length - 1];
if (newVal != leftVal && newVal != rightVal) return false;
break;
return !(newVal != leftVal && newVal != rightVal);
}
}
return currValFound;
return false;
}

function getAllowedParamsRange(string memory _selector) external view returns (ParameterRange memory) {
Expand Down

0 comments on commit f525e16

Please sign in to comment.