From 349ddb8c3a71bfdf7501953e7e70045c76644a68 Mon Sep 17 00:00:00 2001 From: Tina Zheng Date: Tue, 21 Nov 2023 15:02:06 -0500 Subject: [PATCH] use using .. for syntax for TransferHelper --- contracts/base/ERC721Permit.sol | 5 ++++- contracts/base/PeripheryPayments.sol | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/contracts/base/ERC721Permit.sol b/contracts/base/ERC721Permit.sol index f9af9273..707e381b 100644 --- a/contracts/base/ERC721Permit.sol +++ b/contracts/base/ERC721Permit.sol @@ -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 { diff --git a/contracts/base/PeripheryPayments.sol b/contracts/base/PeripheryPayments.sol index 2fa42cd0..4714bf42 100644 --- a/contracts/base/PeripheryPayments.sol +++ b/contracts/base/PeripheryPayments.sol @@ -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 { @@ -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 @@ -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); } } }