Skip to content

[FEAT] Implement Strict Payout Order Enforcement On-Chain #22

Description

@Queenode

🟡 Priority: High
Difficulty: Hard
Estimated Effort: 4-5 days
Relevant Files: contracts/src/lib.rs
Labels: enhancement, priority:high, logic

Requirements

  1. Deterministic Rotations

    • Currently, payout(recipient) allows the admin to pick any member who hasn't received a payout. This allows the admin to play favorites.
    • Implement strict on-chain enforcement of the payout order based on join order (or a pre-defined array).
  2. Payout Queue State

    • Replace the HasReceivedPayout boolean map with a NextPayoutIndex integer in instance storage (starting at 0).
    • The Members vector already establishes an order (index 0, index 1, etc.).
  3. Enforce Queue

    • Modify payout() (or trigger_payout()) so it no longer takes a recipient argument.
    • Instead, it reads NextPayoutIndex.
    • recipient = members.get(NextPayoutIndex).
    • Execute the payout to that specific recipient.
    • Increment NextPayoutIndex by 1.
  4. Cycle Boundaries

    • When NextPayoutIndex == Members.len(), the cycle is complete.
    • The reset_cycle() function should reset NextPayoutIndex to 0.
    • Ensure add_member and remove_member handle NextPayoutIndex gracefully (e.g., if a member is removed before their turn, shift the index or array).
  5. Testing

    • Unit test: 3 members join. Payout 1 goes to member 0. Payout 2 goes to member 1.
    • Unit test: Attempt to bypass the queue (panics or automatically routes to the correct person).
    • Unit test: Cycle completes, resets, and starts again with member 0.
    • Target: 100% coverage on sequential payout logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions