ERC721ReceiverMock.sol 631 B

123456789101112131415161718192021
  1. pragma solidity ^0.4.24;
  2. import "../token/ERC721/IERC721Receiver.sol";
  3. contract ERC721ReceiverMock is IERC721Receiver {
  4. bytes4 private _retval;
  5. bool private _reverts;
  6. event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
  7. constructor (bytes4 retval, bool reverts) public {
  8. _retval = retval;
  9. _reverts = reverts;
  10. }
  11. function onERC721Received(address operator, address from, uint256 tokenId, bytes data) public returns (bytes4) {
  12. require(!_reverts);
  13. emit Received(operator, from, tokenId, data, gasleft());
  14. return _retval;
  15. }
  16. }