This commit is contained in:
elegant651
2020-03-24 14:39:38 +09:00
commit 6e0388b653
83 changed files with 92480 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
pragma solidity 0.4.25;
contract TodoFeed {
event TodoCompleted (uint256 indexed todoId, address owner, string title, bytes photo, uint256 timestamp);
event TodoVerified (uint256 indexed todoId, address verifier);
TodoData[] public todoList;
mapping(uint256 => TodoData) public todoMap;
struct TodoData {
uint256 todoId; // Unique token id
address owner;
string title;
bytes photo; // Image source encoded in uint 8 array format
uint256 timestamp; // Uploaded time
bool isVerified; // check if is verified, default false.
address verifier; // verifier address
}
function writeTodo(string title, bytes photo) public {
uint256 todoId = todoList.length + 1;
TodoData memory newData = TodoData({
todoId : todoId,
owner : msg.sender,
title : title,
photo : photo,
timestamp : now,
isVerified: false,
verifier: address(0)
});
todoList.push(newData);
todoMap[todoId] = newData;
emit TodoCompleted(todoId, msg.sender, title, photo, now);
}
function verifyTodo(uint256 todoId) {
todoMap[todoId].isVerified = true;
todoMap[todoId].verifier = msg.sender;
emit TodoVerified(todoId, msg.sender);
}
function getTotalTodoCount () public view returns (uint) {
return todoList.length;
}
function getTodo (uint todoId) public view
returns(uint256, address, string, bytes, uint256, bool, address) {
require(todoMap[todoId].todoId != 0, "Todo does not exist");
return (
todoMap[todoId].todoId,
todoMap[todoId].owner,
todoMap[todoId].title,
todoMap[todoId].photo,
todoMap[todoId].timestamp,
todoMap[todoId].isVerified,
todoMap[todoId].verifier);
}
}