Skip to content

Commit

Permalink
fix cyclomatic-complexity in solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Jan 10, 2025
1 parent ffe4e6e commit f607131
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions contracts/verifiers/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
// 1. Check first that groupIds don't exist and keep the number of requests per group.
for (uint256 i = 0; i < requests.length; i++) {
uint256 groupID = requests[i].validator.getRequestParams(requests[i].params).groupID;


if (groupID != 0) {
if (groupIdExists(groupID)) {
Expand All @@ -272,13 +271,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {

// 2. Set requests checking groups and nullifierSessionID uniqueness
for (uint256 i = 0; i < requests.length; i++) {
uint256 nullifierSessionID = requests[i].validator.getRequestParams(requests[i].params).nullifierSessionID;
if (nullifierSessionID != 0) {
if (s._nullifierSessionIDs[nullifierSessionID] != 0) {
revert NullifierSessionIDAlreadyExists(nullifierSessionID);
}
s._nullifierSessionIDs[nullifierSessionID] = requests[i].requestId;
}
_checkNullifierSessionIdUniqueness(requests[i]);

uint256 groupID = requests[i].validator.getRequestParams(requests[i].params).groupID;

Expand All @@ -297,6 +290,20 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
}
}

function _checkNullifierSessionIdUniqueness(IVerifier.Request calldata request) internal {
VerifierStorage storage s = _getVerifierStorage();
uint256 nullifierSessionID = request
.validator
.getRequestParams(request.params)
.nullifierSessionID;
if (nullifierSessionID != 0) {
if (s._nullifierSessionIDs[nullifierSessionID] != 0) {
revert NullifierSessionIDAlreadyExists(nullifierSessionID);
}
s._nullifierSessionIDs[nullifierSessionID] = request.requestId;
}
}

function _getGroupIDIndex(
uint256 groupID,
uint256[] memory groupList,
Expand Down

0 comments on commit f607131

Please sign in to comment.