(from https://github.com/OpenZeppelin/openzeppelin-solidity/issues/1290)
This is something I've been wanting to do for a while: to reduce the potential for human error, to more more succinctly express the differences and similarities between the different roles, and because I have a taste for bad ideas
In the WhitelistedCrowdsale - #5 by nventuro topic I noticed a couple things that may differ from role to role, requiring parametrization. These are:
-
Which accounts are able to assign the role? By default, these are accounts with the same role (e.g. accounts with the
Minter
role can create other minters), but in some cases it will be a different role that can do it (like in the case ofWhitelister
s andWhitelistee
s). -
Which accounts are able to remove the role? So far we've kept the function
internal
, leaving it up to our users to implement apublic
one and call it if they need to, but in some cases (again,Whitelistee
) a 'manager' account may have the ability to remove others by default. -
Is the role assigned at creation time to the deployer account? For some roles (especially those managed by a different role, like
Whitelistee
) this may not be true. -
Can the role be renounced? We may have roles that shouldn't allow this (e.g. some sort of blacklist)
Additionally, we could include some sort of description (e.g. 'accounts with this role can mint new tokens') to also improve the documentation (also autogenerated).
The actual code generation should be dead easy, since there are only a few variants: a simple JavaScript program could read the settings from a json file and create the .sol files, only writing to disk if the contents changed (to avoid unnecessary recompilations).