ERC721ReceiverMock.sol 649 B

1234567891011121314151617181920212223
  1. pragma solidity ^0.5.7;
  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 memory data)
  12. public returns (bytes4)
  13. {
  14. require(!_reverts);
  15. emit Received(operator, from, tokenId, data, gasleft());
  16. return _retval;
  17. }
  18. }