Feat/giveaway claim timeout - #418
Merged
Merged
Conversation
…vapp#406) Replaces the push-based distribute_prize with a pull-based claim lifecycle: winners call claim_prize individually while Claimable and before a 7-day claim_deadline set at winner selection. After expiry, the creator or admin can call recover_unclaimed_prize to sweep any still-unclaimed shares back to the creator, finalizing the giveaway. Already-claimed shares are untouched by recovery.
3 tasks
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.
Summary
closes #406
Implements #406 — adds a claim deadline and creator recovery path for unclaimed giveaway prizes.
This also absorbs the stated dependency, "Replace public distribution with winner claim lifecycle," since it hadn't landed yet in this repo — there was no per-winner claim step to attach a timeout to, so this PR builds both in one pass.
distribute_prize(which paid every winner in one call) with a pull-basedclaim_prize(giveaway_id, winner)that each winner calls individually for their own shareGiveawaygainsclaim_deadline(set once, 7 days after the giveaway becomesClaimable) andclaimed_countrecover_unclaimed_prize(giveaway_id, caller)— callable by the creator or admin onceclaim_deadlinehas passed — sweeps any still-unclaimed shares back to the creator and finalizes the giveaway; shares already claimed by other winners are untouchedfee_bps) is now deducted per-claim, on the claiming winner's share only; recovered/unclaimed funds return to the creator at full value since they were never distributedRequirements addressed
claim_deadline, fixed 7-day window)recover_unclaimed_prize)claim_prizerejects claims after expiry)Acceptance criteria
Test plan
cargo test— 71/71 passing, including new coverage: claim before/after expiry, double-claim rejection, non-winner claim rejection, recovery before/after expiry, unauthorized recovery rejection, and partial-claim recovery (one winner claims, one doesn't — only the unclaimed share is recovered, claimed funds untouched)cargo fmt --check— cleancargo clippy --all-targets— clean (no new warnings)Closes #406
Fixes #406