feat: implement common types module (#212) - #318
Merged
truthixify merged 3 commits intoOct 2, 2025
Conversation
- Create shared common_types crate with reusable types - Add SubscriptionPlan enum (Daily, Monthly, PayPerUse) - Add AttendanceAction enum (ClockIn, ClockOut) - Add UserRole enum (Member, Staff, Admin, Visitor) - Add MembershipStatus enum (Active, Expired, Revoked, Inactive) - Apply #[contracttype] for Soroban serialization - Add comprehensive documentation and unit tests - Create test contract demonstrating type usage - Integrate common_types into manage_hub contract - Update workspace to include common_types crate - Refactor manage_hub to use shared MembershipStatus Resolves DistinctCodes#212
|
@Sendi0011 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
… and fix clippy lint issues
Contributor
|
Thank you @Sendi0011 LGTM 🚀 |
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.
Implement Common Types Module (#212)
🎯 Overview
This PR implements a shared
common_typescrate to provide consistent type definitions across all ManageHub contracts, enabling code reuse and maintaining type consistency throughout the system.📦 Changes
New Crate:
common_typesCreated a standalone library crate at
contracts/common_types/containing shared types.Types Implemented
1. SubscriptionPlan Enum
Daily- Daily subscription billingMonthly- Monthly subscription billingPayPerUse- Pay-as-you-go billing model2. AttendanceAction Enum
ClockIn- User arrival actionClockOut- User departure action3. UserRole Enum
Member- Regular member with standard accessStaff- Staff member with elevated privilegesAdmin- Administrator with full accessVisitor- Temporary visitor with limited access4. MembershipStatus Enum
Active- Currently active membershipExpired- Expired membershipRevoked- Revoked membershipInactive- Inactive membership📁 Files Modified
Added
contracts/common_types/Cargo.tomlcontracts/common_types/src/lib.rscontracts/common_types/src/types.rscontracts/common_types/src/test_contract.rsModified
contracts/Cargo.toml- Added common_types to workspacecontracts/manage_hub/Cargo.toml- Added common_types dependencycontracts/manage_hub/src/types.rs- Refactored to use shared MembershipStatus✅ Acceptance Criteria
All acceptance criteria from issue #212 have been met:
types.rswith all required enums#[contracttype]for Soroban serialization on all typeslib.rs🧪 Testing
Unit Tests
All type variants tested for:
Integration Tests
Test contract (
test_contract.rs) verifies:Workspace Tests
📚 Documentation
Each type includes:
🔄 Usage Example
🏗️ Architecture
Benefits
Integration
manage_hubnow uses sharedMembershipStatusfromcommon_typesmembership_tokenandaccess_controlcontracts🔗 Related Issues
Closes #212
🎉 Next Steps
This foundation enables:
Ready for review! 🚀