-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
19 deletions.
There are no files selected for viewing
34 changes: 15 additions & 19 deletions
34
examples/local-explorer/packages/contracts/src/systems/TasksSystem.sol
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.24; | ||
|
||
import {System} from "@latticexyz/world/src/System.sol"; | ||
import {Tasks, TasksData} from "../codegen/index.sol"; | ||
import { System } from "@latticexyz/world/src/System.sol"; | ||
import { Tasks, TasksData } from "../codegen/index.sol"; | ||
|
||
contract TasksSystem is System { | ||
event SomeEvent(string message); | ||
function addTask(string memory description) public returns (bytes32 id) { | ||
id = keccak256(abi.encode(block.prevrandao, _msgSender(), description)); | ||
Tasks.set(id, TasksData({ description: description, createdAt: block.timestamp, completedAt: 0 })); | ||
} | ||
|
||
function addTask(string memory description) public returns (bytes32 id) { | ||
id = keccak256(abi.encode(block.prevrandao, _msgSender(), description)); | ||
Tasks.set(id, TasksData({description: description, createdAt: block.timestamp, completedAt: 0})); | ||
function completeTask(bytes32 id) public { | ||
Tasks.setCompletedAt(id, block.timestamp); | ||
} | ||
|
||
emit SomeEvent("addTask"); | ||
} | ||
function resetTask(bytes32 id) public { | ||
Tasks.setCompletedAt(id, 0); | ||
} | ||
|
||
function completeTask(bytes32 id) public { | ||
Tasks.setCompletedAt(id, block.timestamp); | ||
} | ||
|
||
function resetTask(bytes32 id) public { | ||
Tasks.setCompletedAt(id, 0); | ||
} | ||
|
||
function deleteTask(bytes32 id) public { | ||
Tasks.deleteRecord(id); | ||
} | ||
function deleteTask(bytes32 id) public { | ||
Tasks.deleteRecord(id); | ||
} | ||
} |