setMintingApproval

This function grants minting approval for tickets to specified recipients for existing events and access levels.

It takes four arguments:

  • _eventIds: An array containing unique identifiers for events.

  • _to: An array containing wallet addresses of recipients receiving minting approval.

  • _accessLevels: An array containing names (or identifiers) of existing access levels for the corresponding events.

  • _amounts: An array containing the number of tickets each recipient can mint for the specified event and access level combination.

/**
    SetMintingApproval: Set approval for minting tickets to specified recipients for specific events and access levels.
    @param _eventIds: Array of event IDs for which minting approval is granted.
    @param _to: Array of recipient addresses for whom minting approval is granted.
    @param _accessLevels: Array of access levels for which minting approval is granted.
    @param _amounts: Array of approval amounts for each recipient, event, and access level combination.
    */
    function setMintingApproval(
        string[] calldata _eventIds,
        address[] calldata _to,
        string[] calldata _accessLevels,
        uint256[] calldata _amounts
    ) public {
        // Check if the lengths of input arrays match
        if (!checkLengths(_to, _eventIds, _accessLevels, _amounts))
            revert DecastGating__UnmatchedArrayLength();

        // Iterate through each recipient
        for (uint256 i = 0; i < _to.length; ++i) {
            // Check if the caller is an event manager for the specific event
            if (!checkIfCallerIsEventManager(_eventIds[i], _msgSender()))
                revert DecastGating__UserIsNotAnEventManager();

            // Check if the access level exists for the specific event
            if (!checkAccessLevelExists(_eventIds[i], _accessLevels[i]))
                revert DecastGating__AccessLevelDoesNotExists();

            // Get the token ID for the specific event and access level
            uint256 _tokenId = getTokenIdOfAccessLevel(
                _eventIds[i],
                _accessLevels[i]
            );

            // Check if the token ID exists for the specific event
            if (!checkTokenIdExistsForEventId(_eventIds[i], _tokenId))
                revert DecastGating__TokenIdDoesNotExists();

            // Grant minting approval to the recipient for the specific token ID
            s_tokenIdApprovals[_tokenId][_to[i]] += _amounts[i];
        }
    }

Last updated