pragma solidity ^0.8.0; contract ArtistRegistry { struct Artist { string name; uint256 id; string url; address[] contractAddresses; } mapping(address => Artist) public artists; mapping(address => bool) public allowlist; mapping(address => bool) public allowlistManagers; uint256 public artistCounter; event ArtistRegistered(address indexed artistAddress, string name, uint256 id, string url); event ContractAddressAdded(address indexed artistAddress, address contractAddress); event ArtistUpdated(address indexed artistAddress, string name, string url); event AllowlistManagerAdded(address indexed managerAddress); event AllowlistManagerRemoved(address indexed managerAddress); constructor() { artistCounter = 0; allowlistManagers[msg.sender] = true; } modifier onlyAllowlistManager() { require(allowlistManagers[msg.sender], "Not allowed to perform this action"); _; } modifier onlyAllowlisted() { require(allowlist[msg.sender], "Not allowed to perform this action"); _; } modifier onlyRegistered() { require(artists[msg.sender].id > 0, "Artist not registered"); _; } function addToAllowlist(address _address) public onlyAllowlistManager { allowlist[_address] = true; } function removeFromAllowlist(address _address) public onlyAllowlistManager { allowlist[_address] = false; } function addAllowlistManager(address _managerAddress) public onlyAllowlistManager { allowlistManagers[_managerAddress] = true; emit AllowlistManagerAdded(_managerAddress); } function removeAllowlistManager(address _managerAddress) public onlyAllowlistManager { allowlistManagers[_managerAddress] = false; emit AllowlistManagerRemoved(_managerAddress); } function registerArtist(string memory _name, string memory _url) public onlyAllowlisted { require(bytes(_name).length > 0, "Name is required"); require(bytes(_url).length > 0, "URL is required"); require(artists[msg.sender].id == 0, "Already registered"); artistCounter++; Artist memory newArtist = Artist(_name, artistCounter, _url, new address[](0)); artists[msg.sender] = newArtist; emit ArtistRegistered(msg.sender, _name, artistCounter, _url); } function addContractAddress(address _contractAddress) public onlyRegistered { require(_contractAddress != address(0), "Contract address cannot be zero"); Artist storage artist = artists[msg.sender]; artist.contractAddresses.push(_contractAddress); emit ContractAddressAdded(msg.sender, _contractAddress); } function updateArtist(string memory _name, string memory _url) public onlyRegistered { require(bytes(_name).length > 0, "Name is required"); require(bytes(_url).length > 0, "URL is required"); Artist storage artist = artists[msg.sender]; artist.name = _name; artist.url = _url; emit ArtistUpdated(msg.sender, _name, _url); } function getArtist(address _artistAddress) public view returns (string memory, uint256, string memory, address[] memory) { Artist memory artist = artists[_artistAddress]; require(artist.id > 0, "Artist not found"); return (artist.name, artist.id, artist.url, artist.contractAddresses); } }
0.4.18