Skip to content

Commit

Permalink
Arrays no longer required internally
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Jun 6, 2024
1 parent de3aeb6 commit 89fe76c
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions contracts/extensions/StreamingPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ contract StreamingPayments is ColonyExtensionMeta {
_toChildSkillIndex,
_id,
domainFundingPotId,
toAddressArray(streamingPayment.token),
toUint256Array(amountToClaim)
streamingPayment.token,
amountToClaim
);

colony.claimExpenditurePayout(expenditureId, SLOT, streamingPayment.token);
Expand Down Expand Up @@ -427,8 +427,8 @@ contract StreamingPayments is ColonyExtensionMeta {
uint256 _toChildSkillIndex,
uint256 _id,
uint256 _domainFundingPotId,
address[] memory _tokens,
uint256[] memory _amountsToClaim
address _token,
uint256 _amountToClaim
) internal returns (uint256) {
uint256 expenditureId = colony.makeExpenditure(
_permissionDomainId,
Expand All @@ -437,35 +437,23 @@ contract StreamingPayments is ColonyExtensionMeta {
);
uint256 expenditureFundingPotId = colony.getExpenditure(expenditureId).fundingPotId;

for (uint256 i; i < _tokens.length; i++) {
if (_amountsToClaim[i] > 0) {
colony.moveFundsBetweenPots(
_permissionDomainId,
_childSkillIndex,
streamingPayments[_id].domainId,
_fromChildSkillIndex,
_toChildSkillIndex,
_domainFundingPotId,
expenditureFundingPotId,
_amountsToClaim[i],
_tokens[i]
);
colony.setExpenditurePayout(expenditureId, SLOT, _tokens[i], _amountsToClaim[i]);
}
if (_amountToClaim > 0) {
colony.moveFundsBetweenPots(
_permissionDomainId,
_childSkillIndex,
streamingPayments[_id].domainId,
_fromChildSkillIndex,
_toChildSkillIndex,
_domainFundingPotId,
expenditureFundingPotId,
_amountToClaim,
_token
);
colony.setExpenditurePayout(expenditureId, SLOT, _token, _amountToClaim);
}

colony.setExpenditureRecipient(expenditureId, SLOT, streamingPayments[_id].recipient);
colony.finalizeExpenditure(expenditureId);
return expenditureId;
}

function toAddressArray(address _token) internal pure returns (address[] memory tokens) {
tokens = new address[](1);
tokens[0] = _token;
}

function toUint256Array(uint256 _value) internal pure returns (uint256[] memory values) {
values = new uint256[](1);
values[0] = _value;
}
}

0 comments on commit 89fe76c

Please sign in to comment.