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

Minter Access Control #105

Merged

Conversation

NicolasMahe
Copy link
Contributor

@NicolasMahe NicolasMahe commented Nov 17, 2021

Hey guys,

This PR is the implementation of suggestions from the discussion of my business partner: rarible/protocol#11 and is the phase 2 of the proposal https://gov.rarible.org/t/proposal-to-optionally-restrict-the-mint-of-tokens/182.

This PR adds a new smart contract, MinterAccessControl, to restrict who can mint tokens.

The state variable _minters contains the addresses that are authorized to mint.
Functions grantMinter and revokeMinter add or remove an address to/from the authorized minter list. Only the smart contract's owner can execute these functions.

The state variable minterAccessControlEnabled controls the restriction of mint. false by default not to create breaking change.
Functions enableMinterAccessControl and disableMinterAccessControl enable and disable the restriction of mint. Only the smart contract's owner can execute these functions.

Finally, the function isValidMinter asserts if the minter is authorized only if the mint restriction is enabled. Return true for any minter if the mint restriction is disabled.
This function is called in the mintAndTransfer function of the contracts ERC721LazyMinimal and ERC721Lazy using the minter encoded in the tokenId.

The MinterAccessControl restriction is disabled by default the prevent breaking change. The contract owner has to call enableMinterAccessControl and add the minter's address with grantMinter function.

@artsyassets
Copy link

Thank you!

@basti4nos
Copy link

Nice one!

@eduardstal
Copy link

Nice one @NicolasMahe!

@eduardstal
Copy link

@evgenynacu Would this PR be in conflict with the fix we're deploying to restrict minting with private createToken?

@chusla
Copy link

chusla commented Nov 18, 2021

@evgenynacu Would this PR be in conflict with the fix we're deploying to restrict minting with private createToken?

came here to ask the same question! any input would be much appreciated! current private createtoken is a great start thanks for that. This would give more flexibility on top of it ideally.

@evgenynacu
Copy link
Member

Hey guys
Thanks for the PR
Team will give the feedback soon

Sorry for the delay

Copy link
Contributor

@disenotov disenotov left a comment

Choose a reason for hiding this comment

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

Hello!
sorry for the long wait, here are some comments
feel free to ask any questions, gonna answer faster this time :)

@NicolasMahe
Copy link
Contributor Author

NicolasMahe commented Dec 6, 2021

Hello! sorry for the long wait, here are some comments feel free to ask any questions, gonna answer faster this time :)

Comments implemented 👍

The state variable minterAccessControlEnabled has been removed in favor of isPrivate.

@NicolasMahe NicolasMahe requested a review from disenotov December 6, 2021 13:09
@SKonstantinS SKonstantinS self-requested a review December 9, 2021 08:10
@SKonstantinS
Copy link
Contributor

Hi @NicolasMahe, I leave some comments, not critical, I hope You are agree. Together we`ll try to generate this code better)))

@NicolasMahe
Copy link
Contributor Author

NicolasMahe commented Dec 16, 2021

Hi @NicolasMahe, I leave some comments, not critical, I hope You are agree. Together we`ll try to generate this code better)))

Feedbacks implemented 👍 One conversation open for more modification.

__MinterAccessControl_init_unchained();
}

function version() public view returns (uint256) {
Copy link
Contributor

@SKonstantinS SKonstantinS Dec 21, 2021

Choose a reason for hiding this comment

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

For version identification we use smth like that:
bytes4 constant public V2 = bytes4(keccak256("V2"));
You can see it: exchange-v2/contracts/LibOrderDataV2.sol
So may You use this constant in test?
I think there is no error here, but probably we should use the same approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: af18208

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank You for your work, I`ll review

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SKonstantinS waiting for your review ;)

@disenotov disenotov changed the base branch from master to RPC-132-minter-role January 31, 2022 18:18
@disenotov disenotov merged commit d85e030 into rarible:RPC-132-minter-role Jan 31, 2022
@disenotov
Copy link
Contributor

merged into https://github.com/rarible/protocol-contracts/tree/RPC-132-minter-role branch for now, gonna merge into master soon, thanks!

@evgenynacu
Copy link
Member

@NicolasMahe merged into master too

@bobwith2bees
Copy link

@disenotov Question on Minter Access control: can you enable this after a contract has been deployed with isPrivate=false?

It appears it is enabled by the isPrivate boolean, but I don't see an "enable" function to change the setting via any of the ABI's. What is the name of the function to enable it?

I can access the MinterAccessControl functions (isMinter, addMinter etc).

@disenotov
Copy link
Contributor

@bobwith2bees Hello! do you want to switch isPrivate from false to true? if so, then it's not possible. We designed it so public collections can't become private or vice versa.

@bobwith2bees
Copy link

@disenotov That's what I needed to know. Thanks for the clarification.

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.

10 participants