Repository navigation
feat(roles): add on-chain role management with events - #842
Merged
dzekojohn4 merged 1 commit intoOct 20, 2026
Merged
Conversation
|
@ameeribro4-sudo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Adds on-chain role management to the
stellar_huntscontract, introducingMinterandUpgraderroles on top of the existing single-admin model. This lets privileged responsibilities be delegated without transferring full admin control.Problem
Previously the contract distinguished only admins from everyone else. Any privileged action required the single admin key, so delegating narrow capabilities such as badge minting or schema upgrades meant sharing full control. There was no way to grant or revoke a scoped capability and no on-chain record of who holds one.
Changes Made
Roleenum withMinterandUpgradervariants.DataKey::Role(Address, Role)storage key that records whether an account holds a given role.grant_role,revoke_role, andhas_roleentrypoints:grant_roleandrevoke_roleare admin-gated via the existingrequire_adminhelper.role_granted,role_revoked) so off-chain indexers can track changes.has_rolereturnstruefor the admin implicitly, otherwise reads the stored flag.Only
onchain/contracts/stellar_hunts/src/lib.rswas modified.Implementation Details
Roles are stored in persistent storage under
DataKey::Role(account, role)and set totrueonly while granted;revoke_roleremoves the entry. The admin implicitly holds every role, sohas_roleshort-circuits totruewhen the queried account is the admin. Transitions publish events carrying the(account, role)tuple so consumers can reconstruct role state without replaying raw storage.Closes #672
Closes #673
Closes #674
Closes #676