1
1
pragma solidity 0.5.17 ;
2
2
3
+ import "@daostack/infra/contracts/votingMachines/GenesisProtocolInterface.sol " ;
3
4
import "../schemes/GenericSchemeMultiCall.sol " ;
4
5
import "../schemes/SimpleSchemeConstraints.sol " ;
5
- import "@daostack/infra/contracts/votingMachines/GenesisProtocol.sol " ;
6
6
7
7
/**
8
- * @title
8
+ * @title GenericSchemeMultiCallFactory
9
9
*/
10
10
contract GenericSchemeMultiCallFactory {
11
11
uint8 public constant CUSTOM = 0 ;
@@ -24,14 +24,33 @@ contract GenericSchemeMultiCallFactory {
24
24
address [] memory _contractsWhiteList ,
25
25
string memory _descriptionHash
26
26
) public returns (address ) {
27
+ require (_voteParamsType < 4 , "Vote params type specified does not exist " );
27
28
GenericSchemeMultiCall genericSchemeMultiCall = new GenericSchemeMultiCall ();
28
29
address simpleSchemeConstraints;
29
30
if (_contractsWhiteList.length > 0 ) {
30
31
simpleSchemeConstraints = address (new SimpleSchemeConstraints ());
31
32
SimpleSchemeConstraints (simpleSchemeConstraints).initialize (_contractsWhiteList, _descriptionHash);
32
33
}
33
-
34
34
uint256 [11 ] memory voteParams;
35
+ if (_voteParamsType == CUSTOM) {
36
+ // Custom params hash
37
+ voteParams = _votingParams;
38
+ } else {
39
+ voteParams = getDefaultVoteParams (_voteParamsType);
40
+ }
41
+
42
+ bytes32 voteParamsHash = GenesisProtocolInterface (address (_votingMachine))
43
+ .setParameters (voteParams, _voteOnBehalf);
44
+
45
+ genericSchemeMultiCall.initialize (
46
+ _avatar, _votingMachine, voteParamsHash, SchemeConstraints (simpleSchemeConstraints)
47
+ );
48
+
49
+ emit NewGenericSchemeMultiCall (address (genericSchemeMultiCall));
50
+ return address (genericSchemeMultiCall);
51
+ }
52
+
53
+ function getDefaultVoteParams (uint8 _voteParamsType ) private pure returns (uint256 [11 ] memory voteParams ) {
35
54
if (_voteParamsType == FAST) {
36
55
// Fast params hash
37
56
voteParams = [
@@ -77,24 +96,6 @@ contract GenericSchemeMultiCallFactory {
77
96
uint256 (10 ),
78
97
uint256 (0 )
79
98
];
80
- } else {
81
- // Custom params hash
82
- voteParams = _votingParams;
83
99
}
84
-
85
- GenesisProtocol genesisProtocol = GenesisProtocol (address (_votingMachine));
86
- bytes32 voteParamsHash = genesisProtocol.getParametersHash (voteParams, _voteOnBehalf);
87
- (uint256 queuedVoteRequiredPercentage , , , , , , , , , , , ,) =
88
- genesisProtocol.parameters (voteParamsHash);
89
- if (queuedVoteRequiredPercentage == 0 ) {
90
- //params not set already
91
- genesisProtocol.setParameters (voteParams, _voteOnBehalf);
92
- }
93
- genericSchemeMultiCall.initialize (
94
- _avatar, _votingMachine, voteParamsHash, SchemeConstraints (simpleSchemeConstraints)
95
- );
96
-
97
- emit NewGenericSchemeMultiCall (address (genericSchemeMultiCall));
98
- return address (genericSchemeMultiCall);
99
100
}
100
101
}
0 commit comments