-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Currently the retireAll
method inside the MVDFunctionalityProposalContract blocks its compilation by raising a stack too deep
error.
This is the current method implementation:
/** @dev Allows the sender to retire all the tokens used for voting in this proposal.
* @param proposalId proposal identifier.
*/
function retireAll(uint256 proposalId) public override duringSurvey(proposalId) {
require(_proposals[proposalId].getItemProposalWeightFunctionalityAddress != address(0), "");
IGetItemProposalWeightFunctionality functionality = IGetItemProposalWeightFunctionality(_proposals[proposalId].getItemProposalWeightFunctionalityAddress);
uint256 total = 0;
address[] memory collections = _userCollectionAddresses[proposalId][msg.sender];
for (uint j = 0; j < collections.length; j++) {
uint256[] memory amounts = new uint256[](_userObjectIds[proposalId][msg.sender][collections[j]].length);
for (uint256 i = 0; i < _userObjectIds[proposalId][msg.sender][collections[j]].length; i++) {
require(_accept[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]] + _refuse[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]] > 0, "");
}
for (uint256 i = 0; i < _userObjectIds[proposalId][msg.sender][collections[j]].length; i++) {
uint256 tokenWeight = functionality.getItemProposalWeight(collections[j], _userObjectIds[proposalId][msg.sender][collections[j]][i]);
if (tokenWeight > 0) {
uint256 acpt = _accept[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]];
uint256 rfs = _refuse[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]];
uint256 wAcpt = acpt / tokenWeight;
uint256 wRfs = rfs / tokenWeight;
amounts[i] = wAcpt + wRfs;
_accept[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]] = 0;
_refuse[proposalId][msg.sender][_userObjectIds[proposalId][msg.sender][collections[j]][i]] = 0;
_totalAccept[proposalId] -= acpt;
_totalRefuse[proposalId] -= rfs;
total += (acpt + rfs);
} else {
amounts[i] = 0;
}
}
IEthItemCollection(collections[j]).safeBatchTransferFrom(address(this), msg.sender, amounts, _userObjectIds[proposalId][msg.sender][collections[j]], "");
}
emit RetireAll(msg.sender, proposalId, total);
}
It raises a stack too deep because there are too many nested mappings; a solution could be splitting the function into two retireAllAccept
and retireAllRefuse
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working