Skip to content

feat(admin): extract storage module with Role enum - #623

Open
d3v-active wants to merge 2 commits into
BCPathway:mainfrom
d3v-active:feat/define-role-enum-minter
Open

feat(admin): extract storage module with Role enum#623
d3v-active wants to merge 2 commits into
BCPathway:mainfrom
d3v-active:feat/define-role-enum-minter

Conversation

@d3v-active

Copy link
Copy Markdown

Closes #397

This PR resolves the issue: Define Role Enum with Minter. It establishes a foundational, dedicated storage layer for the Access Control and Role-Based Access Control (RBAC) structures within the bc-forge architecture.

Previously, essential storage layout types such as AdminKey and the Role enum (including the critical Minter role variant) were co-located in the main lib.rs file. This change extracts these structures into an isolated storage module to improve the organization of the codebase, reduce the size of the root library module, and establish a clean pattern for future data types.

Step-by-Step Implementation

  1. Created storage.rs module: Introduced a dedicated storage module under contracts/admin/src/storage.rs.
  2. Extracted Storage Types: Migrated the following core access control types from lib.rs to storage.rs:
    • AdminKey enum: Defines the primary slots (Admin, Role(Role, Address), AdminPool, etc.) preventing storage collision.
    • Role enum: The RBAC definitions, securely containing the Minter variant for token minting privileges.
    • Proposal struct: Governance and multi-sig proposal state representations.
    • SUPER_ADMIN_ROLE constant: Allows easy gating for SuperAdmin roles.
  3. Refactored Module Tree: Updated contracts/admin/src/lib.rs to expose the extracted definitions completely transparently via pub mod storage; and pub use storage::*;.

Acceptance Criteria Met

  • Syntax is correct: The codebase compiles properly (cargo build --target wasm32-unknown-unknown) without syntax warnings or errors.
  • Storage slots do not overlap: Kept the exact discriminant order for all enums. Since the order of variants inside AdminKey and Role remained strictly unaltered during extraction, all previously persisted ledger entries will continue decoding successfully to their correct storage slots.
  • Zero-address edge cases are handled: Preserved zero-address handlers natively within is_valid_role and require_non_zero_address functions, which maintain robust checking before engaging with the underlying storage layer.

Validation / Testing

  • Successfully compiled the workspace against the Soroban wasm32-unknown-unknown target.
  • Ensured that bc-forge-admin tests behave as expected since all pub use aliases mimic the exact pre-existing API surface of the module.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@d3v-active 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! 🚀

Learn more about application limits

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.

[Storage] Define Role Enum with Minter

1 participant