Skip to content

chore: make Acl role limit explicit#70

Merged
mooori merged 1 commit into
masterfrom
doc-max-roles
Jan 23, 2023
Merged

chore: make Acl role limit explicit#70
mooori merged 1 commit into
masterfrom
doc-max-roles

Conversation

@mooori
Copy link
Copy Markdown
Contributor

@mooori mooori commented Jan 23, 2023

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.

/// 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;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Making it pub to have it surface in docs, since the assert message below mentions it.

@mooori mooori marked this pull request as ready for review January 23, 2023 14:49
@mooori mooori requested a review from birchmd January 23, 2023 14:49
@mooori mooori merged commit 06fa4d9 into master Jan 23, 2023
@mooori mooori deleted the doc-max-roles branch January 23, 2023 15:10
birchmd pushed a commit that referenced this pull request Feb 20, 2023
This was referenced Mar 27, 2026
@github-actions github-actions Bot mentioned this pull request Apr 7, 2026
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.

3 participants