41 lines
1.1 KiB
Solidity
41 lines
1.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity >=0.4.22 <0.9.0;
|
|
|
|
import "./Owner.sol";
|
|
|
|
contract MusiciansManager is Owner{
|
|
|
|
event musicianCreated(string _artistName);
|
|
event trackAdded(string _artistName, string _title);
|
|
event getTheTracks(Track[] _tracks);
|
|
|
|
struct Track {
|
|
string title;
|
|
uint duration;
|
|
}
|
|
|
|
struct Musician {
|
|
string name;
|
|
Track[] tracks;
|
|
}
|
|
|
|
mapping (address => Musician) musicians;
|
|
|
|
function addMusician(address _address, string memory _name) public isOwner() {
|
|
require(bytes(musicians[_address].name).length == 0, "Musician already exists");
|
|
musicians[_address].name = _name;
|
|
emit musicianCreated(_name);
|
|
}
|
|
|
|
function addTrack(address _address, string memory _title, uint _duration) external isOwner() {
|
|
require(bytes(musicians[_address].name).length > 0, "Musician does not exist");
|
|
Track memory thisTrack = Track(_title, _duration);
|
|
musicians[_address].tracks.push(thisTrack);
|
|
emit trackAdded(musicians[_address].name, _title);
|
|
}
|
|
|
|
function getTracks(address _address) external {
|
|
emit getTheTracks(musicians[_address].tracks);
|
|
}
|
|
}
|