Skip to content

[CT-12] Implement standalone Role Checker utility for access_control contract in Rust #1029

@devwums

Description

@devwums

Problem

The access_control contract has no exported standalone role-checker utility. Consumers must parse the full ACL structure themselves, leading to duplicated and error-prone role verification logic.

Proposed Solution

Create contracts/cntr/role_checker.rs implementing pub fn has_role(roles: &[(String, String)], address: &str, required_role: &str) -> bool and pub fn get_roles_for_address(roles: &[(String, String)], address: &str) -> Vec<String>. The roles slice is a list of (address, role) pairs. Comparisons are case-sensitive. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/role_checker.rs
  • has_role returns false for an empty roles slice
  • has_role uses case-sensitive comparison for both address and role
  • get_roles_for_address returns all roles held by an address (a member can hold multiple roles)
  • get_roles_for_address returns an empty Vec for unknown addresses
  • At least 6 unit tests
  • Compiles with cargo test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions