@@ -4,20 +4,12 @@ import "../controller/Avatar.sol";
44import "@daostack/infra-experimental/contracts/votingMachines/GenesisProtocol.sol " ;
55import "@daostack/infra-experimental/contracts/votingMachines/IntVoteInterface.sol " ;
66import "@openzeppelin/upgrades/contracts/Initializable.sol " ;
7- import "../utils/DAOFactory.sol " ;
8- import "../libs/StringUtil.sol " ;
97
108
119contract ArcScheme is Initializable {
12- using StringUtil for string ;
1310 Avatar public avatar;
1411 IntVoteInterface public votingMachine;
15-
16- string public constant GENESIS_PROTOCOL_INIT_FUNC_SIGNATURE =
17- "initialize(address,uint256[11],address,address,address,address) " ;
18-
19- string public constant ABSOLUTE_VOTE_INIT_FUNC_SIGNATURE =
20- "initialize(uint256,address,address,address,address) " ;
12+ bytes32 public voteParamsHash;
2113
2214 /**
2315 * @dev _initialize
@@ -32,60 +24,35 @@ contract ArcScheme is Initializable {
3224 /**
3325 * @dev _initializeGovernance
3426 * @param _avatar the scheme avatar
27+ * @param _votingMachine the scheme voting machine
28+ * @param _voteParamsHash the scheme vote params
3529 * @param _votingParams genesisProtocol parameters - valid only if _voteParamsHash is zero
36- * @param _voteOnBehalf parameter
37- * @param _daoFactory DAOFactory instance to instance a votingMachine.
38- * @param _stakingToken (for GenesisProtocol)
39- * @param _callbacks should fulfill voting callbacks interface
40- * @param _authorizedToPropose only this address allow to propose (unless it is zero)
41- * @param _packageVersion packageVersion to instance the votingMachine from.
42- * @param _votingMachineName the votingMachine contract name.
30+ * @param _voteOnBehalf genesisProtocol parameter - valid only if _voteParamsHash is zero
4331 */
4432 function _initializeGovernance (
4533 Avatar _avatar ,
34+ IntVoteInterface _votingMachine ,
35+ bytes32 _voteParamsHash ,
4636 uint256 [11 ] memory _votingParams ,
47- address _voteOnBehalf ,
48- DAOFactory _daoFactory ,
49- address _stakingToken ,
50- address _callbacks ,
51- address _authorizedToPropose ,
52- uint64 [3 ] memory _packageVersion ,
53- string memory _votingMachineName
37+ address _voteOnBehalf
5438 ) internal
5539 {
56-
57- require (_daoFactory != DAOFactory (0 ), "daoFactory cannot be zero " );
58- require (
59- _daoFactory.getImplementation (_packageVersion, _votingMachineName) != address (0 ),
60- "votingMachine name does not exist in ArcHive "
61- );
40+ require (_votingMachine != IntVoteInterface (0 ), "votingMachine cannot be zero " );
6241 _initialize (_avatar);
63-
64- bytes memory initData;
65- if (_votingMachineName. hashCompareWithLengthCheck ( " GenesisProtocol " )) {
66- initData = abi.encodeWithSignature (
67- GENESIS_PROTOCOL_INIT_FUNC_SIGNATURE,
68- _stakingToken,
69- _votingParams,
70- _voteOnBehalf,
71- avatar,
72- _callbacks,
73- _authorizedToPropose);
42+ votingMachine = _votingMachine;
43+ if (_voteParamsHash == bytes32 ( 0 )) {
44+ //genesisProtocol
45+ GenesisProtocol genesisProtocol = GenesisProtocol ( address (_votingMachine));
46+ voteParamsHash = genesisProtocol. getParametersHash (_votingParams, _voteOnBehalf);
47+ ( uint256 queuedVoteRequiredPercentage , , , , , , , , , , , ,) =
48+ genesisProtocol. parameters (voteParamsHash);
49+ if (queuedVoteRequiredPercentage == 0 ) {
50+ //params not set already
51+ genesisProtocol. setParameters (_votingParams, _voteOnBehalf);
52+ }
7453 } else {
75- initData = abi.encodeWithSignature (
76- ABSOLUTE_VOTE_INIT_FUNC_SIGNATURE,
77- _votingParams[0 ],
78- _voteOnBehalf,
79- avatar,
80- _callbacks,
81- _authorizedToPropose);
54+ //for other voting machines
55+ voteParamsHash = _voteParamsHash;
8256 }
83-
84- votingMachine = IntVoteInterface (address (_daoFactory.createInstance (
85- _packageVersion,
86- _votingMachineName,
87- address (avatar),
88- initData)));
89-
9057 }
9158}
0 commit comments