diff --git a/src/plasa/Plasa.sol b/src/plasa/Plasa.sol index 4d35915..8390520 100644 --- a/src/plasa/Plasa.sol +++ b/src/plasa/Plasa.sol @@ -49,4 +49,39 @@ contract Plasa is Ownable, IPlasa { function getUsername(address user) public view returns (string memory) { return names.userToName(user); } + + /** + * @dev Retrieves the usernames associated with an array of user addresses. + * @param users The addresses of the users whose usernames are to be retrieved. + * @return string[] memory An array of usernames corresponding to the input addresses. + */ + function getUsernames(address[] memory users) public view returns (string[] memory) { + string[] memory usernames = new string[](users.length); + for (uint256 i = 0; i < users.length; i++) { + usernames[i] = getUsername(users[i]); + } + return usernames; + } + + /** + * @dev Retrieves the username data associated with a given user address. + * @param user The address of the user whose username data is to be retrieved. + * @return UsernameData memory The username data of the user. + */ + function getUsernameData(address user) public view returns (UsernameData memory) { + return UsernameData({ user: user, name: getUsername(user) }); + } + + /** + * @dev Retrieves the username data associated with an array of user addresses. + * @param users The addresses of the users whose username data is to be retrieved. + * @return UsernameData[] memory An array of UsernameData structures corresponding to the input addresses. + */ + function getUsernamesData(address[] memory users) public view returns (UsernameData[] memory) { + UsernameData[] memory usernameData = new UsernameData[](users.length); + for (uint256 i = 0; i < users.length; i++) { + usernameData[i] = getUsernameData(users[i]); + } + return usernameData; + } } diff --git a/src/plasa/interfaces/IPlasa.sol b/src/plasa/interfaces/IPlasa.sol index 07e34a3..ab3d433 100644 --- a/src/plasa/interfaces/IPlasa.sol +++ b/src/plasa/interfaces/IPlasa.sol @@ -6,6 +6,14 @@ import { INames } from "../../names/INames.sol"; /// @title IPlasa Interface /// @dev This interface defines the functions for user registration and username retrieval in the Plasa system. interface IPlasa { + /// @notice Struct to hold username data. + /// @param user The address of the user. + /// @param name The username of the user. + struct UsernameData { + address user; + string name; + } + /// @notice Checks if a user is registered in the Plasa system. /// @param user The address of the user to check. /// @return bool Returns true if the user is registered, false otherwise. @@ -23,4 +31,14 @@ interface IPlasa { /// @notice The names contract interface. /// @return INames Returns the names contract. function names() external view returns (INames); + + /// @notice Retrieves the username data associated with an array of user addresses. + /// @param user The address of the user whose username is to be retrieved. + /// @return UsernameData The username data of the user. + function getUsernameData(address user) external view returns (UsernameData memory); + + /// @notice Retrieves the usernames associated with an array of user addresses. + /// @param users The addresses of the users whose usernames are to be retrieved. + /// @return UsernameData[] memory An array of UsernameData structures corresponding to the input addresses. + function getUsernamesData(address[] memory users) external view returns (UsernameData[] memory); }