@@ -9,14 +9,16 @@ contract SimpleSchemeConstraints is SchemeConstraints {
9
9
10
10
mapping (address => bool ) public contractsWhiteListMap;
11
11
bool public initialized;
12
+ bool public enableSendEth;
12
13
13
14
/* @dev initialize
14
15
* @param _contractsWhiteList the contracts the scheme is allowed to interact with
15
16
* @param _descriptionHash can be used to add detalis description of the constraints.
16
17
*/
17
18
function initialize (
18
19
address [] calldata _contractsWhiteList ,
19
- string calldata _descriptionHash
20
+ string calldata _descriptionHash ,
21
+ bool _enableSendEth
20
22
)
21
23
external {
22
24
require (! initialized, "cannot initialize twice " );
@@ -26,43 +28,52 @@ contract SimpleSchemeConstraints is SchemeConstraints {
26
28
}
27
29
contractsWhiteList = _contractsWhiteList;
28
30
descriptionHash = _descriptionHash;
31
+ enableSendEth = _enableSendEth;
29
32
}
30
33
31
34
/*
32
35
* @dev isAllowedToCall should be called upon a proposal execution.
33
36
* @param _contractsToCall the contracts to be called
37
+ * @param _values value(ETH) to transfer with the calls
34
38
* @return bool value true-allowed false not allowed
35
39
*/
36
40
function isAllowedToCall (
37
41
address [] calldata _contractsToCall ,
38
42
bytes [] calldata ,
39
- uint256 [] calldata ,
43
+ uint256 [] calldata _values ,
40
44
Avatar
41
45
)
42
46
external
43
47
returns (bool )
44
48
{
45
49
for (uint i = 0 ; i < _contractsToCall.length ; i++ ) {
46
50
require (contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted " );
51
+ if (! enableSendEth) {
52
+ require (_values[i] == 0 , "sending eth is not allowed " );
53
+ }
47
54
}
48
55
return true ;
49
56
}
50
57
51
58
/*
52
59
* @dev isAllowedToPropose should be called upon a proposal submition.
53
60
* @param _contractsToCall the contracts to be called
61
+ * @param _values value(ETH) to transfer with the calls
54
62
* @return bool value true-allowed false not allowed
55
63
*/
56
64
function isAllowedToPropose (
57
65
address [] calldata _contractsToCall ,
58
66
bytes [] calldata ,
59
- uint256 [] calldata ,
67
+ uint256 [] calldata _values ,
60
68
Avatar)
61
69
external
62
70
returns (bool )
63
71
{
64
72
for (uint i = 0 ; i < _contractsToCall.length ; i++ ) {
65
73
require (contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted " );
74
+ if (! enableSendEth) {
75
+ require (_values[i] == 0 , "sending eth is not allowed " );
76
+ }
66
77
}
67
78
return true ;
68
79
}
0 commit comments