Nested namespace for library extensions #314
andrew-fleming
started this conversation in
Design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Nested namespace for library extensions
The current design of erc721_enumerable's library imports the ERC721 library and integrates the updated logic for:
transfer_fromsafe_transfer_from_mint_burnContracts that utilize the enumerable extension are expected to import from both erc721 and erc721_enumerable libraries. I believe this is a bit messy and confusing since the enumerable functions share the same name. Prior to namespace, an alternative we considered was to rewrite every erc721 method in the erc721_enumerable library (which IMO is redundant but perhaps viable).
So I'm presenting a new approach which leverages namespace and nests the
Enumerableextension within theERC721base namespace. Here's the gist for the library and preset contract.Details
By removing the extra import and library module, it may be easier to use the enumerable logic.
If it seems reasonable, we could also include some sort of check with ERC165 that reverts if standard ERC721 contracts attempt to use
ERC721.Enumerable.<method>and vice versa.Things to consider
Must not call initializers on any function_mint()within theERC721.Enumerablenamespace would callERC721._mint()This was done as an experiment, so I'd appreciate any feedback 🙏
All reactions