-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathRemoveRewardProgram.sol
84 lines (72 loc) · 2.56 KB
/
RemoveRewardProgram.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
77
78
79
80
81
82
83
84
// SPDX-FileCopyrightText: 2021 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
import "../TrustedCaller.sol";
import "../RewardProgramsRegistry.sol";
import "../libraries/EVMScriptCreator.sol";
import "../interfaces/IEVMScriptFactory.sol";
/// @author psirex
/// @notice Creates EVMScript to remove reward program from RewardProgramsRegistry
contract RemoveRewardProgram is TrustedCaller, IEVMScriptFactory {
// -------------
// ERRORS
// -------------
string private constant ERROR_REWARD_PROGRAM_NOT_FOUND = "REWARD_PROGRAM_NOT_FOUND";
// -------------
// VARIABLES
// -------------
/// @notice Address of RewardsProgramsRegistry
RewardProgramsRegistry public immutable rewardProgramsRegistry;
// -------------
// CONSTRUCTOR
// -------------
constructor(address _trustedCaller, address _rewardProgramsRegistry)
TrustedCaller(_trustedCaller)
{
rewardProgramsRegistry = RewardProgramsRegistry(_rewardProgramsRegistry);
}
// -------------
// EXTERNAL METHODS
// -------------
/// @notice Creates EVMScript to remove reward program from RewardProgramsRegistry
/// @param _creator Address who creates EVMScript
/// @param _evmScriptCallData Encoded tuple: (address _rewardProgram)
function createEVMScript(address _creator, bytes memory _evmScriptCallData)
external
view
override
onlyTrustedCaller(_creator)
returns (bytes memory)
{
require(
rewardProgramsRegistry.isRewardProgram(_decodeEVMScriptCallData(_evmScriptCallData)),
ERROR_REWARD_PROGRAM_NOT_FOUND
);
return
EVMScriptCreator.createEVMScript(
address(rewardProgramsRegistry),
rewardProgramsRegistry.removeRewardProgram.selector,
_evmScriptCallData
);
}
/// @notice Decodes call data used by createEVMScript method
/// @param _evmScriptCallData Encoded tuple: (address _rewardProgram)
/// @return _rewardProgram Address of reward program to remove
function decodeEVMScriptCallData(bytes memory _evmScriptCallData)
external
pure
returns (address _rewardProgram)
{
return _decodeEVMScriptCallData(_evmScriptCallData);
}
// ------------------
// PRIVATE METHODS
// ------------------
function _decodeEVMScriptCallData(bytes memory _evmScriptCallData)
private
pure
returns (address)
{
return abi.decode(_evmScriptCallData, (address));
}
}