Skip to content

Comments

feat(contract): cancellation refund math#46

Merged
Kaylahray merged 1 commit intoQuid-proquo:mainfrom
walterthesmart:feat/cancellation-refund
Feb 20, 2026
Merged

feat(contract): cancellation refund math#46
Kaylahray merged 1 commit intoQuid-proquo:mainfrom
walterthesmart:feat/cancellation-refund

Conversation

@walterthesmart
Copy link
Contributor

Implement refund calculation for cancelled missions.

Changes

  • Added cancel_mission(env: Env, mission_id: u64) function to QuidStoreContract.
  • Implemented logic to calculate unspent funds: (max_participants - participants_count) * reward_amount.
  • Refund logic triggers if refund_amount > 0.
  • Transfers tokens from contract to mission owner using token::Client.
  • Updates mission status to Cancelled.
  • Emits mission_cancelled event.
  • Prevents double refund by checking if mission is already Closed/Cancelled.

Fixes

Closes #38

Test

Added test_cancel_mission_full_refund to verify full refund on cancellation.
Added test_cancel_already_cancelled_mission_fails to verify idempotent safety.

@walterthesmart
Copy link
Contributor Author

@Kaylahray, Kindly look into this fix and merge accordingly.

Copy link
Contributor

@Kaylahray Kaylahray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for completing this issue.

@Kaylahray Kaylahray merged commit e177ec3 into Quid-proquo:main Feb 20, 2026
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.

[Contract] Implement Refund Calculation

2 participants