Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
linting and changeset
  • Loading branch information
kfishnchips committed Mar 10, 2023
commit bf8c07645ad148f655fa20053a0944f4bf2ddd61
5 changes: 5 additions & 0 deletions .changeset/spotty-hotels-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`ERC721Consecutive`: Add support for setting a starting token id
4 changes: 3 additions & 1 deletion contracts/token/ERC721/extensions/ERC721Consecutive.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 {
/**
* @dev Used to offset the first token id in {_totalConsecutiveSupply}
*/
function _firstConsecutiveId() internal view virtual returns (uint96) { return 0; }
function _firstConsecutiveId() internal view virtual returns (uint96) {
return 0;
}

function _totalConsecutiveSupply() private view returns (uint96) {
(bool exists, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint();
Expand Down
26 changes: 22 additions & 4 deletions test/token/ERC721/extensions/ERC721Consecutive.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ contract ERC721ConsecutiveTest is Test {
assertEq(token.balanceOf(receiver), token.totalMinted());
}

function test_ownership(address receiver, uint256[] calldata batches, uint256[2] calldata unboundedTokenId, uint96 startingId) public {
function test_ownership(
address receiver,
uint256[] calldata batches,
uint256[2] calldata unboundedTokenId,
uint96 startingId
) public {
vm.assume(receiver != address(0));
vm.assume(startingId < type(uint96).max - 5000);

Expand All @@ -57,12 +62,21 @@ contract ERC721ConsecutiveTest is Test {
assertEq(token.ownerOf(validTokenId), receiver);
}

uint256 invalidTokenId = bound(unboundedTokenId[1], startingId + token.totalMinted(), startingId + token.totalMinted() + 1);
uint256 invalidTokenId = bound(
unboundedTokenId[1],
startingId + token.totalMinted(),
startingId + token.totalMinted() + 1
);
vm.expectRevert();
token.ownerOf(invalidTokenId);
}

function test_burn(address receiver, uint256[] calldata batches, uint256 unboundedTokenId, uint96 startingId) public {
function test_burn(
address receiver,
uint256[] calldata batches,
uint256 unboundedTokenId,
uint96 startingId
) public {
vm.assume(receiver != address(0));
vm.assume(startingId < type(uint96).max - 5000);

Expand Down Expand Up @@ -143,7 +157,11 @@ contract ERC721ConsecutiveTest is Test {
batches[0] = bound(unboundedBatches[0], startingTokenId, 5000);
batches[1] = bound(unboundedBatches[1], startingTokenId, 5000);

ERC721ConsecutiveTarget token = new ERC721ConsecutiveTarget(toSingleton(receiver), batches, uint96(startingTokenId));
ERC721ConsecutiveTarget token = new ERC721ConsecutiveTarget(
toSingleton(receiver),
batches,
uint96(startingTokenId)
);

uint256 tokenId0 = bound(unboundedTokenId[0], startingTokenId, batches[0]);
uint256 tokenId1 = bound(unboundedTokenId[1], startingTokenId, batches[1]);
Expand Down