Skip to content

Commit

Permalink
apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Apr 23, 2024
1 parent dbe1ea2 commit 98dc648
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions contracts/contracts/coordination/Subscription.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,28 @@ abstract contract Subscription {
}

/**
* @notice Withdraws the contract balance to the beneficiary
* @param amount The amount to withdraw
* @notice Calculates the available amount of fees that can be withdrawn be the beneficiary
* @return The available amount of fees
*/
function withdrawToBeneficiary(uint256 amount) external {
require(msg.sender == beneficiary, "Only the beneficiary can withdraw");

function calculateAvailableAmountForBeneficiary() public view returns (uint256) {
uint256 availableAmount = 0;
for (uint32 i = 0; i < numberOfSubscriptions; i++) {
SubscriptionInfo storage sub = subscriptions[i];
if (block.timestamp >= sub.expiration) {
availableAmount += sub.paidFor - sub.spent;
}
}
require(amount <= availableAmount, "Insufficient available amount");
return availableAmount;
}

/**
* @notice Withdraws the contract balance to the beneficiary
* @param amount The amount to withdraw
*/
function withdrawToBeneficiary(uint256 amount) external {
require(msg.sender == beneficiary, "Only the beneficiary can withdraw");
require(amount <= calculateAvailableAmountForBeneficiary(), "Insufficient available amount");

Check failure on line 198 in contracts/contracts/coordination/Subscription.sol

View workflow job for this annotation

GitHub Actions / linting

Replace amount·<=·calculateAvailableAmountForBeneficiary(),·"Insufficient·available·amount" with ⏎············amount·<=·calculateAvailableAmountForBeneficiary(),⏎············"Insufficient·available·amount"⏎········
feeToken.safeTransfer(beneficiary, amount);

emit WithdrawalToBeneficiary(beneficiary, amount);
}

Expand Down

0 comments on commit 98dc648

Please sign in to comment.