Skip to content

Commit cb4ac6f

Browse files
authored
GeneticSchemeMultiCall : execute is external (#792)
* execute is external * improve err msg at bytesLib
1 parent 803e13e commit cb4ac6f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

contracts/libs/BytesLib.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ library BytesLib {
2424
returns (bytes memory)
2525
// solhint-disable-next-line function-max-lines
2626
{
27-
require(_bytes.length >= _start.add(_length), "_bytes.length < (_start + _length)");
27+
require(_bytes.length >= _start.add(_length), "Read out of bounds");
2828

2929
bytes memory tempBytes;
3030
// solhint-disable-next-line no-inline-assembly

contracts/schemes/GenericSchemeMultiCall.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ contract GenericSchemeMultiCall is VotingMachineCallbacks, ProposalExecuteInterf
125125
* @dev execution of proposals after it has been decided by the voting machine
126126
* @param _proposalId the ID of the voting in the voting machine
127127
*/
128-
function execute(bytes32 _proposalId) public {
128+
function execute(bytes32 _proposalId) external {
129129
MultiCallProposal storage proposal = proposals[_proposalId];
130130
require(proposal.exist, "must be a live proposal");
131131
require(proposal.passed, "proposal must passed by voting machine");
@@ -193,15 +193,14 @@ contract GenericSchemeMultiCall is VotingMachineCallbacks, ProposalExecuteInterf
193193
(_contractsToCall.length == _callsDataLens.length) && (_contractsToCall.length == _values.length),
194194
"Wrong length of _contractsToCall, _callsDataLens or _values arrays"
195195
);
196-
Controller controller = Controller(whitelistedContracts[0]);
197196
uint256 startIndex = 0;
198197
for (uint i = 0; i < _contractsToCall.length; i++) {
199198
require(
200199
contractWhitelist[_contractsToCall[i]], "contractToCall is not whitelisted"
201200
);
202-
if (_contractsToCall[i] == address(controller)) {
201+
bytes memory callData = _callsData.slice(startIndex, _callsDataLens[i]);
202+
if (_contractsToCall[i] == whitelistedContracts[0]) {
203203

204-
bytes memory callData = _callsData.slice(startIndex, _callsDataLens[i]);
205204
(, address spender,) =
206205
abi.decode(
207206
callData,
@@ -211,6 +210,8 @@ contract GenericSchemeMultiCall is VotingMachineCallbacks, ProposalExecuteInterf
211210
}
212211
startIndex = startIndex.add(_callsDataLens[i]);
213212
}
213+
require(startIndex == _callsData.length, "_callsDataLens is wrong");
214+
214215
proposalId = votingMachine.propose(2, voteParams, msg.sender, address(avatar));
215216

216217
proposals[proposalId] = MultiCallProposal({
@@ -227,6 +228,5 @@ contract GenericSchemeMultiCall is VotingMachineCallbacks, ProposalExecuteInterf
227228
});
228229

229230
emit NewMultiCallProposal(address(avatar), proposalId, _callsData, _values, _descriptionHash, _contractsToCall);
230-
231231
}
232232
}

0 commit comments

Comments
 (0)