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

Update documentation in IAccessControl #4924

Conversation

0xdevant
Copy link
Contributor

@0xdevant 0xdevant commented Feb 28, 2024

Fixes #4923

As mentioned, this is to fix the natspec comment of IAccessControl on "RoleGranted" event to confirm with latest logic on AccessControl.

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Feb 28, 2024

⚠️ No Changeset found

Latest commit: 86efa23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ernestognw
Copy link
Member

I removed the changeset because this is not something we'd like to document in the changelog.

@ernestognw ernestognw changed the title fix: update the natspec comment of IAccessControl on "RoleGranted" event to conform with latest logic on AccessControl Remove outdated docs for IAccessControl Mar 4, 2024
ernestognw
ernestognw previously approved these changes Mar 4, 2024
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Still requires review from @Amxx

@0xdevant
Copy link
Contributor Author

0xdevant commented Mar 4, 2024

Understood, and thanks for reviewing!

@@ -30,8 +30,7 @@ interface IAccessControl {
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
* `sender` is the account that originated the contract call i.e. the admin role bearer.
Copy link
Collaborator

Choose a reason for hiding this comment

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

When the role is granted using the internal _grantRole (for example during construction, or through any other process), then the msg.sender may not bear the admin rights for the role that is granted.

Copy link
Contributor Author

@0xdevant 0xdevant Mar 4, 2024

Choose a reason for hiding this comment

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

Oh right, my bad, so it should be

`sender` is the account that originated the contract call, an admin role
bearer except when using {AccessControl-_grantRole}.

Copy link
Collaborator

@Amxx Amxx Mar 4, 2024

Choose a reason for hiding this comment

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

     * `sender` is the account that originated the contract call, an admin role 
     * bearer except when using {AccessControl-_grantRole}.

works.

Suggested change
* `sender` is the account that originated the contract call i.e. the admin role bearer.
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted
* role), expect in cases where the role was granted using the internal {AccessControl-_grantRole}.

works as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If that's the case, should we update the description for the event RoleRevoked as well then?

/**
 * @dev Emitted when `account` is revoked `role`.
 *
 * `sender` is the account that originated the contract call:
 *   - if using `revokeRole`, it bears the admin role (for the granted role)
 *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
 */
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

Copy link
Member

Choose a reason for hiding this comment

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

I think the current description of RoleRevoked is fine. Given there are already contracts out there that may grant roles without emitting RoleGranted, it justifies clarifying only for that case.

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Amxx
Amxx previously approved these changes Mar 4, 2024
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

@ernestognw is that good for you ?

@ernestognw
Copy link
Member

@ernestognw is that good for you ?

Yes, more precise. Thanks!

@Amxx Amxx changed the title Remove outdated docs for IAccessControl Update documentation in IAccessControl Mar 4, 2024
Amxx
Amxx previously approved these changes Mar 4, 2024
@Amxx Amxx enabled auto-merge (squash) March 4, 2024 16:06
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

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

Updated with a small nit.

@@ -30,8 +30,8 @@ interface IAccessControl {
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted
* role), expect in cases where the role was granted using the internal {AccessControl-_grantRole}.
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
Copy link
Collaborator

Choose a reason for hiding this comment

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

that line is 124 chars, should not pass linting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yet it does ...

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I ran npm lint:fix before pushing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could be another issue to look into...

@Amxx Amxx merged commit 0a3f880 into OpenZeppelin:master Mar 4, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The natspec comment of IAccessControl regarding RoleGranted event should be updated
3 participants