Skip to content

Commit

Permalink
chore: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhit15082003 committed Apr 5, 2024
1 parent c38f7a6 commit 0d50c2f
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions contracts/tasktrackr.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract tasktrackr {
event TaskUpdated(uint256 indexed id, string newTask);
event ContractDestroyed(address indexed destroyer);
event TaskDeleted(uint256 indexed id);

mapping(uint256 => TodoItem) public list;
uint256 public count = 0;
address public owner;
Expand All @@ -21,7 +21,10 @@ contract tasktrackr {
}

modifier onlyOwner() {
require(msg.sender == owner, "Only contract owner can call this function");
require(
msg.sender == owner,
"Only contract owner can call this function"
);
_;
}

Expand Down Expand Up @@ -88,7 +91,7 @@ contract tasktrackr {
}
}
assembly {
mstore(completedTasks, completedCount)
mstore(completedTasks, completedCount)
}
return completedTasks;
}
Expand All @@ -109,26 +112,31 @@ contract tasktrackr {
}
return incompleteTasks;
}
}

function displayAllTasks() public view returns (string[] memory tasks, bool[] memory statuses) {
string[] memory taskList = new string[](count);
bool[] memory statusList = new bool[](count);
if(count==0)
revert("Nothing to display");
for (uint256 i = 0; i < count; i++) {
TodoItem memory item = list[i];
taskList[i] = item.task;
statusList[i] = item.isCompleted;
function displayAllTasks()
public
view
returns (string[] memory tasks, bool[] memory statuses)
{
string[] memory taskList = new string[](count);
bool[] memory statusList = new bool[](count);
if (count == 0) revert("Nothing to display");
for (uint256 i = 0; i < count; i++) {
TodoItem memory item = list[i];
taskList[i] = item.task;
statusList[i] = item.isCompleted;
}

return (taskList, statusList);
}

return (taskList, statusList);
}
function displayById(uint256 id) public view returns (string memory task, bool isCompleted) {
require(id < count, "Task with given ID does not exist");
TodoItem memory item = list[id];
return (item.task, item.isCompleted);
function displayById(uint256 id)
public
view
returns (string memory task, bool isCompleted)
{
require(id < count, "Task with given ID does not exist");
TodoItem memory item = list[id];
return (item.task, item.isCompleted);
}

}

0 comments on commit 0d50c2f

Please sign in to comment.