Skip to content

Commit

Permalink
stytle underbar like other internal variables (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulldecent authored Feb 9, 2022
1 parent 430da07 commit 41d7c71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions contracts/ERC721A.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
uint128 numberMinted;
}

uint256 internal currentIndex;
uint256 internal _currentindex;

// Token name
string private _name;
Expand Down Expand Up @@ -84,7 +84,7 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
return _currentindex;
}

/**
Expand Down Expand Up @@ -290,7 +290,7 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
return tokenId < _currentindex;
}

function _safeMint(address to, uint256 quantity) internal {
Expand Down Expand Up @@ -331,15 +331,15 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
uint256 startTokenId = _currentindex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();

_beforeTokenTransfers(address(0), to, startTokenId, quantity);

// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1
// updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1
// updatedIndex overflows if _currentindex + quantity > 1.56e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
Expand All @@ -358,7 +358,7 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
updatedIndex++;
}

currentIndex = updatedIndex;
_currentindex = updatedIndex;
}

_afterTokenTransfers(address(0), to, startTokenId, quantity);
Expand Down
8 changes: 4 additions & 4 deletions contracts/extensions/ERC721AOwnersExplicit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ abstract contract ERC721AOwnersExplicit is ERC721A {
*/
function _setOwnersExplicit(uint256 quantity) internal {
if (quantity == 0) revert QuantityMustBeNonZero();
if (currentIndex == 0) revert NoTokensMintedYet();
if (_currentindex == 0) revert NoTokensMintedYet();
uint256 _nextOwnerToExplicitlySet = nextOwnerToExplicitlySet;
if (_nextOwnerToExplicitlySet >= currentIndex) revert AllOwnershipsHaveBeenSet();
if (_nextOwnerToExplicitlySet >= _currentindex) revert AllOwnershipsHaveBeenSet();

// Index underflow is impossible.
// Counter or index overflow is incredibly unrealistic.
unchecked {
uint256 endIndex = _nextOwnerToExplicitlySet + quantity - 1;

// Set the end index to be the last token index
if (endIndex + 1 > currentIndex) {
endIndex = currentIndex - 1;
if (endIndex + 1 > _currentindex) {
endIndex = _currentindex - 1;
}

for (uint256 i = _nextOwnerToExplicitlySet; i <= endIndex; i++) {
Expand Down

0 comments on commit 41d7c71

Please sign in to comment.