// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./TixSellContentLibrary.sol"; import "../factories/IContentTicketContractFactory.sol"; contract ContentContract is Ownable,ReentrancyGuard,AccessControl { bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); address public ticketContract; TixSellContentLibrary.Content public theContent; // Events event ContentCreated(string name); event ContentUpdated(string id); event ContentTicketTypeAdded(string contentId, string ticketTypeName); event ContentTicketTypeUpdated(string contentId, string ticketTypeName); constructor( address[] memory _admins, address _organizerAddress, address _ticketFactoryAddress, TixSellContentLibrary.Content memory _cDta, address _tixSellpaymentSplitter, address _organizerPaymentSplitter, address _resellPaiementSplitter, address _dataFeedEURUSD) Ownable(_organizerAddress) { for (uint256 i = 0; i < _admins.length; ++i) { _grantRole(ADMIN_ROLE, _admins[i]); _grantRole(DEFAULT_ADMIN_ROLE, _admins[i]); } theContent = TixSellContentLibrary.Content( _cDta.id, _cDta.typeContent, _cDta.name, _cDta.description, false, //Pas annulé, _cDta.royalty, _cDta.sellTixRoyaltieValue, _cDta.ticketTypes ); emit ContentCreated(_cDta.name); // deploy ? IContentTicketContractFactory ticketContractFactory = IContentTicketContractFactory(_ticketFactoryAddress); ticketContract = ticketContractFactory.deployTicketContract(_admins, _organizerAddress, _tixSellpaymentSplitter, _organizerPaymentSplitter, _resellPaiementSplitter, _dataFeedEURUSD, address(this),_cDta.name,_cDta.royalty); } modifier onlyAdmin() { require(msg.sender == owner() || msg.sender == ticketContract || hasRole(ADMIN_ROLE, msg.sender), "Only admins can do that"); _; } function updateContent(TixSellContentLibrary.Content memory _cDta) external onlyAdmin() returns(bool) { //Can update only metadata theContent.name = _cDta.name; theContent.description = _cDta.description; theContent.canceled = _cDta.canceled; theContent.royalty = _cDta.royalty; theContent.sellTixRoyaltieValue = _cDta.sellTixRoyaltieValue; emit ContentUpdated(_cDta.id); return true ; } function addContentTicketType(TixSellContentLibrary.ContentTicketType memory _newTicketType) external onlyAdmin returns (bool) { theContent.ticketTypes.push(_newTicketType); emit ContentTicketTypeAdded(theContent.id, _newTicketType.name); return true; } function updateContentTicketType(uint256 _ticketTypeIndex, TixSellContentLibrary.ContentTicketType memory _updatedTicketType) external onlyAdmin returns (bool) { require(_ticketTypeIndex < theContent.ticketTypes.length, "Invalid ticket type index"); theContent.ticketTypes[_ticketTypeIndex] = _updatedTicketType; emit ContentTicketTypeUpdated(theContent.id, _updatedTicketType.name); return true; } function getContent() external view returns(TixSellContentLibrary.Content memory){ return theContent; } }