From 427dbf37ebb51eb0fe1e85ca7e43a23876c7418d Mon Sep 17 00:00:00 2001 From: Daniel Kronovet Date: Fri, 11 Oct 2024 12:04:11 -0400 Subject: [PATCH] Correctly implement SetExpenditureSingleValues --- .../common/SetExpenditureSingleValues.sol | 53 ++++++------------- contracts/extensions/StreamingPayments.sol | 14 +++-- 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/contracts/common/SetExpenditureSingleValues.sol b/contracts/common/SetExpenditureSingleValues.sol index 740a5a5d70..1ebedf0ca5 100644 --- a/contracts/common/SetExpenditureSingleValues.sol +++ b/contracts/common/SetExpenditureSingleValues.sol @@ -16,23 +16,21 @@ along with The Colony Network. If not, see . */ -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, @@ -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); } } diff --git a/contracts/extensions/StreamingPayments.sol b/contracts/extensions/StreamingPayments.sol index b0bc18b3c5..c3f4bd03a9 100644 --- a/contracts/extensions/StreamingPayments.sol +++ b/contracts/extensions/StreamingPayments.sol @@ -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 { @@ -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;