-
Notifications
You must be signed in to change notification settings - Fork 12.4k
rbac mintable erc721 token with signature bouncer #950
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
rbac mintable erc721 token with signature bouncer #950
Conversation
54fede7 to
8365b90
Compare
frangio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think this is interesting. Given that the functionality is a bit more complex than what we're used to for OpenZeppelin, I'm wondering if it was motivated by a real need/use case?
I'm not sure about including the AutoIncrementing variant. Once a user has a signature, they can use it to mint many times. Is this a bug or is it by design? If by design, it feels like it duplicates the RBACMintable functionality, becase giving someone a signature is like making them a minter (minus being able to choose an id). Again, if this was motivated by a real use case I think that would help deciding whether we want to include it or not.
I don't see NonceTracker being used in the ERC721 parts. What is its purpose in this context? I would consider leaving it out of this PR.
|
|
||
|
|
||
| contract AutoIncrementing { | ||
| uint256 internal nextId_ = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this private so that derived contracts cannot access/modify directly.
| /** | ||
| * @title AutoIncrementingERC721Minter | ||
| * @author Matt Condon (@shrugs) | ||
| * @dev An ERc721Minter that generates auto-incrementing `tokenId`s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: lowercase c.
| token = _token; | ||
| } | ||
|
|
||
| function mint(bytes _sig, uint256 _tokenId, string _tokenURI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _sig argument is found in too many different argument positions. It's the first argument in mint, the second one in isValidMintSignature, and the last one in isValidSignature. It would be nice to make it consistent.
What do you think about making it always the last argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| function isValidMintSignature( | ||
| address _address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a more relevant name here. I can only think of _beneficiary but there may be better ones...
|
AutoIncrementing is designed for NFTs where the number isn't really important. The spec doesn't suggest or imply that token ids will be contiguous, but I expect most will want to be. By default this token minter AutoIncrements the token id, but one could easily override that and, combined with #973 allow the user to input the token id as an argument. NonceTracker is actually what's stopping a user from using the |
I wrote all of these contracts to support mintable ERC721 using signature bouncer signatures.
AutoIncrementing.sol— just keeps track of an ID and when you access it withnextId()it increments it on demandERC721Minter.sol— a signature bouncer that lets you mint yourself a targetMintablerERC721Tokenif you give it a valid signature (see tests for details, but a bouncer psigns the hash ofcontract.address + sender + tokenId + tokenURINonceTracker— a simple method of tracking nonces per-address and imposing a maximum number of requests for a resource. Pairs well with a signature bouncer to make sure an address can only use the contract a single timeDefaultTokenURI.sol— implementtokenURI(uint256 _tokenId)and returns a defaulttokenURIif a specific token URI is not set. saves the developer from storing the same tokenURI for every tokenRBACMintable.sol— a super simple mintable role withonlyMintermodifier. Does not suggest role authorization, which is left up to the implementer. Pairs well withRBACOwnableRBACOwnable— anOwnableimplementation that allows multiple owners that can add/remove themselvesMintableERC721Token.sol— anERC721Tokenthat can be minted by anyone with theminterrole.fixes #962
npm run lint:all:fix).