File size: 2,157 Bytes
cc183a1 | 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 55 56 57 58 59 60 61 62 63 64 65 66 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
contract DualVault13 is IERC721Receiver, IERC1155Receiver {
address public immutable guildAdmin;
bool public acceptsERC721;
bool public acceptsERC1155;
event AcceptanceUpdated(bool acceptsERC721, bool acceptsERC1155);
constructor(bool initialERC721, bool initialERC1155) {
guildAdmin = msg.sender;
acceptsERC721 = initialERC721;
acceptsERC1155 = initialERC1155;
}
function setAcceptance(bool erc721, bool erc1155) external {
require(msg.sender == guildAdmin, "only admin");
acceptsERC721 = erc721;
acceptsERC1155 = erc1155;
emit AcceptanceUpdated(erc721, erc1155);
}
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external view override returns (bytes4) {
require(acceptsERC721, "ERC721 safe transfer rejected");
return this.onERC721Received.selector;
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) external view override returns (bytes4) {
require(acceptsERC1155, "ERC1155 safe transfer rejected");
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external view override returns (bytes4) {
require(acceptsERC1155, "ERC1155 safe transfer rejected");
return this.onERC1155BatchReceived.selector;
}
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
return interfaceId == type(IERC721Receiver).interfaceId
|| interfaceId == type(IERC1155Receiver).interfaceId
|| interfaceId == type(IERC165).interfaceId;
}
}
|