Skip to content

Commit

Permalink
Add some more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Feb 2, 2024
1 parent 8656cf0 commit 5f38c62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contracts/ERC721A.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ interface ERC721A__IERC721Receiver {
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* The `_sequentialUpTo()` function can be overriden to enable spot mints
* (i.e. non-consecutive mints) for `tokenId`s greater than `_sequentialUpTo()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
Expand Down Expand Up @@ -189,8 +192,8 @@ contract ERC721A is IERC721A {
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256 result) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
// Counter underflow is impossible as `_burnCounter` cannot be incremented
// more than `_currentIndex + _spotMinted - _startTokenId()` times.
unchecked {
result = _currentIndex - _burnCounter - _startTokenId();
if (_sequentialUpTo() != type(uint256).max) result += _spotMinted;
Expand Down
2 changes: 2 additions & 0 deletions contracts/extensions/ERC721AQueryable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
// as the array will at least contain one element.
do {
if (_sequentialUpTo() != type(uint256).max) {
// Skip the remaining unused sequential slots.
if (start == nextTokenId) start = _sequentialUpTo() + 1;
// Reset `currOwnershipAddr`, as each spot-minted token is a batch of one.
if (start > _sequentialUpTo()) currOwnershipAddr = address(0);
}
ownership = _ownershipAt(start);
Expand Down

0 comments on commit 5f38c62

Please sign in to comment.