Skip to content
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

Move _setOwnersExplicit to separate extension #34

Merged
merged 6 commits into from
Jan 27, 2022
Merged

Conversation

cygaar
Copy link
Collaborator

@cygaar cygaar commented Jan 27, 2022

_setOwnersExplicit doesn't need to be in the base level contract as most users won't need it. However, we want to provide it as an optional extension in case some users want to explicitly set ownerships after a mint is over.

@@ -46,7 +46,7 @@ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable

// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) private _ownerships;
mapping(uint256 => TokenOwnership) internal _ownerships;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to convert this to internal in order for ERC721AOwnersExplicit to read the variable. We can also redeclare ownerships in that file, I have no strong preference here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with currentIndex above

endIndex = currentIndex - 1;
}
// We know if the last one in the group exists, all in the group exist, due to serial ordering.
require(_exists(endIndex), "not enough minted yet for this cleanup");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will never evaluate to true due to line 408 so I removed this check in the refactored function

function _setOwnersExplicit(uint256 quantity) internal {
require(quantity > 0, "quantity must be nonzero");
require(currentIndex > 0, "no tokens minted yet");
require(nextOwnerToExplicitlySet < currentIndex, "all ownerships have been set");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to prevent unnecessary calls to this function

@cygaar cygaar requested a review from chiru-labs January 27, 2022 05:44
@cygaar cygaar force-pushed the explicit_ownerships branch from 35d8f9b to 8063078 Compare January 27, 2022 16:39
@cygaar cygaar merged commit 4d0abd0 into main Jan 27, 2022
@cygaar cygaar deleted the explicit_ownerships branch January 27, 2022 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants