Skip to content

feat: define core Group, Member, and GroupMember types in base/types.rs - #154

Open
Ugasutun wants to merge 1 commit into
Web3Novalabs:mainfrom
Ugasutun:feature/add-payroll-types
Open

feat: define core Group, Member, and GroupMember types in base/types.rs#154
Ugasutun wants to merge 1 commit into
Web3Novalabs:mainfrom
Ugasutun:feature/add-payroll-types

Conversation

@Ugasutun

Copy link
Copy Markdown

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.

- 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
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.

Define core data types for Groups and Members

1 participant