Skip to content

Commit

Permalink
Rescuable721 (#34)
Browse files Browse the repository at this point in the history
* ready for review

* add interface and natspec

* ready for review

* rename emergency transfer function

* add fuzzing

---------

Co-authored-by: defijesus.eth <[email protected]>
  • Loading branch information
defijesus and defijesus.eth authored Jul 8, 2024
1 parent 43cbda7 commit 96ab2a4
Show file tree
Hide file tree
Showing 4 changed files with 1,064 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/contracts/utils/Rescuable721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import {IRescuable721, IERC721} from './interfaces/IRescuable721.sol';
import {Rescuable} from './Rescuable.sol';

/**
* @title Rescuable721
* @author defijesus.eth
* @notice abstract contract that extend Rescuable with the methods to rescue ERC721 tokens from a contract
*/
abstract contract Rescuable721 is Rescuable, IRescuable721 {

/// @inheritdoc IRescuable721
function emergency721TokenTransfer(
address erc721Token,
address to,
uint256 tokenId
) external virtual onlyRescueGuardian {
IERC721(erc721Token).transferFrom(address(this), to, tokenId);

emit ERC721Rescued(msg.sender, erc721Token, to, tokenId);
}
}
35 changes: 35 additions & 0 deletions src/contracts/utils/interfaces/IRescuable721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

/**
* @title IRescuable721
* @author defijesus.eth
* @notice interface containing the objects, events and methods definitions of the Rescuable721 contract
*/
interface IRescuable721 {
/**
* @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 the id of the token rescued
*/
event ERC721Rescued(
address indexed caller,
address indexed token,
address indexed to,
uint256 tokenId
);

/**
* @notice method called to rescue a ERC721 token sent erroneously to the contract. Only callable by owner
* @param erc721Token address of the token to rescue
* @param to address to send the token
* @param tokenId of token to rescue
*/
function emergency721TokenTransfer(address erc721Token, address to, uint256 tokenId) external;
}

interface IERC721 {
function transferFrom(address from, address to, uint256 tokenId) external;
}
Loading

0 comments on commit 96ab2a4

Please sign in to comment.