From 300fe01a466b4ba56698e36bc92d6b5f0ad23413 Mon Sep 17 00:00:00 2001 From: "defijesus.eth" Date: Fri, 5 Jul 2024 02:44:52 +0100 Subject: [PATCH] ready for review --- src/contracts/utils/Rescuable721.sol | 24 ++++--------------- .../utils/interfaces/IRescuable721.sol | 16 ++++++------- test/Rescuable721.t.sol | 4 ++-- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/contracts/utils/Rescuable721.sol b/src/contracts/utils/Rescuable721.sol index 7a688df..5df0a0d 100644 --- a/src/contracts/utils/Rescuable721.sol +++ b/src/contracts/utils/Rescuable721.sol @@ -1,29 +1,18 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.8; -import {IRescuable721} from './interfaces/IRescuable721.sol'; - -interface IERC721 { - function transferFrom(address from, address to, uint256 tokenId) external; -} +import {IRescuable721, IERC721} from './interfaces/IRescuable721.sol'; +import {Rescuable} from './Rescuable.sol'; /** * @title Rescuable721 * @author defijesus.eth - * @notice abstract contract with the methods to rescue ERC721 tokens from a contract + * @notice abstract contract that extend Rescuable with the methods to rescue ERC721 tokens from a contract */ -abstract contract Rescuable721 is IRescuable721 { - - error ONLY_RESCUE_GUARDIAN(); - - /// @notice modifier that checks that caller is allowed address - modifier onlyRescueGuardian() { - if(msg.sender != whoCanRescue()) revert ONLY_RESCUE_GUARDIAN(); - _; - } +abstract contract Rescuable721 is Rescuable, IRescuable721 { /// @inheritdoc IRescuable721 - function emergencyTokenTransfer( + function rescue721( address erc721Token, address to, uint256 tokenId @@ -32,7 +21,4 @@ abstract contract Rescuable721 is IRescuable721 { emit ERC721Rescued(msg.sender, erc721Token, to, tokenId); } - - /// @inheritdoc IRescuable721 - function whoCanRescue() public view virtual returns (address); } diff --git a/src/contracts/utils/interfaces/IRescuable721.sol b/src/contracts/utils/interfaces/IRescuable721.sol index fa2900b..6f9432e 100644 --- a/src/contracts/utils/interfaces/IRescuable721.sol +++ b/src/contracts/utils/interfaces/IRescuable721.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.8; /** - * @title IRescuable + * @title IRescuable721 * @author defijesus.eth * @notice interface containing the objects, events and methods definitions of the Rescuable721 contract */ interface IRescuable721 { /** - * @notice emitted when erc20 tokens get rescued + * @notice emitted when erc721 tokens get rescued * @param caller address that triggers the rescue * @param token address of the rescued token * @param to address that will receive the rescued tokens - * @param tokenId quantity of tokens rescued + * @param tokenId the id of the token rescued */ event ERC721Rescued( address indexed caller, @@ -27,11 +27,9 @@ interface IRescuable721 { * @param to address to send the token * @param tokenId of token to rescue */ - function emergencyTokenTransfer(address erc721Token, address to, uint256 tokenId) external; + function rescue721(address erc721Token, address to, uint256 tokenId) external; +} - /** - * @notice method that defines the address that is allowed to rescue tokens - * @return the allowed address - */ - function whoCanRescue() external view returns (address); +interface IERC721 { + function transferFrom(address from, address to, uint256 tokenId) external; } diff --git a/test/Rescuable721.t.sol b/test/Rescuable721.t.sol index d2d2f5a..6633a10 100644 --- a/test/Rescuable721.t.sol +++ b/test/Rescuable721.t.sol @@ -48,7 +48,7 @@ contract Rescue721Test is Test { hoax(ALLOWED); vm.expectEmit(true, true, false, true); emit ERC721Rescued(ALLOWED, address(testToken), recipient, 1); - tokensReceiver.emergencyTokenTransfer(address(testToken), recipient, 1); + tokensReceiver.rescue721(address(testToken), recipient, 1); assertEq(testToken.balanceOf(address(tokensReceiver)), 0); assertEq(testToken.balanceOf(address(recipient)), 1); @@ -65,6 +65,6 @@ contract Rescue721Test is Test { address recipient = address(1230123519); vm.expectRevert(); - tokensReceiver.emergencyTokenTransfer(address(testToken), recipient, 1); + tokensReceiver.rescue721(address(testToken), recipient, 1); } }