Skip to content

Commit

Permalink
chore: use singular form for CEI
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg committed Apr 11, 2024
1 parent a03ba4a commit 40cca4a
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/SablierV2OpenEnded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
uint256 streamIdsCount = streamIds.length;
uint256 amountsCount = amounts.length;

// Checks: count of `streamIds` matches count of `amounts`.
// Check: count of `streamIds` matches count of `amounts`.
if (streamIdsCount != amountsCount) {
revert Errors.SablierV2OpenEnded_DepositArrayCountsNotEqual(streamIdsCount, amountsCount);
}
Expand All @@ -176,7 +176,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
for (uint256 i = 0; i < streamIdsCount; ++i) {
streamId = streamIds[i];

// Checks: the stream is not canceled.
// Check: the stream is not canceled.
if (isCanceled(streamId)) {
revert Errors.SablierV2OpenEnded_StreamCanceled(streamId);
}
Expand Down Expand Up @@ -336,14 +336,14 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope

/// @dev See the documentation for the user-facing functions that call this internal function.
function _adjustRatePerSecond(uint256 streamId, uint128 newRatePerSecond) internal {
// Checks: the new rate per second is not zero.
// Check: the new rate per second is not zero.
if (newRatePerSecond == 0) {
revert Errors.SablierV2OpenEnded_RatePerSecondZero();
}

uint128 oldRatePerSecond = _streams[streamId].ratePerSecond;

// Checks: the new rate per second is not equal to the actual rate per second.
// Check: the new rate per second is not equal to the actual rate per second.
if (newRatePerSecond == oldRatePerSecond) {
revert Errors.SablierV2OpenEnded_ratePerSecondNotDifferent(newRatePerSecond);
}
Expand All @@ -354,10 +354,10 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
// in case of a bug.
_checkCalculatedAmount(streamId, recipientAmount);

// Effects: change the rate per second.
// Effect: change the rate per second.
_streams[streamId].ratePerSecond = newRatePerSecond;

// Effects: update the stream time.
// Effect: update the stream time.
_updateTime(streamId, uint40(block.timestamp));

// Effects and Interactions: withdraw the assets to the recipient, if any assets available.
Expand Down Expand Up @@ -388,10 +388,10 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
// condition is checked to avoid exploits in case of a bug.
_checkCalculatedAmount(streamId, sum);

// Effects: set the stream as canceled.
// Effect: set the stream as canceled.
_streams[streamId].isCanceled = true;

// Effects: set the rate per second to zero.
// Effect: set the rate per second to zero.
_streams[streamId].ratePerSecond = 0;

// Effects and Interactions: refund the sender, if any assets available.
Expand Down Expand Up @@ -421,32 +421,32 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
noDelegateCall
returns (uint256 streamId)
{
// Checks: the sender is not the zero address.
// Check: the sender is not the zero address.
if (sender == address(0)) {
revert Errors.SablierV2OpenEnded_SenderZeroAddress();
}

// Checks: the recipient is not the zero address.
// Check: the recipient is not the zero address.
if (recipient == address(0)) {
revert Errors.SablierV2OpenEnded_RecipientZeroAddress();
}

// Checks: the rate per second is not zero.
// Check: the rate per second is not zero.
if (ratePerSecond == 0) {
revert Errors.SablierV2OpenEnded_RatePerSecondZero();
}

uint8 assetDecimals = _safeAssetDecimals(address(asset));

// Checks: the asset does not have decimals.
// Check: the asset does not have decimals.
if (assetDecimals == 0) {
revert Errors.SablierV2OpenEnded_InvalidAssetDecimals(asset);
}

// Load the stream id.
streamId = nextStreamId;

// Effects: create the stream.
// Effect: create the stream.
_streams[streamId] = OpenEnded.Stream({
asset: asset,
assetDecimals: assetDecimals,
Expand All @@ -459,7 +459,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
sender: sender
});

// Effects: bump the next stream id.
// Effect: bump the next stream id.
// Using unchecked arithmetic because this calculation cannot realistically overflow, ever.
unchecked {
nextStreamId = streamId + 1;
Expand All @@ -473,12 +473,12 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope

/// @dev See the documentation for the user-facing functions that call this internal function.
function _deposit(uint256 streamId, uint128 amount) internal {
// Checks: the amount is not zero.
// Check: the amount is not zero.
if (amount == 0) {
revert Errors.SablierV2OpenEnded_DepositAmountZero();
}

// Effects: update the stream balance.
// Effect: update the stream balance.
_streams[streamId].balance += amount;

// Retrieve the ERC-20 asset from storage.
Expand All @@ -487,7 +487,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
// Calculate the transfer amount.
uint128 transferAmount = _calculateTransferAmount(streamId, amount);

// Interactions: transfer the deposit amount.
// Interaction: transfer the deposit amount.
asset.safeTransferFrom(msg.sender, address(this), transferAmount);

// Log the deposit.
Expand All @@ -496,13 +496,13 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope

/// @dev Helper function to update the `balance` and to perform the ERC-20 transfer.
function _extractFromStream(uint256 streamId, address to, uint128 amount) internal {
// Effects: update the stream balance.
// Effect: update the stream balance.
_streams[streamId].balance -= amount;

// Calculate the transfer amount.
uint128 transferAmount = _calculateTransferAmount(streamId, amount);

// Interactions: perform the ERC-20 transfer.
// Interaction: perform the ERC-20 transfer.
_streams[streamId].asset.safeTransfer(to, transferAmount);
}

Expand All @@ -511,12 +511,12 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
address sender = _streams[streamId].sender;
uint128 refundableAmount = _refundableAmountOf(streamId, uint40(block.timestamp));

// Checks: the amount is not zero.
// Check: the amount is not zero.
if (amount == 0) {
revert Errors.SablierV2OpenEnded_RefundAmountZero();
}

// Checks: the withdraw amount is not greater than the refundable amount.
// Check: the withdraw amount is not greater than the refundable amount.
if (amount > refundableAmount) {
revert Errors.SablierV2OpenEnded_Overrefund(streamId, amount, refundableAmount);
}
Expand All @@ -538,23 +538,23 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
notNull(streamId)
onlySender(streamId)
{
// Checks: the stream is canceled.
// Check: the stream is canceled.
if (!_streams[streamId].isCanceled) {
revert Errors.SablierV2OpenEnded_StreamNotCanceled(streamId);
}

// Checks: the rate per second is not zero.
// Check: the rate per second is not zero.
if (ratePerSecond == 0) {
revert Errors.SablierV2OpenEnded_RatePerSecondZero();
}

// Effects: set the rate per second.
// Effect: set the rate per second.
_streams[streamId].ratePerSecond = ratePerSecond;

// Effects: set the stream as not canceled.
// Effect: set the stream as not canceled.
_streams[streamId].isCanceled = false;

// Effects: update the stream time.
// Effect: update the stream time.
_updateTime(streamId, uint40(block.timestamp));

// Log the restart.
Expand All @@ -568,7 +568,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope

/// @dev See the documentation for the user-facing functions that call this internal function.
function _withdraw(uint256 streamId, address to, uint40 time) internal noDelegateCall notCanceled(streamId) {
// Checks: the withdrawal address is not zero.
// Check: the withdrawal address is not zero.
if (to == address(0)) {
revert Errors.SablierV2OpenEnded_WithdrawToZeroAddress();
}
Expand All @@ -583,12 +583,12 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope

uint40 lastTimeUpdate = _streams[streamId].lastTimeUpdate;

// Checks: the withdrawal time is greater than the `lastTimeUpdate`.
// Check: the withdrawal time is greater than the `lastTimeUpdate`.
if (time <= lastTimeUpdate) {
revert Errors.SablierV2OpenEnded_WithdrawalTimeNotGreaterThanLastUpdate(time, lastTimeUpdate);
}

// Checks: the time reference is not in the future.
// Check: the time reference is not in the future.
if (time > uint40(block.timestamp)) {
revert Errors.SablierV2OpenEnded_WithdrawalTimeInTheFuture(time, block.timestamp);
}
Expand All @@ -600,7 +600,7 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
// in case of a bug.
_checkCalculatedAmount(streamId, withdrawAmount);

// Effects: update the stream time.
// Effect: update the stream time.
_updateTime(streamId, time);

// Effects and interactions: update the `balance` and perform the ERC-20 transfer.
Expand Down

0 comments on commit 40cca4a

Please sign in to comment.