Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescuable721 #34

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/contracts/utils/Rescuable721.sol
defijesus marked this conversation as resolved.
Show resolved Hide resolved
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
Loading