Skip to content

Conversation

@2PykeETH
Copy link

Summary

This PR introduces two new internal utility functions to IdentityManagerV2 that handle user tracking by type. These functions improve how the contract manages categorized users, ensuring consistent updates to internal mappings and arrays.


Changes

  • Added _addToUsersByType

    • Associates a user with a specific UserType
    • Tracks the user’s position in the usersByType array
    • Ensures efficient appending and retrieval
  • Added _removeFromUsersByType

    • Removes a user from a UserType list while maintaining array compactness
    • Updates userPositions mapping for O(1) lookups
    • Cleans up state by deleting the user’s position record
  • Natspec comments for both functions for improved readability and documentation.


Benefits

  • Provides modular internal helpers for managing users by type
  • Ensures efficient array manipulation (swap-and-pop pattern)
  • Simplifies logic for higher-level functions that depend on user categorization
  • Improves maintainability with clear Natspec documentation

Next Steps

  • Integrate _addToUsersByType and _removeFromUsersByType into the verification and de-verification flows
  • Add unit tests to confirm correct state management when users are added/removed across different types
  • Extend stats tracking to leverage these helpers for more robust reporting

Notes

These changes set the foundation for scalable identity management, where users may be grouped by type for permissions, analytics, or governance logic.

@SynnekOG SynnekOG self-requested a review September 25, 2025 15:34
@SynnekOG SynnekOG added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 25, 2025
@SynnekOG SynnekOG merged commit 6cbd067 into CrediChain:main Sep 25, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants