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

Bundle ERC721 extensions into base contract #2149

Merged
merged 9 commits into from
Mar 27, 2020

Conversation

nventuro
Copy link
Contributor

Part of #2086.

The goal behind this initiative is to have all optional extensions for tokens baked into the base implementation (that is, for ERC20 to include ERC20Detailed, and ERC721 to include both ERC721Metadata and ERC721Enumerable). These optional extensions were often (always?) used along the base implementation, and the changes in Solidity around inheritance mean that forcing our users to use multiple inheritance create unnecessary friction.

As a side effect, we should be able to use the newly added EnumerableSet and the proposals around EnumerableMap (#2072) to improve code readability, gas efficiency and overall security.

Because the tokens are some of the library's biggest contracts, these changes are not trivial. I thought it best to approach this in a step-by-step manner, by:

  • first merging all ERC721 implementations and refactoring the tests (with no changes to the internals of the Solidity code)
  • then refactoring the ERC721 internals
  • then doing the same on ERC20

This PR contains just the first step of the three described above. To make reviewing easier, I split the changes to the contracts code in different commits. The tests refactor is unfortunately hard to review, though I am confident it was performed correctly (I copy-pasted the tests from ERC721.behavior and ERC721Full.test into ERC721.test).

@nventuro nventuro requested a review from frangio March 26, 2020 17:04
@nventuro
Copy link
Contributor Author

Also, I haven't yet updated the documentation generators, so some links will be broken. I'll address that once we have the final code in place.

contracts/token/ERC721/ERC721.sol Show resolved Hide resolved
contracts/token/ERC721/ERC721.sol Outdated Show resolved Hide resolved
contracts/token/ERC721/ERC721.sol Show resolved Hide resolved
contracts/token/ERC721/ERC721Pausable.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

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

Looks good!

@nventuro nventuro merged commit 24c37c1 into OpenZeppelin:master Mar 27, 2020
@nventuro nventuro deleted the erc721-bundle branch March 27, 2020 20:27
This was referenced Mar 30, 2020
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