Skip to content

Commit

Permalink
[L-2] Completing the token purchase potentially locks native tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 committed Apr 3, 2024
1 parent f2db1bf commit caf72cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PaymentsGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ contract PaymentsGateway is EIP712, Ownable, ReentrancyGuard {
error PaymentsGatewayVerificationFailed();
error PaymentsGatewayFailedToForward();
error PaymentsGatewayRequestExpired(uint256 expirationTimestamp);
error PaymentsGatewayMsgValueNotZero();

/*///////////////////////////////////////////////////////////////
Constructor
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit caf72cb

Please sign in to comment.