Skip to content

Commit

Permalink
use using .. for syntax for TransferHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaszheng committed Nov 21, 2023
1 parent 30479c6 commit 349ddb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion contracts/base/ERC721Permit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ abstract contract ERC721Permit is ERC721, IERC721Permit {
if (spender == owner) revert ApprovalToOwner();

if (owner.code.length > 0) {
if (IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) != IERC1271.isValidSignature.selector) {
if (
IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v))
!= IERC1271.isValidSignature.selector
) {
revert Unauthorized();
}
} else {
Expand Down
11 changes: 7 additions & 4 deletions contracts/base/PeripheryPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {IPeripheryPayments} from "../interfaces/IPeripheryPayments.sol";

import "../libraries/TransferHelper.sol";

using TransferHelper for address;
using TransferHelper for IERC20Minimal;

error InsufficientToken();

abstract contract PeripheryPayments is IPeripheryPayments {
Expand All @@ -17,13 +20,13 @@ abstract contract PeripheryPayments is IPeripheryPayments {
if (balanceToken < amountMinimum) revert InsufficientToken();

if (balanceToken > 0) {
TransferHelper.safeTransfer(IERC20Minimal(token), recipient, balanceToken);
IERC20Minimal(token).safeTransfer(recipient, balanceToken);
}
}

/// @inheritdoc IPeripheryPayments
function refundETH() external payable override {
if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance);
if (address(this).balance > 0) msg.sender.safeTransferETH(address(this).balance);
}

/// @param token The token to pay
Expand All @@ -33,10 +36,10 @@ abstract contract PeripheryPayments is IPeripheryPayments {
function pay(address token, address payer, address recipient, uint256 value) internal {
if (payer == address(this)) {
// pay with tokens already in the contract (for the exact input multihop case)
TransferHelper.safeTransfer(IERC20Minimal(token), recipient, value);
IERC20Minimal(token).safeTransfer(recipient, value);
} else {
// pull payment
TransferHelper.safeTransferFrom(IERC20Minimal(token), payer, recipient, value);
IERC20Minimal(token).safeTransferFrom(payer, recipient, value);
}
}
}

0 comments on commit 349ddb8

Please sign in to comment.