pragma solidity ^0.4.24; /* ledger over issues/bounties in a github repo */ contract IssueBounty { struct Repo { uint id; mapping (uint => Issue) issues; } struct Issue { uint taskId; uint totalBountyAmount; Bounty[] bounties; } struct Bounty { uint amount; uint endTime; address issuerAddress; } address owner; mapping(uint => Repo) repos; constructor() public { owner = msg.sender; } modifier onlySeller() { require( msg.sender == owner, "Only seller can call this." ); // _ is the place where the modified function body will be inserted _; } function getIssue(uint repoId, uint issueId) internal view returns (Issue) { Repo storage repo = repos[repoId]; return repo.issues[issueId]; } // TODO handle multiple bounties on the same issue function putBountyOnIssue(uint repoId, uint issueId, uint endTime) external payable { // TODO set default time to 90 days uint _endTime = endTime; Repo storage repo = repos[repoId]; Issue storage issue = repo.issues[issueId]; issue.totalBountyAmount += msg.value; Bounty memory bounty = Bounty(msg.value, _endTime, msg.sender); issue.bounties.push(bounty); } function payoutBounty(address to, uint repoId, uint taskId) external onlySeller { Issue memory issue = getIssue(repoId, taskId); to.transfer(issue.totalBountyAmount); } }
0.4.24