From d7bbaca89be33090b4abf318f6858ecf42a6dd38 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Thu, 25 Sep 2025 08:29:59 -0700 Subject: [PATCH 1/4] feat: Add _addToUsersByType Internal Function --- src/IdentityManagerV2.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/IdentityManagerV2.sol b/src/IdentityManagerV2.sol index f98ab14..40600de 100644 --- a/src/IdentityManagerV2.sol +++ b/src/IdentityManagerV2.sol @@ -551,4 +551,9 @@ contract IdentityManagerV2 is AccessControl, ReentrancyGuard, Pausable { verifiedUsers.pop(); delete verifiedUserPositions[user]; } + + function _addToUsersByType(address user, UserType userType) internal { + userPositions[userType][user] = usersByType[userType].length; + usersByType[userType].push(user); + } } From 2828cd6c243877b4509751f2c971cb1b8a23c6f8 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Thu, 25 Sep 2025 08:30:17 -0700 Subject: [PATCH 2/4] feat: Add _addToUsersByType Internal Function Natspec Comments --- src/IdentityManagerV2.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/IdentityManagerV2.sol b/src/IdentityManagerV2.sol index 40600de..14ee939 100644 --- a/src/IdentityManagerV2.sol +++ b/src/IdentityManagerV2.sol @@ -552,6 +552,9 @@ contract IdentityManagerV2 is AccessControl, ReentrancyGuard, Pausable { delete verifiedUserPositions[user]; } + /** + * @notice Adds user to user type list + */ function _addToUsersByType(address user, UserType userType) internal { userPositions[userType][user] = usersByType[userType].length; usersByType[userType].push(user); From 4ab8a6cc2448fe4f094796ce8dbd559956ca0698 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Thu, 25 Sep 2025 08:30:49 -0700 Subject: [PATCH 3/4] feat: Add _removeFromUsersByType Internal Function --- src/IdentityManagerV2.sol | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/IdentityManagerV2.sol b/src/IdentityManagerV2.sol index 14ee939..e51bb64 100644 --- a/src/IdentityManagerV2.sol +++ b/src/IdentityManagerV2.sol @@ -559,4 +559,18 @@ contract IdentityManagerV2 is AccessControl, ReentrancyGuard, Pausable { userPositions[userType][user] = usersByType[userType].length; usersByType[userType].push(user); } + + function _removeFromUsersByType(address user, UserType userType) internal { + uint256 position = userPositions[userType][user]; + uint256 lastPosition = usersByType[userType].length - 1; + + if (position != lastPosition) { + address lastUser = usersByType[userType][lastPosition]; + usersByType[userType][position] = lastUser; + userPositions[userType][lastUser] = position; + } + + usersByType[userType].pop(); + delete userPositions[userType][user]; + } } From efcd26f5a6aea585b4627dacda6f133012981d51 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Thu, 25 Sep 2025 08:31:08 -0700 Subject: [PATCH 4/4] feat: Add _removeFromUsersByType Internal Function Natspec Comment --- src/IdentityManagerV2.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/IdentityManagerV2.sol b/src/IdentityManagerV2.sol index e51bb64..10fe07b 100644 --- a/src/IdentityManagerV2.sol +++ b/src/IdentityManagerV2.sol @@ -560,6 +560,9 @@ contract IdentityManagerV2 is AccessControl, ReentrancyGuard, Pausable { usersByType[userType].push(user); } + /** + * @notice Removes user from user type list + */ function _removeFromUsersByType(address user, UserType userType) internal { uint256 position = userPositions[userType][user]; uint256 lastPosition = usersByType[userType].length - 1;