Skip to content

Commit

Permalink
refactor: convert modifier to internal method
Browse files Browse the repository at this point in the history
  • Loading branch information
viraj124 committed Jun 29, 2023
1 parent aad03da commit 6f016a3
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions contracts/abstract/JBPayoutRedemptionPaymentTerminal3_1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ abstract contract JBPayoutRedemptionPaymentTerminal3_1_1 is
error REDEEM_TO_ZERO_ADDRESS();
error TERMINAL_TOKENS_INCOMPATIBLE();

//*********************************************************************//
// ---------------------------- modifiers ---------------------------- //
//*********************************************************************//

/**
@notice
A modifier that verifies this terminal is a terminal of provided project ID.
*/
modifier isTerminalOf(uint256 _projectId) {
if (!directory.isTerminalOf(_projectId, this)) revert PROJECT_TERMINAL_MISMATCH();
_;
}

//*********************************************************************//
// --------------------- internal stored constants ------------------- //
Expand Down Expand Up @@ -351,9 +339,12 @@ abstract contract JBPayoutRedemptionPaymentTerminal3_1_1 is
bool _preferClaimedTokens,
string calldata _memo,
bytes calldata _metadata
) external payable virtual override isTerminalOf(_projectId) returns (uint256) {
) external payable virtual override returns (uint256) {
_token; // Prevents unused var compiler and natspec complaints.

// valid terminal check
isTerminalOf(_projectId);

// ETH shouldn't be sent if this terminal's token isn't ETH.
if (token != JBTokens.ETH) {
if (msg.value != 0) revert NO_MSG_VALUE_ALLOWED();
Expand Down Expand Up @@ -576,7 +567,10 @@ abstract contract JBPayoutRedemptionPaymentTerminal3_1_1 is
address _token,
string calldata _memo,
bytes calldata _metadata
) external payable virtual override isTerminalOf(_projectId) {
) external payable virtual override {
// valid terminal check
isTerminalOf(_projectId);

// Do not refund held fees by default.
addToBalanceOf(_projectId, _amount, _token, false, _memo, _metadata);
}
Expand Down Expand Up @@ -709,7 +703,10 @@ abstract contract JBPayoutRedemptionPaymentTerminal3_1_1 is
bool _shouldRefundHeldFees,
string calldata _memo,
bytes calldata _metadata
) public payable virtual override isTerminalOf(_projectId) {
) public payable virtual override {
// valid terminal check
isTerminalOf(_projectId);

_token; // Prevents unused var compiler and natspec complaints.

// If this terminal's token isn't ETH, make sure no msg.value was sent, then transfer the tokens in from msg.sender.
Expand Down Expand Up @@ -775,6 +772,14 @@ abstract contract JBPayoutRedemptionPaymentTerminal3_1_1 is
_amount; // Prevents unused var compiler and natspec complaints.
}

/**
@notice
Verifies this terminal is a terminal of provided project ID.
*/
function isTerminalOf(uint256 _projectId) internal view {
if (!directory.isTerminalOf(_projectId, this)) revert PROJECT_TERMINAL_MISMATCH();
}

/**
@notice
Holders can redeem their tokens to claim the project's overflowed tokens, or to trigger rules determined by the project's current funding cycle's data source.
Expand Down

0 comments on commit 6f016a3

Please sign in to comment.