-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathTokenRecover.sol
More file actions
54 lines (48 loc) · 2.06 KB
/
Copy pathTokenRecover.sol
File metadata and controls
54 lines (48 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {RecoverERC20} from "./recover/RecoverERC20.sol";
import {RecoverERC721} from "./recover/RecoverERC721.sol";
/**
* @title TokenRecover
* @dev Allows the contract owner to recover any ERC-20 or ERC-721 token sent into the contract
* and sends them to a receiver.
*/
abstract contract TokenRecover is Ownable, RecoverERC20, RecoverERC721 {
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) Ownable(initialOwner) {}
/**
* @dev Recovers a `tokenAmount` of the ERC-20 `tokenAddress` locked into this contract
* and sends them to the `tokenReceiver` address.
*
* NOTE: restricting access to owner only. See `RecoverERC20::_recoverERC20`.
*
* @param tokenAddress The contract address of the token to recover.
* @param tokenReceiver The address that will receive the recovered tokens.
* @param tokenAmount Number of tokens to be recovered.
*/
function recoverERC20(address tokenAddress, address tokenReceiver, uint256 tokenAmount) public virtual onlyOwner {
_recoverERC20(tokenAddress, tokenReceiver, tokenAmount);
}
/**
* @dev Recovers the `tokenId` of the ERC-721 `tokenAddress` locked into this contract
* and sends it to the `tokenReceiver` address.
*
* NOTE: restricting access to owner only. See `RecoverERC721::_recoverERC721`.
*
* @param tokenAddress The contract address of the token to recover.
* @param tokenReceiver The address that will receive the recovered token.
* @param tokenId The identifier for the NFT to be recovered.
* @param data Additional data with no specified format.
*/
function recoverERC721(
address tokenAddress,
address tokenReceiver,
uint256 tokenId,
bytes memory data
) public virtual onlyOwner {
_recoverERC721(tokenAddress, tokenReceiver, tokenId, data);
}
}