Created
June 21, 2022 16:47
-
-
Save donoso-eth/0678b0613db36c6c332063c9f39cddfd to your computer and use it in GitHub Desktop.
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
// ============= ============= Create Simple Task Use Case Business Logic ============= ============= // | |
// #region Create Simple Task Use Case Business Logic | |
/************************************************************************** | |
* Create Simple Task Use Case Business Logic | |
* | |
* Step 1 : createTask() | |
* - will create a gelato task | |
* - will store the taskId | |
* | |
* Step 2 : checkerstartParty() Function. | |
* - Check If the task can be executed , in rhis case if we don't headache | |
* - returns the execPayload of startParty() | |
* | |
* Step 3 : Executable Function: startParty() | |
* - will Start the party setting lastPartyStrt to block.timestamo | |
* - will cause a headache | |
*************************************************************************/ | |
function createTask() public { | |
require(taskIdByUser[msg.sender] == bytes32(0), "TASK_STILL_ACTIVE"); | |
bytes32 taskId = IOps(ops).createTask( | |
address(this), /// Contract executing the task | |
this.startParty.selector, /// Executable function's selector | |
address(this), /// Resolver contract, in our case will be the same | |
abi.encodeWithSelector(this.checkerStartParty.selector) /// Checker Condition | |
); | |
taskIdByUser[msg.sender] = taskId; | |
} | |
function checkerStartParty() | |
external | |
view | |
returns (bool canExec, bytes memory execPayload) | |
{ | |
canExec = headachePresent == false; | |
execPayload = abi.encodeWithSelector(this.startParty.selector); | |
} | |
function startParty() external onlyOps { | |
require(headachePresent == false, "NOT_READY"); | |
lastPartyStart = block.timestamp; | |
headachePresent = true; | |
} | |
// #endregion Create Simple Task Use Case Business Logic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment