From caf72cb921608caac1d41cf94e8a861a0d95d317 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 3 Apr 2024 20:50:29 +0530 Subject: [PATCH] [L-2] Completing the token purchase potentially locks native tokens --- src/PaymentsGateway.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PaymentsGateway.sol b/src/PaymentsGateway.sol index 7536cae..42f25a0 100644 --- a/src/PaymentsGateway.sol +++ b/src/PaymentsGateway.sol @@ -103,6 +103,7 @@ contract PaymentsGateway is EIP712, Ownable, ReentrancyGuard { error PaymentsGatewayVerificationFailed(); error PaymentsGatewayFailedToForward(); error PaymentsGatewayRequestExpired(uint256 expirationTimestamp); + error PaymentsGatewayMsgValueNotZero(); /*/////////////////////////////////////////////////////////////// Constructor @@ -228,13 +229,16 @@ contract PaymentsGateway is EIP712, Ownable, ReentrancyGuard { } if (_isTokenNative(tokenAddress)) { - if (msg.value < tokenAmount) { + if (msg.value != tokenAmount) { revert PaymentsGatewayMismatchedValue(tokenAmount, msg.value); } } // pull user funds if (_isTokenERC20(tokenAddress)) { + if (msg.value != 0) { + revert PaymentsGatewayMsgValueNotZero(); + } SafeTransferLib.safeTransferFrom(tokenAddress, msg.sender, receiverAddress, tokenAmount); } else { SafeTransferLib.safeTransferETH(receiverAddress, tokenAmount);