Skip to content

Commit 1f754a3

Browse files
committed
fixes for ERC721 hardhat examples
1 parent 083c32f commit 1f754a3

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

tests/ERC721/hardhat/contracts/CryticTest.sol

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,40 @@ import "@crytic/properties/ERC721/internal/properties/ERC721BasicProperties.sol"
33
import "./ExampleToken.sol";
44

55
contract CryticERC721InternalHarness is ExampleToken, CryticERC721BasicProperties {
6+
using Address for address;
7+
68
constructor() {
9+
maxSupply = 100;
710
isMintableOrBurnable = true;
11+
hasMaxSupply = false;
12+
safeReceiver = new MockReceiver(true);
13+
unsafeReceiver = new MockReceiver(false);
814
}
915

1016
function _customMint(uint256 amount) internal virtual {
11-
mint(amount);
17+
mint(msg.sender, amount);
1218
}
1319

1420
function _customMaxSupply() internal virtual view returns (uint256) {
1521
return maxSupply;
1622
}
23+
24+
// The following functions are overrides required by Solidity.
25+
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
26+
internal
27+
virtual
28+
override(ExampleToken, CryticERC721TestBase)
29+
{
30+
super._beforeTokenTransfer(from, to, tokenId, batchSize);
31+
}
32+
33+
function supportsInterface(bytes4 interfaceId)
34+
public
35+
view
36+
virtual
37+
override(ExampleToken, CryticERC721TestBase)
38+
returns (bool)
39+
{
40+
return super.supportsInterface(interfaceId);
41+
}
1742
}

tests/ERC721/hardhat/contracts/CryticTestExt.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ pragma solidity ^0.8.0;
22
import "./ExampleToken.sol";
33
import {IERC721Internal} from "@crytic/properties/ERC721/util/IERC721Internal.sol";
44
import {CryticERC721ExternalBasicProperties} from "@crytic/properties/ERC721/external/properties/ERC721xternalBasicProperties.sol";
5+
import {MockReceiver} from "properties/ERC721/external/util/MockReceiver.sol";
56

67
contract CryticERC721ExternalHarness is CryticERC721ExternalBasicProperties {
78

89
constructor() {
910
// Deploy ERC721
1011
token = IERC721Internal(address(new ERC721Mock()));
12+
mockSafeReceiver = new MockReceiver(true);
13+
mockUnsafeReceiver = new MockReceiver(false);
1114
}
1215

1316
}

tests/ERC721/hardhat/contracts/ExampleToken.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
55
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
66

77
contract ExampleToken is ERC721, ERC721Enumerable, ERC721Burnable {
8+
9+
uint256 public counter;
810
constructor() ERC721("Example token", "EXT") {}
911

10-
function mint(address to, uint256 tokenId) public virtual {
11-
_mint(to, tokenId);
12+
function mint(address to, uint256 amount) public {
13+
for (uint256 i; i < amount; i++) {
14+
_mint(to, counter++);
15+
}
1216
}
1317

1418
// Overrides
1519

1620
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
1721
internal
22+
virtual
1823
override(ERC721, ERC721Enumerable)
1924
{
2025
super._beforeTokenTransfer(from, to, tokenId, batchSize);
@@ -23,6 +28,7 @@ contract ExampleToken is ERC721, ERC721Enumerable, ERC721Burnable {
2328
function supportsInterface(bytes4 interfaceId)
2429
public
2530
view
31+
virtual
2632
override(ERC721, ERC721Enumerable)
2733
returns (bool)
2834
{

0 commit comments

Comments
 (0)