-
Notifications
You must be signed in to change notification settings - Fork 2
/
CounterSingleExecTaskCreatorWT.sol
58 lines (43 loc) · 1.57 KB
/
CounterSingleExecTaskCreatorWT.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "../../gelato/AutomateTaskCreator.sol";
import { Module } from "../../gelato/Types.sol";
import "../../gelato/IOpsProxy.sol";
import "forge-std/Test.sol";
/**
* @dev
* Example contract that creates a single exec task.
*/
// solhint-disable not-rely-on-time
// solhint-disable no-empty-blocks
contract CounterSingleExecTaskCreatorWT is AutomateTaskCreator {
uint256 public count;
uint256 public lastExecuted;
bytes32 public taskId;
uint256 public constant MAX_COUNT = 5;
uint256 public constant INTERVAL = 3 minutes;
event CounterTaskCreated(bytes32 taskId);
constructor(address payable _automate, address _fundsOwner)
AutomateTaskCreator(_automate, _fundsOwner)
{ }
receive() external payable { }
function createTask() external payable {
require(taskId == bytes32(""), "Already started task");
bytes memory execData = abi.encodeCall(this.increaseCount, (1));
ModuleData memory moduleData =
ModuleData({modules: new Module[](2), args: new bytes[](2)});
moduleData.modules[0] = Module.PROXY;
moduleData.modules[1] = Module.SINGLE_EXEC;
moduleData.args[0] = _proxyModuleArg();
moduleData.args[1] = _singleExecModuleArg();
bytes32 id = _createTask(address(this), execData, moduleData, ETH);
taskId = id;
emit CounterTaskCreated(id);
}
function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {
count += _amount;
taskId = bytes32("");
(uint256 fee, address feeToken) = _getFeeDetails();
_transfer(fee, feeToken);
}
}