Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 committed Aug 14, 2024
1 parent 0bf6c08 commit 6954b96
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/PayGatewayModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ contract PayGatewayModule is EIP712, ModularModule, ReentrancyGuard {
error PayGatewayVerificationFailed();
error PayGatewayFailedToForward();
error PayGatewayRequestExpired(uint256 expirationTimestamp);
error PaymentsGatewayMsgValueNotZero();

/*//////////////////////////////////////////////////////////////
EXTENSION CONFIG
Expand Down Expand Up @@ -151,6 +152,11 @@ contract PayGatewayModule is EIP712, ModularModule, ReentrancyGuard {
External / public functions
//////////////////////////////////////////////////////////////*/

/// @notice check if transaction id has been used / processed
function isProcessed(bytes32 transactionId) external view returns (bool) {
return PayGatewayModuleStorage.data().processed[transactionId];
}

/// @notice some bridges may refund need a way to get funds back to user
function withdrawTo(address tokenAddress, uint256 tokenAmount, address payable receiver) public nonReentrant {
if (_isTokenERC20(tokenAddress)) {
Expand Down Expand Up @@ -269,13 +275,17 @@ contract PayGatewayModule is EIP712, ModularModule, ReentrancyGuard {
}

if (_isTokenNative(tokenAddress)) {
if (msg.value < tokenAmount) {
if (msg.value != tokenAmount) {
revert PayGatewayMismatchedValue(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 6954b96

Please sign in to comment.