Skip to content

Add maximum participant cap to campaign contract#66

Merged
joelpeace48-cell merged 2 commits intoFinesseStudioLab:mainfrom
xqcxx:feature/add-campaign-max-participants
Mar 25, 2026
Merged

Add maximum participant cap to campaign contract#66
joelpeace48-cell merged 2 commits intoFinesseStudioLab:mainfrom
xqcxx:feature/add-campaign-max-participants

Conversation

@xqcxx
Copy link
Copy Markdown
Contributor

@xqcxx xqcxx commented Mar 25, 2026

Summary

Implements an optional maximum participant capacity feature for campaigns, allowing administrators to limit the number of participants who can register.

Changes

  • Added CapacityReached error variant (Error code 102)
  • Added storage for max capacity (MAX_CAP) and participant count (PARTICIPANT_COUNT)
  • Implemented set_max_cap admin function to configure the capacity limit
  • Updated register function to:
    • Check current count against max capacity before allowing registration
    • Automatically increment participant count on successful registration
    • Return clear error when capacity is reached
  • Added get_participant_count query function to retrieve current participant count
  • Added get_max_cap query function to retrieve the configured capacity limit

Implementation Details

The capacity system works as follows:

  1. Default behavior: Max cap is 0 (unlimited participants) - maintains backward compatibility
  2. Setting a cap: Admin calls set_max_cap with desired limit
  3. Registration: The register function checks if max_cap > 0 and count >= max_cap before allowing new registrations
  4. Counting: Participant count is tracked separately from individual participant records for efficient querying
  5. Error handling: Returns CapacityReached error with clear message when limit is hit

Backward Compatibility

  • Existing campaigns continue to work with unlimited participants (max_cap defaults to 0)
  • No breaking changes to existing functions
  • Optional feature that can be enabled per campaign

Closes #4

- Add CapacityReached error variant (Error code 102)
- Add MAX_CAP and PARTICIPANT_COUNT storage keys
- Implement set_max_cap admin function to set capacity limit
- Update register function to check and enforce capacity
- Track participant count automatically on registration
- Add get_participant_count and get_max_cap query functions
- Cap value of 0 means unlimited participants (default behavior)

Closes FinesseStudioLab#4
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

@xqcxx is attempting to deploy a commit to the joelpeace48-cell's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 25, 2026

@xqcxx 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

@joelpeace48-cell joelpeace48-cell merged commit e8bc9c5 into FinesseStudioLab:main Mar 25, 2026
1 of 2 checks passed
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.

Add campaign cap (max participants) in campaign contract

2 participants