Skip to content

Commit

Permalink
fix: dos if payment id frontran
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Nov 26, 2024
1 parent 2448b7f commit f40c1f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
9 changes: 0 additions & 9 deletions src/contracts/Grateful.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ contract Grateful is IGrateful, Ownable2Step, ReentrancyGuard {
/// @inheritdoc IGrateful
mapping(address => CustomFee) public override customFees;

/// @inheritdoc IGrateful
mapping(uint256 => bool) public paymentIds;

/// @inheritdoc IGrateful
uint256 public performanceFee;

Expand Down Expand Up @@ -458,12 +455,6 @@ contract Grateful is IGrateful, Ownable2Step, ReentrancyGuard {
revert Grateful_InvalidAddress();
}

// Check payment id
if (paymentIds[_paymentId]) {
revert Grateful_PaymentIdAlreadyUsed();
}
paymentIds[_paymentId] = true;

// Apply the fee
uint256 amountWithFee = applyFee(_merchant, _amount);
uint256 feeAmount = _amount - amountWithFee;
Expand Down
10 changes: 3 additions & 7 deletions src/interfaces/IGrateful.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ interface IGrateful {
/// @notice Thrown when the provided address is invalid.
error Grateful_InvalidAddress();

/// @notice Thrown when the precomputed address does not match the one-time address created.
error Grateful_PrecomputedAddressMismatch();

/*///////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -208,13 +211,6 @@ interface IGrateful {
address _merchant
) external view returns (bool isSet, uint256 fee);

/// @notice Returns if a paymentId has been used.
/// @param paymentId The payment id.
/// @return isUsed True if the payment id has been used.
function paymentIds(
uint256 paymentId
) external view returns (bool isUsed);

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit f40c1f6

Please sign in to comment.