feat: define core Group, Member, and GroupMember types in base/types.rs - #154
Open
Ugasutun wants to merge 1 commit into
Open
feat: define core Group, Member, and GroupMember types in base/types.rs#154Ugasutun wants to merge 1 commit into
Ugasutun wants to merge 1 commit into
Conversation
- Add Group struct with id, creator, token, created_at, member_count fields - Add Member struct with address, percentage, joined_at fields - Enhance GroupMember struct with joined_at timestamp field - All types implement #[contracttype] for Soroban serialization compatibility - Update all test files to initialize joined_at field with ledger timestamp - Add comprehensive tests for type initialization and serialization - Types are properly documented with field descriptions - Code formatted with cargo fmt Closes Web3Novalabs#55
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.
Closes #55
Description
Summary
Implements #55 — defines the core Soroban-compatible data types for representing payroll groups and members in contract state: Group, Member, and GroupMember.
Changes
contract/src/base/types.rs:
Added Group struct:
id: u128 — unique identifier for the payroll group
creator: Address — the address that created the group
token: Address — the token used for payroll distributions in this group
created_at: u64 — ledger timestamp at group creation
member_count: u32 — current number of members in the group
Added Member struct:
address: Address — the member's Stellar address
percentage: u32 — the member's payout share (basis points or percentage, documented in-line)
joined_at: u64 — ledger timestamp when the member joined
Added GroupMember struct combining a Group and its associated Member data, for contract functions that need both in a single return/query type.
All three structs derive #[contracttype] (Soroban's Serialize/Deserialize-compatible derive) so they can be stored in contract state and passed across contract function boundaries.
Added rustdoc comments on the struct and every field explaining its purpose and units (e.g. percentage scale, timestamp semantics).
Exported all three types from base/types.rs for use across contract modules.
Testing
Added tests verifying:
Group, Member, and GroupMember instances can be constructed with expected field values.
Structs round-trip correctly through Soroban's storage (set/get) without data loss.
GroupMember correctly composes Group and Member data.
All tests pass; cargo build succeeds with no warnings; cargo fmt applied.
Notes for reviewers
Used u128 for Group::id and u32 for member_count/percentage — happy to adjust types if the project has a different convention elsewhere in the contract (e.g. u64 for IDs).
This PR is types-only, as scoped — no contract function logic (create group, add member, etc.) is included here; that's expected to build on top of these types in follow-up work.