Last active
November 9, 2021 12:06
-
-
Save mpetrunic/7c6d97072d2f6711c85533abe90998c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.3; | |
| contract ToDo { | |
| event TaskCreated(uint256 id, uint256 date, string content, bool done); | |
| event TaskCompleted(uint256 id, uint256 dateComplete); | |
| event TaskDeleted(uint256 id); | |
| struct Task { | |
| uint256 id; | |
| uint256 date; | |
| string content; | |
| bool done; | |
| uint256 dateComplete; | |
| } | |
| //creates new task, returns task id | |
| function createTask(string memory _content) public returns(uint256) { | |
| } | |
| //return array of task ids for all existing, non deleted tasks | |
| function getTaskIds() external view returns (uint256[] memory) { | |
| } | |
| //Returns task with given id, empty task or revert if task not found | |
| function getTask(uint256 id) external view returns(Task memory) { | |
| } | |
| //not required, bonus task | |
| function getTasks() external view returns (Task[] memory) { | |
| } | |
| //marks task as done | |
| function completeTask(uint256 id) external taskExists(id) { | |
| } | |
| //deletes task with given id, reverts if task doesn't exist | |
| function deleteTask(uint256 id) external taskExists(id) { | |
| } | |
| // reverts if task with this id doesn't exist | |
| modifier taskExists(uint256 id) { | |
| _; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment