Skip to content

Commit

Permalink
Default to all splitters
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk committed Aug 23, 2024
1 parent 4895465 commit 0fda265
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/payments/IPaymentCombiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IPaymentCombinerFunctions {
* Get the list of pending shares for a payee.
* @param payee The address of the payee
* @param tokenAddr The address of the ERC-20 token. If the token address is 0x0, then the native token is used.
* @param splitterAddrs The list of payments splitters to check
* @param splitterAddrs The list of payments splitters to check. If empty then all splitters are used.
* @return pendingShares The list of pending shares
* @dev The list includes zero balances. These should be removed before releasing shares.
*/
Expand All @@ -50,8 +50,9 @@ interface IPaymentCombinerFunctions {
* Release the pending shares for a payee.
* @param payee The address of the payee
* @param tokenAddr The address of the ERC-20 token. If the token address is 0x0, then the native token is used.
* @param splitterAddrs The list of payments splitters to release shares from
* @dev Use the listReleasableSplitters function to get the list of splitters and pending shares
* @param splitterAddrs The list of payments splitters to release shares from. If empty then all splitters are used.
* @dev Use the above functions to get the list of splitters and pending shares.
* @dev Calling splitters with no shares to release will fail.
*/
function release(address payable payee, address tokenAddr, address[] calldata splitterAddrs) external;
}
Expand Down
10 changes: 10 additions & 0 deletions src/payments/PaymentCombiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ contract PaymentCombiner is IPaymentCombiner, IERC165 {
returns (uint256[] memory pendingShares)
{
uint256 len = splitterAddrs.length;
if (len == 0) {
splitterAddrs = _payeeSplitters[payee];
len = splitterAddrs.length;
}

uint256[] memory payeePendingShares = new uint256[](len);

if (tokenAddr == address(0)) {
Expand All @@ -98,6 +103,11 @@ contract PaymentCombiner is IPaymentCombiner, IERC165 {
/// @inheritdoc IPaymentCombinerFunctions
function release(address payable payee, address tokenAddr, address[] calldata splitterAddrs) external {
uint256 len = splitterAddrs.length;
if (len == 0) {
splitterAddrs = _payeeSplitters[payee];
len = splitterAddrs.length;
}

if (tokenAddr == address(0)) {
for (uint256 i = 0; i < len;) {
PaymentSplitter(payable(splitterAddrs[i])).release(payee);
Expand Down

0 comments on commit 0fda265

Please sign in to comment.