-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Ability to set starting token id for ERC721Consecutive #4097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b693f7f
bf8c076
31a565b
b651b93
854b461
1c7570d
ab40061
1835727
1fdcbff
44cc563
3f8b0f9
573fa0d
5d9b21b
0fcb048
dd1d6bf
361aa8d
114a3f6
6b4e4ee
78ed610
7959df3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,11 +56,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { | |||||
| address owner = super._ownerOf(tokenId); | ||||||
|
|
||||||
| // If token is owned by the core, or beyond consecutive range, return base value | ||||||
| if ( | ||||||
| owner != address(0) || | ||||||
| tokenId > (uint256(type(uint96).max) + _firstConsecutiveId()) || | ||||||
| tokenId < _firstConsecutiveId() | ||||||
| ) { | ||||||
| if (owner != address(0) || tokenId > type(uint96).max || tokenId < _firstConsecutiveId()) { | ||||||
| return owner; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -86,7 +82,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { | |||||
| * Emits a {IERC2309-ConsecutiveTransfer} event. | ||||||
| */ | ||||||
| function _mintConsecutive(address to, uint96 batchSize) internal virtual returns (uint96) { | ||||||
| uint96 first = _totalConsecutiveSupply(); | ||||||
| uint96 first = _nextConsecutiveId(); | ||||||
|
|
||||||
| // minting a batch of size 0 is a no-op | ||||||
| if (batchSize > 0) { | ||||||
|
|
@@ -137,7 +133,7 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { | |||||
| if ( | ||||||
| to == address(0) && // if we burn | ||||||
| firstTokenId >= _firstConsecutiveId() && | ||||||
| firstTokenId - _firstConsecutiveId() < _totalConsecutiveSupply() && // and the tokenId is in the batch range | ||||||
| firstTokenId - _firstConsecutiveId() < _nextConsecutiveId() && // and the tokenId is in the batch range | ||||||
| !_sequentialBurn.get(firstTokenId) | ||||||
| ) // and the token was never marked as burnt | ||||||
| { | ||||||
|
|
@@ -148,13 +144,13 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { | |||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * @dev Used to offset the first token id in {_totalConsecutiveSupply} | ||||||
| * @dev Used to offset the first token id in {_nextConsecutiveId} | ||||||
| */ | ||||||
| function _firstConsecutiveId() internal view virtual returns (uint96) { | ||||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| function _totalConsecutiveSupply() private view returns (uint96) { | ||||||
| function _nextConsecutiveId() private view returns (uint96) { | ||||||
| (bool exists, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint(); | ||||||
| return exists ? latestId + 1 : _firstConsecutiveId(); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think For example:
I think this is what we should aim for:
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make more sense for someone to consecutively mint token
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would requiring that the tokenId be greater than the last batch minted one in the function _mint(address to, uint256 tokenId) internal virtual override {
require(Address.isContract(address(this)), "ERC721Consecutive: can't mint during construction");
(, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint();
require(tokenId > latestId, "ERC721Consecutive: token id must be greater than latest id");
super._mint(to, tokenId);
}
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is something we don't want, because it adds 2 (cold) sload to the mint operation, which we want to keep as cheap as possible. Also, if we do that, it would be impossible to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note that mint already check if the tokenId has an owner, and revert if that is the case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I'm still wrapping my head around the internals of this but I think I got it. |
||||||
| } | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.