Skip to content

feat: #75 Implement event fund withdrawal for organizers - #144

Merged
manoahLinks merged 2 commits into
crowdpass-live:mainfrom
jayteemoney:feature/event-fund-withdrawal
Mar 28, 2026
Merged

feat: #75 Implement event fund withdrawal for organizers#144
manoahLinks merged 2 commits into
crowdpass-live:mainfrom
jayteemoney:feature/event-fund-withdrawal

Conversation

@jayteemoney

Copy link
Copy Markdown
Contributor

Summary

  • Adds withdraw_funds(event_id) to the event_manager Soroban contract so organizers can collect accumulated ticket-sale revenue after an event concludes
  • Introduces an escrow model: funds from purchase_ticket / purchase_tickets are now held by the contract (EventBalance per event) rather than sent directly to the organizer, and released via withdraw_funds
  • claim_refund deducts from the escrowed balance so refunds on cancelled events remain functional
  • Resolves pre-existing merge-conflict artifacts (duplicate function definitions, conflicting error enum values) that prevented the contract from compiling

Requirements fulfilled

Requirement Implementation
withdraw_funds(event_id) in event_manager ✅ Added
Only callable by event organizer event.organizer.require_auth()
Only after event end_date has passed Error::EventNotEnded guard
Only if event is not cancelled Error::EventAlreadyCanceled guard
Transfer accumulated funds to organizer wallet ✅ Token transfer from contract escrow
Emit withdrawal event funds_withdrawn event published
Prevent double withdrawal DataKey::FundsWithdrawn persistent flag

New storage keys

  • DataKey::EventBalance(u32) — escrowed ticket-sale balance per event
  • DataKey::FundsWithdrawn(u32) — double-withdrawal guard flag

New error variants

  • Error::EventNotEnded = 19
  • Error::FundsAlreadyWithdrawn = 20

Test results

running 38 tests
test test::test_withdraw_funds_success ... ok
test test::test_withdraw_funds_before_end_date ... ok
test test::test_withdraw_funds_cancelled_event ... ok
test test::test_withdraw_funds_double_withdrawal ... ok
test test::test_withdraw_funds_nonexistent_event ... ok
test test::test_withdraw_funds_not_organizer ... ok
test test::test_withdraw_funds_zero_balance ... ok
test test::test_withdraw_funds_after_partial_refunds ... ok
... (30 existing tests) ...
test result: ok. 38 passed; 0 failed; 0 ignored

Closes #75

…s-live#75)

Add withdraw_funds(event_id) to the event_manager contract so organizers
can collect accumulated ticket-sale revenue after an event concludes.

Guards enforced:
- Only callable by the event organizer (require_auth)
- Only after event end_date has passed (EventNotEnded)
- Only if the event was not cancelled (EventAlreadyCanceled)
- Prevents double withdrawal via a persistent FundsWithdrawn flag

Funds are now escrowed in the contract during purchase_ticket /
purchase_tickets (tracked in EventBalance per event) and released to
the organizer wallet via withdraw_funds. claim_refund deducts from the
escrowed balance when a cancelled event is refunded.

New additions:
- DataKey::EventBalance(u32) — escrowed balance per event
- DataKey::FundsWithdrawn(u32) — double-withdrawal guard
- Error::EventNotEnded (19), Error::FundsAlreadyWithdrawn (20)
- withdraw_funds public function with full guard logic
- 8 new tests covering all edge cases

Also resolves pre-existing merge-conflict artifacts in lib.rs and
test.rs (duplicate function definitions, conflicting error enum
values) that prevented the contract from compiling.
@drips-wave

drips-wave Bot commented Mar 28, 2026

Copy link
Copy Markdown

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

@manoahLinks
manoahLinks merged commit 1ff0aec into crowdpass-live:main Mar 28, 2026
1 of 3 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.

Implement event fund withdrawal for organizers

2 participants