Introduce array of roleIds
alexroan opened this issue · comments
contracts/contracts/access/Hierarchy.sol
Line 19 in 4c4acb1
using an array instead of a single role would allow multiple roles to be granted access to a function.
Hi Alex. Yes, an array would allow several roles to be granted access to a function, but for this case I just needed to check membership to one role from addRole
just below. I might implement your proposal in a separate contract. Let me think about it.
That's a very well-written article, and interesting solution, congratulations.
There are two solutions to creating dynamic permissions. You can either leave the roles static and assign users to groups, which is what would happen with modifiers like onlyMinter
. You can also leave the user groups static, and make dynamic modifiers like in your example, where instead of changing user membership to a role, you change roles required for a function.
So far, I've been able to use RBAC.sol (the precursor to AccessControl.sol
) for everything I've come across in real life. AccessControl.sol
just made it more efficient.
I wonder if the extra complexity is needed or not. If you come across a real world example where your solution was the best option it would make for a very interesting article.
I like your articles a lot, keep it up 👍