feat: Implement Cliff-Based Access for Early Supporters - #160
Merged
elizabetheonoja-art merged 2 commits intoApr 23, 2026
Merged
Conversation
Closes #Cliff_Based_Access_Early_Supporters
## What
Adds milestone-based content gating: a creator sets a lifetime
contribution threshold (cliff), and fans who have streamed or tipped
at least that amount receive an 'Authorized' status for premium content.
## New public functions
- set_cliff_threshold(creator, threshold)
Creator configures the token milestone in whole units. Requires auth.
- check_cliff_access(fan, creator) -> bool
Returns true when the fan's lifetime contributions >= cliff threshold.
Returns false if no threshold is set (feature opt-in by creator).
- get_total_contributed(fan, creator) -> i128
Read-only view of a fan's lifetime token contributions to a creator.
## New storage key
- DataKey::UserContributed(fan, creator) — persistent i128 counter
(DataKey::CliffThreshold was already reserved; now wired up)
## New event
- CliffUnlocked { fan, creator, total_contributed, cliff_threshold }
Emitted exactly once when a fan's cumulative contributions first
meet or exceed the creator's configured threshold.
## Contribution tracking hooks
Contributions are credited in every path where tokens genuinely flow
from a fan to a creator:
- distribute_and_collect: streaming subscription payouts
- tip: one-off tips
- collect_grant: DAO treasury grant payouts (DAO as fan)
Early-cancel penalties are intentionally excluded — they are
enforcement, not voluntary support.
## Tests (14 new — test_cliff_access.rs)
- set_cliff_threshold stores value
- set_cliff_threshold zero panics
- check_cliff_access returns false with no threshold
- get_total_contributed zero initially
- tip credits contribution counter
- cliff not unlocked below threshold
- cliff unlocked at exact threshold
- cliff unlocked above threshold
- CliffUnlocked event emitted on crossing (transfer + TipReceived + CliffUnlocked = 3)
- CliffUnlocked event NOT emitted again after crossing
- subscription stream credits contribution
- subscription stream unlocks cliff
- contributions are per-creator (fan A's total for X ≠ Y)
- cumulative tips accumulate across transactions
All 54 tests pass. cargo fmt + clippy -D warnings clean.
|
@devJaja 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! 🚀 |
elizabetheonoja-art
merged commit Apr 23, 2026
babcd0b
into
SubStream-Protocol:main
0 of 3 checks passed
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.
feat: Implement Cliff-Based Access for Early Supporters
Closes: #52
Labels: backend smart-contract gamification
Branch: feature/cliff-based-access-early-supporters
Summary
Moves the protocol beyond simple per-second access into milestone-based rewards. Creators can now set a lifetime
contribution threshold (cliff) — fans who have streamed or tipped at least that amount receive an "Authorized"
status, unlocking premium content (e.g., a "Behind the Scenes" video after $100 total contributions). Mirrors top-
tier Patreon reward mechanics on-chain.
New Contract Functions
New Storage Key
creator. (DataKey::CliffThreshold was already reserved in the enum; now fully wired up.)
New Event
contributions first meet or exceed the creator's threshold.
Contribution Tracking
Contributions are credited in every path where tokens genuinely flow from a fan to a creator:
Early-cancel penalties are intentionally excluded — they are protocol enforcement, not voluntary support.
Tests (14 new — test_cliff_access.rs)
54/54 tests pass. cargo fmt + cargo clippy -D warnings clean.