This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
ProviderModuleGelatoUserProxy.sol
76 lines (70 loc) · 2.64 KB
/
ProviderModuleGelatoUserProxy.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.10;
pragma experimental ABIEncoderV2;
import {GelatoProviderModuleStandard} from "../GelatoProviderModuleStandard.sol";
import {
Action, Operation, DataFlow, Task
} from "../../gelato_core/interfaces/IGelatoCore.sol";
import {
IGelatoUserProxyFactory
} from "../../user_proxies/gelato_user_proxy/interfaces/IGelatoUserProxyFactory.sol";
import {
IGelatoUserProxy
} from "../../user_proxies/gelato_user_proxy/interfaces/IGelatoUserProxy.sol";
import {GelatoActionPipeline} from "../../gelato_actions/GelatoActionPipeline.sol";
contract ProviderModuleGelatoUserProxy is GelatoProviderModuleStandard {
IGelatoUserProxyFactory public immutable gelatoUserProxyFactory;
address public immutable gelatoActionPipeline;
constructor(
IGelatoUserProxyFactory _gelatoUserProxyFactory,
address _gelatoActionPipeline
)
public
{
gelatoUserProxyFactory = _gelatoUserProxyFactory;
gelatoActionPipeline = _gelatoActionPipeline;
}
// ================= GELATO PROVIDER MODULE STANDARD ================
function isProvided(address _userProxy, address, Task calldata)
external
view
override
returns(string memory)
{
bool proxyOk = gelatoUserProxyFactory.isGelatoUserProxy(_userProxy);
if (!proxyOk) return "ProviderModuleGelatoUserProxy.isProvided:InvalidUserProxy";
return OK;
}
function execPayload(uint256, address, address, Task calldata _task, uint256)
external
view
override
returns(bytes memory payload, bool) // bool==false: no execRevertCheck
{
if (_task.actions.length > 1) {
bytes memory gelatoActionPipelinePayload = abi.encodeWithSelector(
GelatoActionPipeline.execActionsAndPipeData.selector,
_task.actions
);
Action memory pipelinedActions = Action({
addr: gelatoActionPipeline,
data: gelatoActionPipelinePayload,
operation: Operation.Delegatecall,
dataFlow: DataFlow.None,
value: 0,
termsOkCheck: false
});
payload = abi.encodeWithSelector(
IGelatoUserProxy.execAction.selector,
pipelinedActions
);
} else if (_task.actions.length == 1) {
payload = abi.encodeWithSelector(
IGelatoUserProxy.execAction.selector,
_task.actions[0]
);
} else {
revert("ProviderModuleGelatoUserProxy.execPayload: 0 _task.actions length");
}
}
}