Skip to content

Commit

Permalink
Correctly implement SetExpenditureSingleValues
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens committed Oct 14, 2024
1 parent f483ab4 commit 27ab876
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 41 deletions.
53 changes: 15 additions & 38 deletions contracts/common/SetExpenditureSingleValues.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma solidity 0.8.27;
pragma experimental ABIEncoderV2;

import { IColony } from "./../colony/IColony.sol";

contract SetExpenditureSingleValues {
struct SetExpenditureValuesCallData {
uint256[] slots;
uint256[][] wrappedSlots;
address payable[] recipients;
uint256[] slots;
uint256[] skills;
address[] tokens;
uint256[][] amounts;
uint256[] amounts;
}

function setExpenditureSingleValues(
address colony,
address _colony,
uint256 _expenditureId,
uint256 _slot,
address payable _recipient,
Expand All @@ -41,44 +39,23 @@ contract SetExpenditureSingleValues {
uint256 _amount
) internal {
SetExpenditureValuesCallData memory data = SetExpenditureValuesCallData(
new uint256[](1),
new uint256[][](1),
new address payable[](1),
new uint256[](0),
new address[](1),
new uint256[][](1)
new uint256[](1),
new uint256[](1),
new uint256[](1)
);

if (_skillId != 0) {
data.skills = new uint256[](1);
data.skills[0] = _skillId;
}

data.recipients[0] = _recipient;
data.slots[0] = _slot;
data.wrappedSlots[0] = new uint256[](1);
data.wrappedSlots[0][0] = _slot;
data.skills[0] = _skillId;
data.amounts[0] = _amount;

data.recipients[0] = _recipient;
data.tokens[0] = _token;
data.amounts[0] = new uint256[](1);
data.amounts[0][0] = _amount;
IColony(_colony).setExpenditureRecipients(_expenditureId, data.slots, data.recipients);

uint256[] memory emptyUint256Array;
int256[] memory emptyInt256Array;
if (data.skills[0] > 0) {
IColony(_colony).setExpenditureSkills(_expenditureId, data.slots, data.skills);
}

IColony(colony).setExpenditureValues(
_expenditureId,
data.slots,
data.recipients,
data.slots,
data.skills,
emptyUint256Array,
emptyUint256Array,
emptyUint256Array,
emptyInt256Array,
data.tokens,
data.wrappedSlots,
data.amounts
);
IColony(_colony).setExpenditurePayouts(_expenditureId, data.slots, _token, data.amounts);
}
}
14 changes: 11 additions & 3 deletions contracts/extensions/StreamingPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2;

import { ColonyExtensionMeta } from "./ColonyExtensionMeta.sol";
import { ColonyDataTypes } from "./../colony/ColonyDataTypes.sol";

import { SetExpenditureSingleValues } from "./../common/SetExpenditureSingleValues.sol";
// ignore-file-swc-108

contract StreamingPayments is ColonyExtensionMeta, SetExpenditureSingleValues {
Expand Down Expand Up @@ -547,8 +547,16 @@ contract StreamingPayments is ColonyExtensionMeta, SetExpenditureSingleValues {
_token
);

colony.setExpenditurePayout(expenditureId, SLOT, _token, _amountToClaim);
colony.setExpenditureRecipient(expenditureId, SLOT, streamingPayments[_id].recipient);
setExpenditureSingleValues(
address(colony),
expenditureId,
SLOT,
streamingPayments[_id].recipient,
0,
_token,
_amountToClaim
);

colony.finalizeExpenditure(expenditureId);

return expenditureId;
Expand Down

0 comments on commit 27ab876

Please sign in to comment.