chore: make Acl role limit explicit#70
Merged
Merged
Conversation
mooori
commented
Jan 23, 2023
| /// and one for the corresponding admin permission. This would allow for 64 | ||
| /// roles. However, one flag is reserved for `__SUPER_ADMIN`, leaving 127 | ||
| /// bits that can fit 63 roles. | ||
| pub const MAX_ROLE_VARIANTS: u8 = 63; |
Contributor
Author
There was a problem hiding this comment.
Making it pub to have it surface in docs, since the assert message below mentions it.
birchmd
approved these changes
Jan 23, 2023
mrLSD
approved these changes
Mar 12, 2024
This was referenced Mar 27, 2026
Closed
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, if the enum that represents Acl roles has too many variants, compilation fails with an overflow error due to this type definition:
https://github.com/aurora-is-near/near-plugins/blob/dbec4424c5bbfad5fedbfcbe877ed16bacfa18f3/near-plugins-derive/src/access_control_role.rs#L194-L198
This might be hard to understand for developers using the plugin. The changes in this PR produce a more helpful error in case there are too many enum variants. In addition, an upcoming PR will rely on that limit, so better to have it explicitly defined.