Openzeppelin-contracts: Preset contracts with roles: Add initial role addresses to constructor/initializer

Created on 2 Dec 2020  路  4Comments  路  Source: OpenZeppelin/openzeppelin-contracts

馃 Motivation
Currently preset contracts (ERC20, ERC721 & ERC1155) with roles assign the roles to the msg.sender (contract deployer) in the constructor/initializer.

Decoupling the initial role from the deployer would better support deploying with roles assigned to a multi-sig, or when deploying from a factory contract.

馃摑 Details
When deploying with the aim of controlling admin roles with a multi-sig, either the roles need to be granted and renounced or the preset can't be used. See the following example where the preset couldn't be used: https://forum.openzeppelin.com/t/manage-an-erc20-token-using-defender-admin-and-gnosis-safe/4575

Whilst adding additional parameters is not desirable, it gives a great deal of extra flexibility.
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/presets/ERC20PresetMinterPauser.sol#L35

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/presets/ERC721PresetMinterPauserAutoId.sol#L42

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/presets/ERC1155PresetMinterPauser.sol#L33

on hold

All 4 comments

Yes I agree, this should have been like that from the beginning. We can't change the existing contracts but we can add new ones. (The existing ones can be redefined as these new ones where the extra argument is the msg.sender, so as to keep it backwards compatible but not duplicate the code.)

We need to figure out what to name them though... I'm honestly just tempted to add a 2 at the end of the name: ERC20PresetMinterPauser2.

  • ERC20PresetCustomMinterPauser

  • ERC20PresetExternalMinterPauser

But might prove to be too lengthy. Just few names off the top.

Pity we can't have overloaded constructors or default parameters in Solidity.

I assume changing the constructor parameters breaks the API Stability: https://docs.openzeppelin.com/contracts/3.x/releases-stability#api-stability

Maybe Specified?
Preset Specified Minter...

We're starting to discuss an interactive "boilerplate generator" that might make presets obsolete, as it would essentially generate the presets on demand based on a desired configuration. I'll put this issue on hold until we have more clarity on whether we will be moving in that direction.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frangio picture frangio  路  3Comments

mswezey23 picture mswezey23  路  4Comments

valmack picture valmack  路  3Comments

sebastien-kr picture sebastien-kr  路  4Comments

xiaoyao1991 picture xiaoyao1991  路  3Comments