Skip to content

Commit 26abb69

Browse files
authored
schemeConstraint - add enableSendEth flag (#816)
* schemeConstraint - add enableSendEth flag * bump v to rc.56
1 parent 24f5a6c commit 26abb69

File tree

6 files changed

+1213
-997
lines changed

6 files changed

+1213
-997
lines changed

contracts/schemes/SimpleSchemeConstraints.sol

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ contract SimpleSchemeConstraints is SchemeConstraints {
99

1010
mapping(address=>bool) public contractsWhiteListMap;
1111
bool public initialized;
12+
bool public enableSendEth;
1213

1314
/* @dev initialize
1415
* @param _contractsWhiteList the contracts the scheme is allowed to interact with
1516
* @param _descriptionHash can be used to add detalis description of the constraints.
1617
*/
1718
function initialize(
1819
address[] calldata _contractsWhiteList,
19-
string calldata _descriptionHash
20+
string calldata _descriptionHash,
21+
bool _enableSendEth
2022
)
2123
external {
2224
require(!initialized, "cannot initialize twice");
@@ -26,43 +28,52 @@ contract SimpleSchemeConstraints is SchemeConstraints {
2628
}
2729
contractsWhiteList = _contractsWhiteList;
2830
descriptionHash = _descriptionHash;
31+
enableSendEth = _enableSendEth;
2932
}
3033

3134
/*
3235
* @dev isAllowedToCall should be called upon a proposal execution.
3336
* @param _contractsToCall the contracts to be called
37+
* @param _values value(ETH) to transfer with the calls
3438
* @return bool value true-allowed false not allowed
3539
*/
3640
function isAllowedToCall(
3741
address[] calldata _contractsToCall,
3842
bytes[] calldata,
39-
uint256[] calldata,
43+
uint256[] calldata _values,
4044
Avatar
4145
)
4246
external
4347
returns(bool)
4448
{
4549
for (uint i = 0; i < _contractsToCall.length; i++) {
4650
require(contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted");
51+
if (!enableSendEth) {
52+
require(_values[i] == 0, "sending eth is not allowed");
53+
}
4754
}
4855
return true;
4956
}
5057

5158
/*
5259
* @dev isAllowedToPropose should be called upon a proposal submition.
5360
* @param _contractsToCall the contracts to be called
61+
* @param _values value(ETH) to transfer with the calls
5462
* @return bool value true-allowed false not allowed
5563
*/
5664
function isAllowedToPropose(
5765
address[] calldata _contractsToCall,
5866
bytes[] calldata,
59-
uint256[] calldata,
67+
uint256[] calldata _values,
6068
Avatar)
6169
external
6270
returns(bool)
6371
{
6472
for (uint i = 0; i < _contractsToCall.length; i++) {
6573
require(contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted");
74+
if (!enableSendEth) {
75+
require(_values[i] == 0, "sending eth is not allowed");
76+
}
6677
}
6778
return true;
6879
}

contracts/utils/GenericSchemeMultiCallFactory.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ contract GenericSchemeMultiCallFactory {
2222
uint256[11] memory _votingParams,
2323
address _voteOnBehalf,
2424
address[] memory _contractsWhiteList,
25+
bool _enableSendEth,
2526
string memory _descriptionHash
2627
) public returns(address) {
2728
require(_voteParamsType < 4, "Vote params type specified does not exist");
2829
GenericSchemeMultiCall genericSchemeMultiCall = new GenericSchemeMultiCall();
2930
address simpleSchemeConstraints;
3031
if (_contractsWhiteList.length > 0) {
3132
simpleSchemeConstraints = address(new SimpleSchemeConstraints());
32-
SimpleSchemeConstraints(simpleSchemeConstraints).initialize(_contractsWhiteList, _descriptionHash);
33+
SimpleSchemeConstraints(simpleSchemeConstraints)
34+
.initialize(_contractsWhiteList, _descriptionHash, _enableSendEth);
3335
}
3436
uint256[11] memory voteParams;
3537
if (_voteParamsType == CUSTOM) {

0 commit comments

Comments
 (0)