mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openzeppelin-contracts/contracts/mocks/ERC721ReceiverMock.sol

26 lines
717 B

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
ERC721 full implementation (#803) * Rename current ERC721 implementation to BaseERC721 * Implement ERC721 optional & approveAll functionality * Support for new ERC721 interface - Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex * Add more tests for ERC721 * Implement suggestions by @dekz * Update comments in ERC721 contracts * Implement tokensByIndex extension - Remove restrictions from mock mint and burn calls * Add default implementation for metadata URI This allows token implementation to be non-abstract * Allow operators to call approve on a token * Remove gas stipend restriction in call to 721 receiver * Remove deprecated implementation We only want to keep the interface, for interacting with already deployed contracts * Add notice to isContract helper on constract constructors * Change natspec delimiters for consistency * Minor linting fixes * Add constant modifier to ERC721_RECEIVED magic value * Use 4-params safeTransferFrom for implementing the 3-params overload * Minor text changes in natspec comments * Use address(0) instead of 0 or 0x0 * Use if-statements instead of boolean one-liners for clarity :-( * Keep ownedTokensCount state var in sync in full ERC721 implementation * Fix incorrect comparison when burning ERC721 tokens with metadata * Use address(0) instead of 0 in one more place in ERC721 * Throw when querying balance for the zero address Required by the spec * Update links to approved version of EIP721 * Use explicit size for uint * Remove unneeded internal function in ERC721 Also rename addToken and removeToken for added clarity * Use underscore instead of 'do' prefix for internal methods in ERC721 * Fix failing test due to events reordering in ERC721 safe transfer * Fix bug introduced in 74db03ba06 * Remove do prefix for internal setTokenUri method * Allow transfers to self in ERC721
7 years ago
import "../token/ERC721/IERC721Receiver.sol";
ERC721 full implementation (#803) * Rename current ERC721 implementation to BaseERC721 * Implement ERC721 optional & approveAll functionality * Support for new ERC721 interface - Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex * Add more tests for ERC721 * Implement suggestions by @dekz * Update comments in ERC721 contracts * Implement tokensByIndex extension - Remove restrictions from mock mint and burn calls * Add default implementation for metadata URI This allows token implementation to be non-abstract * Allow operators to call approve on a token * Remove gas stipend restriction in call to 721 receiver * Remove deprecated implementation We only want to keep the interface, for interacting with already deployed contracts * Add notice to isContract helper on constract constructors * Change natspec delimiters for consistency * Minor linting fixes * Add constant modifier to ERC721_RECEIVED magic value * Use 4-params safeTransferFrom for implementing the 3-params overload * Minor text changes in natspec comments * Use address(0) instead of 0 or 0x0 * Use if-statements instead of boolean one-liners for clarity :-( * Keep ownedTokensCount state var in sync in full ERC721 implementation * Fix incorrect comparison when burning ERC721 tokens with metadata * Use address(0) instead of 0 in one more place in ERC721 * Throw when querying balance for the zero address Required by the spec * Update links to approved version of EIP721 * Use explicit size for uint * Remove unneeded internal function in ERC721 Also rename addToken and removeToken for added clarity * Use underscore instead of 'do' prefix for internal methods in ERC721 * Fix failing test due to events reordering in ERC721 safe transfer * Fix bug introduced in 74db03ba06 * Remove do prefix for internal setTokenUri method * Allow transfers to self in ERC721
7 years ago
contract ERC721ReceiverMock is IERC721Receiver {
bytes4 private _retval;
bool private _reverts;
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
ERC721 full implementation (#803) * Rename current ERC721 implementation to BaseERC721 * Implement ERC721 optional & approveAll functionality * Support for new ERC721 interface - Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex * Add more tests for ERC721 * Implement suggestions by @dekz * Update comments in ERC721 contracts * Implement tokensByIndex extension - Remove restrictions from mock mint and burn calls * Add default implementation for metadata URI This allows token implementation to be non-abstract * Allow operators to call approve on a token * Remove gas stipend restriction in call to 721 receiver * Remove deprecated implementation We only want to keep the interface, for interacting with already deployed contracts * Add notice to isContract helper on constract constructors * Change natspec delimiters for consistency * Minor linting fixes * Add constant modifier to ERC721_RECEIVED magic value * Use 4-params safeTransferFrom for implementing the 3-params overload * Minor text changes in natspec comments * Use address(0) instead of 0 or 0x0 * Use if-statements instead of boolean one-liners for clarity :-( * Keep ownedTokensCount state var in sync in full ERC721 implementation * Fix incorrect comparison when burning ERC721 tokens with metadata * Use address(0) instead of 0 in one more place in ERC721 * Throw when querying balance for the zero address Required by the spec * Update links to approved version of EIP721 * Use explicit size for uint * Remove unneeded internal function in ERC721 Also rename addToken and removeToken for added clarity * Use underscore instead of 'do' prefix for internal methods in ERC721 * Fix failing test due to events reordering in ERC721 safe transfer * Fix bug introduced in 74db03ba06 * Remove do prefix for internal setTokenUri method * Allow transfers to self in ERC721
7 years ago
constructor (bytes4 retval, bool reverts) {
_retval = retval;
_reverts = reverts;
}
ERC721 full implementation (#803) * Rename current ERC721 implementation to BaseERC721 * Implement ERC721 optional & approveAll functionality * Support for new ERC721 interface - Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex * Add more tests for ERC721 * Implement suggestions by @dekz * Update comments in ERC721 contracts * Implement tokensByIndex extension - Remove restrictions from mock mint and burn calls * Add default implementation for metadata URI This allows token implementation to be non-abstract * Allow operators to call approve on a token * Remove gas stipend restriction in call to 721 receiver * Remove deprecated implementation We only want to keep the interface, for interacting with already deployed contracts * Add notice to isContract helper on constract constructors * Change natspec delimiters for consistency * Minor linting fixes * Add constant modifier to ERC721_RECEIVED magic value * Use 4-params safeTransferFrom for implementing the 3-params overload * Minor text changes in natspec comments * Use address(0) instead of 0 or 0x0 * Use if-statements instead of boolean one-liners for clarity :-( * Keep ownedTokensCount state var in sync in full ERC721 implementation * Fix incorrect comparison when burning ERC721 tokens with metadata * Use address(0) instead of 0 in one more place in ERC721 * Throw when querying balance for the zero address Required by the spec * Update links to approved version of EIP721 * Use explicit size for uint * Remove unneeded internal function in ERC721 Also rename addToken and removeToken for added clarity * Use underscore instead of 'do' prefix for internal methods in ERC721 * Fix failing test due to events reordering in ERC721 safe transfer * Fix bug introduced in 74db03ba06 * Remove do prefix for internal setTokenUri method * Allow transfers to self in ERC721
7 years ago
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public override returns (bytes4)
{
require(!_reverts, "ERC721ReceiverMock: reverting");
emit Received(operator, from, tokenId, data, gasleft());
return _retval;
}
ERC721 full implementation (#803) * Rename current ERC721 implementation to BaseERC721 * Implement ERC721 optional & approveAll functionality * Support for new ERC721 interface - Tests for new features are pending - ERC721 is abstract, since it requires metadata implementation - Move some methods into DeprecatedERC721 contract - Reorganise base vs full implementation - Pending tokenByIndex * Add more tests for ERC721 * Implement suggestions by @dekz * Update comments in ERC721 contracts * Implement tokensByIndex extension - Remove restrictions from mock mint and burn calls * Add default implementation for metadata URI This allows token implementation to be non-abstract * Allow operators to call approve on a token * Remove gas stipend restriction in call to 721 receiver * Remove deprecated implementation We only want to keep the interface, for interacting with already deployed contracts * Add notice to isContract helper on constract constructors * Change natspec delimiters for consistency * Minor linting fixes * Add constant modifier to ERC721_RECEIVED magic value * Use 4-params safeTransferFrom for implementing the 3-params overload * Minor text changes in natspec comments * Use address(0) instead of 0 or 0x0 * Use if-statements instead of boolean one-liners for clarity :-( * Keep ownedTokensCount state var in sync in full ERC721 implementation * Fix incorrect comparison when burning ERC721 tokens with metadata * Use address(0) instead of 0 in one more place in ERC721 * Throw when querying balance for the zero address Required by the spec * Update links to approved version of EIP721 * Use explicit size for uint * Remove unneeded internal function in ERC721 Also rename addToken and removeToken for added clarity * Use underscore instead of 'do' prefix for internal methods in ERC721 * Fix failing test due to events reordering in ERC721 safe transfer * Fix bug introduced in 74db03ba06 * Remove do prefix for internal setTokenUri method * Allow transfers to self in ERC721
7 years ago
}