Skip to content

Commit 6cbd067

Browse files
author
malgusss
authored
Merge pull request #60 from tyranis0x01/main
feat: add internal user type management functions to IdentityManagerV2
2 parents 2aa42ed + efcd26f commit 6cbd067

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/IdentityManagerV2.sol

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,29 @@ contract IdentityManagerV2 is AccessControl, ReentrancyGuard, Pausable {
551551
verifiedUsers.pop();
552552
delete verifiedUserPositions[user];
553553
}
554+
555+
/**
556+
* @notice Adds user to user type list
557+
*/
558+
function _addToUsersByType(address user, UserType userType) internal {
559+
userPositions[userType][user] = usersByType[userType].length;
560+
usersByType[userType].push(user);
561+
}
562+
563+
/**
564+
* @notice Removes user from user type list
565+
*/
566+
function _removeFromUsersByType(address user, UserType userType) internal {
567+
uint256 position = userPositions[userType][user];
568+
uint256 lastPosition = usersByType[userType].length - 1;
569+
570+
if (position != lastPosition) {
571+
address lastUser = usersByType[userType][lastPosition];
572+
usersByType[userType][position] = lastUser;
573+
userPositions[userType][lastUser] = position;
574+
}
575+
576+
usersByType[userType].pop();
577+
delete userPositions[userType][user];
578+
}
554579
}

0 commit comments

Comments
 (0)