Skip to content

Commit

Permalink
chore: rename left 'Invoice*' docs/methods to 'Payment*'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielstoica committed Nov 15, 2024
1 parent 10b624d commit 8fca235
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/modules/payment-module/PaymentModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ contract PaymentModule is IPaymentModule, StreamManager {
if (request.config.asset == address(0)) {
// Checks: the payment amount matches the request value
if (msg.value < request.config.amount) {
revert Errors.PaymentAmountLessThanInvoiceValue({ amount: request.config.amount });
revert Errors.PaymentAmountLessThanRequestedAmount({ amount: request.config.amount });
}

// Interactions: pay the recipient with native token (ETH)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/payment-module/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library Errors {
error ZeroPaymentAmount();

/// @notice Thrown when the payment amount is less than the payment request value
error PaymentAmountLessThanInvoiceValue(uint256 amount);
error PaymentAmountLessThanRequestedAmount(uint256 amount);

/// @notice Thrown when a payment in the native token (ETH) fails
error NativeTokenPaymentFailed();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/payment-module/libraries/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.26;
import { Types } from "./Types.sol";

/// @title Helpers
/// @notice Library with helpers used across the {InvoiceModule} contract
/// @notice Library with helpers used across the {PaymentModule} contract
library Helpers {
/// @dev Calculates the number of payments that must be done for a recurring transfer or tranched stream paymentRequest
/// Notes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract TransferFrom_Integration_Concret_Test is TransferFrom_Integration_Share
// Make Bob the payer for the payment request
vm.startPrank({ msgSender: users.bob });
// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].payment.amount });
// Pay the payment request
Expand All @@ -47,7 +47,7 @@ contract TransferFrom_Integration_Concret_Test is TransferFrom_Integration_Share
// Make Eve's space the caller which is the recipient of the payment request
vm.startPrank({ msgSender: address(space) });
// Approve the {InvoiceModule} to transfer the `streamId` stream on behalf of the Eve's space
// Approve the {PaymentModule} to transfer the `streamId` stream on behalf of the Eve's space
sablierV2LockupLinear.approve({ to: address(paymentModule), tokenId: streamId });
// Run the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
CancelRequest_Integration_Shared_Test.setUp();
}

function test_RevertWhen_InvoiceIsPaid() external {
function test_RevertWhen_PaymentIsPaid() external {
// Set the one-off ETH transfer payment request as current one
uint256 paymentRequestId = 2;

Expand Down Expand Up @@ -50,7 +50,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
paymentModule.cancelRequest({ requestId: paymentRequestId });
}

function test_RevertWhen_PaymentMethodTransfer_SenderNotInvoiceRecipient()
function test_RevertWhen_PaymentMethodTransfer_SenderNotPaymentRecipient()
external
whenRequestNotAlreadyPaid
whenRequestNotCanceled
Expand All @@ -74,7 +74,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
whenRequestNotAlreadyPaid
whenRequestNotCanceled
givenPaymentMethodTransfer
whenSenderInvoiceRecipient
whenRequestSenderRecipient
{
// Set the one-off ETH transfer payment request as current one
uint256 paymentRequestId = 2;
Expand All @@ -94,12 +94,12 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
assertEq(uint8(paymentRequestStatus), uint8(Types.Status.Canceled));
}

function test_RevertWhen_PaymentMethodLinearStream_StatusPending_SenderNotInvoiceRecipient()
function test_RevertWhen_PaymentMethodLinearStream_StatusPending_SenderNotPaymentRecipient()
external
whenRequestNotAlreadyPaid
whenRequestNotCanceled
givenPaymentMethodLinearStream
givenInvoiceStatusPending
givenRequestStatusPending
{
// Set current paymentRequest as a linear stream-based one
uint256 paymentRequestId = 5;
Expand All @@ -119,8 +119,8 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
whenRequestNotAlreadyPaid
whenRequestNotCanceled
givenPaymentMethodLinearStream
givenInvoiceStatusPending
whenSenderInvoiceRecipient
givenRequestStatusPending
whenRequestSenderRecipient
{
// Set current paymentRequest as a linear stream-based one
uint256 paymentRequestId = 5;
Expand Down Expand Up @@ -154,7 +154,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
// Make Bob the payer of the payment request (also Bob will be the stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand Down Expand Up @@ -187,7 +187,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
// Make Bob the payer of the payment request (also Bob will be the initial stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand All @@ -210,12 +210,12 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
assertEq(uint8(paymentRequestStatus), uint8(Types.Status.Canceled));
}

function test_RevertWhen_PaymentMethodTranchedStream_StatusPending_SenderNotInvoiceRecipient()
function test_RevertWhen_PaymentMethodTranchedStream_StatusPending_SenderNotPaymentRecipient()
external
whenRequestNotAlreadyPaid
whenRequestNotCanceled
givenPaymentMethodTranchedStream
givenInvoiceStatusPending
givenRequestStatusPending
{
// Set current paymentRequest as a tranched stream-based one
uint256 paymentRequestId = 5;
Expand All @@ -235,8 +235,8 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
whenRequestNotAlreadyPaid
whenRequestNotCanceled
givenPaymentMethodTranchedStream
givenInvoiceStatusPending
whenSenderInvoiceRecipient
givenRequestStatusPending
whenRequestSenderRecipient
{
// Set current paymentRequest as a tranched stream-based one
uint256 paymentRequestId = 5;
Expand Down Expand Up @@ -270,7 +270,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
// Make Bob the payer of the payment request (also Bob will be the stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand Down Expand Up @@ -303,7 +303,7 @@ contract CancelRequest_Integration_Concret_Test is CancelRequest_Integration_Sha
// Make Bob the payer of the payment request (also Bob will be the initial stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ contract CreateRequest_Integration_Concret_Test is CreateRequest_Integration_Sha
// Create a recurring transfer payment request that must be paid on a monthly basis
// Hence, the interval between the start and end time must be at least 1 month
paymentRequest =
createInvoiceWithRecurringTransfer({ recurrence: Types.Recurrence.Monthly, recipient: address(space) });
createPaymentWithRecurringTransfer({ recurrence: Types.Recurrence.Monthly, recipient: address(space) });

// Alter the end time to be 3 weeks from now
paymentRequest.endTime = uint40(block.timestamp) + 3 weeks;
Expand Down Expand Up @@ -236,7 +236,7 @@ contract CreateRequest_Integration_Concret_Test is CreateRequest_Integration_Sha

// Create a recurring transfer payment request that must be paid on weekly basis
paymentRequest =
createInvoiceWithRecurringTransfer({ recurrence: Types.Recurrence.Weekly, recipient: address(space) });
createPaymentWithRecurringTransfer({ recurrence: Types.Recurrence.Weekly, recipient: address(space) });

// Create the calldata for the Payment Module execution
bytes memory data = abi.encodeWithSignature(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Errors } from "../../../../utils/Errors.sol";

import { LockupLinear, LockupTranched } from "@sablier/v2-core/src/types/DataTypes.sol";

contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Test {
contract PayPayment_Integration_Concret_Test is PayRequest_Integration_Shared_Test {
function setUp() public virtual override {
PayRequest_Integration_Shared_Test.setUp();
}
Expand All @@ -28,7 +28,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
// Make Bob the payer for the default paymentRequest
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the ERC-20 token on Bob's behalf
// Approve the {PaymentModule} to transfer the ERC-20 token on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay first the payment request
Expand Down Expand Up @@ -61,7 +61,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
paymentModule.payRequest({ requestId: paymentRequestId });
}

function test_RevertWhen_PaymentMethodTransfer_PaymentAmountLessThanInvoiceValue()
function test_RevertWhen_PaymentMethodTransfer_PaymentAmountLessThanRequestedAmount()
external
whenRequestNotNull
whenRequestNotAlreadyPaid
Expand All @@ -75,10 +75,10 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
// Make Bob the payer for the default paymentRequest
vm.startPrank({ msgSender: users.bob });

// Expect the call to be reverted with the {PaymentAmountLessThanInvoiceValue} error
// Expect the call to be reverted with the {PaymentAmountLessThanRequestedAmount} error
vm.expectRevert(
abi.encodeWithSelector(
Errors.PaymentAmountLessThanInvoiceValue.selector, paymentRequests[paymentRequestId].config.amount
Errors.PaymentAmountLessThanRequestedAmount.selector, paymentRequests[paymentRequestId].config.amount
)
);

Expand All @@ -95,7 +95,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
whenRequestNotCanceled
givenPaymentMethodTransfer
givenPaymentAmountInNativeToken
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
{
// Create a mock payment request with a one-off ETH transfer from the Eve's space
Types.PaymentRequest memory paymentRequest =
Expand All @@ -107,7 +107,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
// Make Eve's space the caller for the next call to approve & transfer the payment request NFT to a bad receiver
//vm.startPrank({ msgSender: address(space) });

// Approve the {InvoiceModule} to transfer the token
// Approve the {PaymentModule} to transfer the token
//paymentModule.approve({ to: address(paymentModule), tokenrequestId: paymentRequestId });

// Transfer the payment request to a bad receiver so we can test against `NativeTokenPaymentFailed`
Expand All @@ -130,7 +130,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
whenRequestNotCanceled
givenPaymentMethodTransfer
givenPaymentAmountInNativeToken
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
whenNativeTokenPaymentSucceeds
{
// Set the one-off ETH transfer payment request as current one
Expand Down Expand Up @@ -182,7 +182,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
whenRequestNotCanceled
givenPaymentMethodTransfer
givenPaymentAmountInERC20Tokens
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
{
// Set the recurring USDT transfer payment request as current one
uint256 paymentRequestId = 3;
Expand All @@ -194,7 +194,7 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
uint256 balanceOfBobBefore = usdt.balanceOf(users.bob);
uint256 balanceOfRecipientBefore = usdt.balanceOf(address(space));

// Approve the {InvoiceModule} to transfer the ERC-20 tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the ERC-20 tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Expect the {RequestPaid} event to be emitted
Expand Down Expand Up @@ -238,15 +238,15 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
whenRequestNotCanceled
givenPaymentMethodLinearStream
givenPaymentAmountInERC20Tokens
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
{
// Set the linear USDT stream-based paymentRequest as current one
uint256 paymentRequestId = 4;

// Make Bob the payer for the default paymentRequest
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the ERC-20 tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the ERC-20 tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Expect the {RequestPaid} event to be emitted
Expand Down Expand Up @@ -293,15 +293,15 @@ contract PayInvoice_Integration_Concret_Test is PayRequest_Integration_Shared_Te
whenRequestNotCanceled
givenPaymentMethodTranchedStream
givenPaymentAmountInERC20Tokens
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
{
// Set the tranched USDT stream-based paymentRequest as current one
uint256 paymentRequestId = 5;

// Make Bob the payer for the default paymentRequest
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the ERC-20 tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the ERC-20 tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Expect the {RequestPaid} event to be emitted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ payRequest.t.sol
├── given the payment method is transfer
│ ├── given the payment amount is in native token (ETH)
│ │ ├── when the payment amount is less than the payment request value
│ │ │ └── it should revert with the {PaymentAmountLessThanInvoiceValue} error
│ │ │ └── it should revert with the {PaymentAmountLessThanRequestedAmount} error
│ │ └── when the payment amount IS equal to the payment request value
│ │ ├── when the native token transfer fails
│ │ │ └── it should revert with the {NativeTokenPaymentFailed} error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.26;
import { WithdrawLinearStream_Integration_Shared_Test } from "../../../shared/withdrawLinearStream.t.sol";
import { Types } from "./../../../../../src/modules/payment-module/libraries/Types.sol";

contract WithdrawLinearStream_Integration_Concret_Test is WithdrawLinearStream_Integration_Shared_Test {
contract WithdrawRequestStream_Integration_Concret_Test is WithdrawLinearStream_Integration_Shared_Test {
function setUp() public virtual override {
WithdrawLinearStream_Integration_Shared_Test.setUp();
}
Expand All @@ -18,7 +18,7 @@ contract WithdrawLinearStream_Integration_Concret_Test is WithdrawLinearStream_I
// Make Bob the payer of the payment request (also Bob will be the initial stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand Down Expand Up @@ -55,7 +55,7 @@ contract WithdrawLinearStream_Integration_Concret_Test is WithdrawLinearStream_I
// Make Bob the payer of the payment request (also Bob will be the initial stream sender)
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on Bob's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on Bob's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequests[paymentRequestId].config.amount });

// Pay the payment request first (status will be updated to `Accepted`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
withdrawStream.t.sol
withdrawRequestStream.t.sol
├── given the payment method is linear stream
│ └── given the payment request status is Ongoing
│ └── it should allow the payment request recipient to withdraw from the stream
Expand Down
6 changes: 3 additions & 3 deletions test/integration/fuzz/payRequest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract PayRequest_Integration_Fuzz_Test is PayRequest_Integration_Shared_Test
whenRequestNotCanceled
givenPaymentMethodTransfer
givenPaymentAmountInNativeToken
whenPaymentAmountEqualToInvoiceValue
whenPaymentAmountEqualToPaymentValue
whenNativeTokenPaymentSucceeds
{
// Discard bad fuzz inputs
Expand Down Expand Up @@ -59,7 +59,7 @@ contract PayRequest_Integration_Fuzz_Test is PayRequest_Integration_Shared_Test
})
});

// Create the calldata for the {InvoiceModule} execution
// Create the calldata for the {PaymentModule} execution
bytes memory data = abi.encodeWithSignature(
"createRequest((bool,bool,uint40,uint40,address,(uint8,uint8,uint40,address,uint128,uint256)))",
paymentRequest
Expand All @@ -79,7 +79,7 @@ contract PayRequest_Integration_Fuzz_Test is PayRequest_Integration_Shared_Test
// Make payer the caller to pay for the fuzzed paymentRequest
vm.startPrank({ msgSender: users.bob });

// Approve the {InvoiceModule} to transfer the USDT tokens on payer's behalf
// Approve the {PaymentModule} to transfer the USDT tokens on payer's behalf
usdt.approve({ spender: address(paymentModule), amount: paymentRequest.config.amount });

// Store the USDT balances of the payer and recipient before paying the payment request
Expand Down
Loading

0 comments on commit 8fca235

Please sign in to comment.