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

Feature/Adding RoleAdminChanged event in AccessControl #2214

Merged
merged 8 commits into from
May 6, 2020

Conversation

julianmrodri
Copy link
Contributor

@julianmrodri julianmrodri commented Apr 24, 2020

#2210

Fixes #2210

Adding a new event named "RoleAdminChanged" when the adminRole of a Role is changed. This event is emitted from with the _setRoleAdmin function.

@julianmrodri
Copy link
Contributor Author

I see 2 potential changes worth discussing:

  • I put the Declaration of the new event before the existing ones, we can move it to the after the other two events.
  • Should we only trigger the event in the case the new Role Admin is different than the existing Role Admin? (this would require to add a validation)

Looking forward for your comments!
.

@julianmrodri
Copy link
Contributor Author

@nventuro @frangio Would really appreciate your inputs so we can put this puppy to bed! Thanks for your time!

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @julianmrodri! We were a bit busy with the release of v3.0 and the Solidity Summity last week.

This looks great, thanks! I love how you followed our style for the docs and tests - I only left a small suggestion for further clarity.

Regarding only emitting on change, AccessControl is a bit special in that no-ops in grantRole and revokeRole don't emit events. This is to prevent confusion: RoleRevoked seems to imply the role had been previously granted, so we wanted to avoid revokes not preceeded by grants.

This case however seems more similar to an ERC20 transfer of 0. What if instead we added the previous role admin in the event? @frangio WDYT?

contracts/access/AccessControl.sol Outdated Show resolved Hide resolved
@frangio
Copy link
Contributor

frangio commented May 4, 2020

I agree we should include the current admin role in the event as well, similar to the OwnershipTransferred event. And I think we should always emit it, not only when it actually changes.

Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
@julianmrodri
Copy link
Contributor Author

julianmrodri commented May 4, 2020

Sounds good! Thanks! Will implement the change to add the current Admin Role and let you know.

@julianmrodri
Copy link
Contributor Author

julianmrodri commented May 6, 2020

@nventuro @frangio I have implemented the changes you suggested.

  • I added the "previousAdminRole" to the event. I followed the same naming you are using in OwnershipTransferred. I had to emit the event before updating the value now (the same is being done in 'OwnershipTransferred').
  • Regarding the tests I had to break one statement into 3 lines due to lint issues (max length). TBH didn't know if use only 2 lines (leaving the first two parameters in the same line). I saw you were using one line per parameter in many cases so I followed that but we can change it if required.

Let me know what you think thanks for your support!

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Thank you very much @julianmrodri! I went ahead and adjusted the overly long line to a style that is more congruent with what we tend to use, and added an entry to the changelog for this improvement.

Hope to see more contributions from you soon! :)

@nventuro nventuro merged commit 73baf0b into OpenZeppelin:master May 6, 2020
@julianmrodri julianmrodri deleted the feature/add-event-#2210 branch May 6, 2020 21:10
@julianmrodri
Copy link
Contributor Author

Thanks for your time and patience! for sure!

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.

Add event for AccessControl._setRoleAdmin
3 participants