Hi, I'm new in Solidity programming, and I have some questions about AccessControl library.
The methods grantRole and revokeRole was exactly what I was looking for. But the method renounceRole came together.
And this method, for my use case could be dangerous, due it make possible the only Admin renounce its role and the contract become without administrator.
To solve it, the first thing I did was trying to override the function with private visibility, but it's not possible.
So, I override with a require, that doesn't allow revoke the own admin role.
function renounceRole(bytes32 role, address account)
public
virtual
override
{
require(role != DEFAULT_ADMIN_ROLE, "AccessControl: cannot renounce Admin role");
super.renounceRole(role, account);
}
It worked fine, but remain some questions:
- What is the primary purpose of the
revokeRole
method, allowing the contract become without admin role? - Is it possible "hide" a imported library method? Does it make sense? I mean, is there a good practice related to it?
As I'm still a newbie in Solidity, I'm afraid to change imported methods and after deploy I discover that I changed any important method, that is required to compliance with some standard.
So, my last question is:
- What should I worry about before you overwrite a method, or hide it (if this is possible)?