registerAccessLevels
```remix-solidity
/**
* @notice Register new access levels for an event, including ticket price, access level name, and whitelist status.
* @dev This function allows event managers to add new access levels to their events.
* It verifies that the caller is an event manager, checks for existing access levels,
* and updates the mappings with the new access level information.
*
* @param _eventId The unique identifier for the event.
* @param _newAccessLevels An array of names for the new access levels.
* @param _newTicketPrices An array of ticket prices for the new access levels, corresponding to the names.
* @param _newWhitelists An array of booleans indicating whether each new access level requires whitelisting.
*
* Requirements:
* - The length of `_newAccessLevels`, `_newTicketPrices`, and `_newWhitelists` must be the same.
* - The caller must be an event manager for the event specified by `_eventId`.
* - Each access level name in `_newAccessLevels` must not already exist for the event.
*
* Format: eventId, accessLevel, ticketPrice, isWhitelisted
*/
function registerAccessLevels(
string calldata _eventId,
string[] calldata _newAccessLevels,
uint256[] calldata _newTicketPrices,
bool[] calldata _newWhitelists
) public {
// Ensure all input arrays have the same length
if (
_newAccessLevels.length != _newTicketPrices.length ||
_newTicketPrices.length != _newWhitelists.length ||
_newAccessLevels.length != _newWhitelists.length
) revert();
// Check if the caller is an event manager
if (!checkIfCallerIsEventManager(_eventId, _msgSender()))
revert DecastGating__UserIsNotAnEventManager();
for (uint256 i = 0; i < _newAccessLevels.length; ++i) {
// Check if the access level already exists for the event
if (checkAccessLevelExists(_eventId, _newAccessLevels[i]))
revert DecastGating__AccessLevelAlreadyExists();
// Generate a new token ID for the access level
uint256 tokenId = generateTokenId(
_eventId,
_msgSender(),
_newAccessLevels[i]
);
// Update mappings with the new access level information
s_eventIdToTokenIds[_eventId].push(tokenId);
s_eventIdToAccessLevels[_eventId].push(_newAccessLevels[i]);
s_tokenIdToTicketPrice[tokenId] = _newTicketPrices[i];
s_tokenIdToWhitelist[tokenId] = _newWhitelists[i];
}
}
```Explanation:
Last updated