-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathERC721MintableTests.sol
101 lines (84 loc) · 3.41 KB
/
ERC721MintableTests.sol
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import {CryticERC721MintableProperties} from "../../properties/ERC721MintableProperties.sol";
import {MockReceiver} from "../../util/MockReceiver.sol";
contract ERC721MintableTestsInternal is CryticERC721MintableProperties {
using Address for address;
uint256 public counter;
constructor() ERC721("ERC721BasicTestsInternal","ERC721BasicTestsInternal") {
isMintableOrBurnable = true;
safeReceiver = new MockReceiver(true);
unsafeReceiver = new MockReceiver(false);
}
function mint(address to) public {
//require(totalSupply() + amount <= maxSupply);
/* for (uint256 i; i < amount; i++) {
_mint(msg.sender, counter++);
} */
}
function balanceOf(address owner) public view virtual override(ERC721, IERC721) returns (uint256) {
//require(owner != address(0), "ERC721: address zero is not a valid owner");
return owner == address(0) ? 0 : super.balanceOf(owner);
}
function ownerOf(uint256 tokenId) public view virtual override(ERC721, IERC721) returns (address) {
address owner = _ownerOf(tokenId);
//require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
function approve(address to, uint256 tokenId) public virtual override(ERC721, IERC721) {
if(_exists(tokenId)) {
super.approve(to, tokenId);
}
// Does not revert if token doesn't exist
}
function transferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, IERC721) {
//solhint-disable-next-line max-line-length
//require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
if (from == address(0)) {
_mint(to, tokenId);
}
_approve(address(this), tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override(ERC721, IERC721) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, "") returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
_transfer(from, to, tokenId);
} else {
safeTransferFrom(from, to, tokenId, "");
}
} catch (bytes memory reason) {
_transfer(from, to, tokenId);
}
} else {
safeTransferFrom(from, to, tokenId, "");
}
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
internal
virtual
override
{
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _customMint(address to, uint256 amount) internal virtual override {
for(uint256 i; i < amount; i++) {
mint(to);
}
}
}
contract TestHarness is ERC721MintableTestsInternal {
constructor() {}
}