Skip to content

feat: implement the reject and refund features#22

Merged
Bosun-Josh121 merged 1 commit intoLightForgeHub:mainfrom
dinahmaccodes:issue16
Jan 29, 2026
Merged

feat: implement the reject and refund features#22
Bosun-Josh121 merged 1 commit intoLightForgeHub:mainfrom
dinahmaccodes:issue16

Conversation

@dinahmaccodes
Copy link
Contributor

@dinahmaccodes dinahmaccodes commented Jan 29, 2026

SkillSphere Pull Request


Tests added passed. General tests passed as well

Added 6 comprehensive test cases covering:
Successful rejection with refund
Authorization enforcement (user/wrong expert)
Status validation (Complete/Reclaimed sessions)
Error handling (non-existent bookings)

Images:

image

📌 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ Enhancement (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🏗️ Refactor (code improvement/cleanup without logical changes)

📝 Changes Description

Better description of tasks

Added reject_session functionality allowing experts to instantly decline pending consultation bookings with automatic full refunds to users.


📸 Evidence

image

Closes #16


Thank you for contributing to SkillSphere! 🌍

We are glad you have chosen to help us democratize access to knowledge on the Stellar network. Your contribution brings us one step closer to a trustless, peer-to-peer consulting economy. Let's build the future together! 🚀

Summary by CodeRabbit

  • New Features

    • Experts can now reject pending bookings, automatically refunding the user.
    • Added "Rejected" status to the booking lifecycle.
  • Tests

    • Added comprehensive test coverage for rejection scenarios, including authorization validation and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

This PR implements an expert-initiated session rejection feature, allowing experts to decline pending bookings and refund the user's deposit instantly. It adds the reject_session logic, corresponding event emission, type definitions, comprehensive tests, and updates the BookingStatus enum with a new Rejected variant.

Changes

Cohort / File(s) Summary
Core Rejection Logic
contracts/payment-vault-contract/src/contract.rs, contracts/payment-vault-contract/src/events.rs, contracts/payment-vault-contract/src/lib.rs
Introduces reject_session function with expert authorization, pending status validation, deposit transfer back to user, status update to Rejected, and corresponding session_rejected event emission. Public API method delegates to core contract logic.
Type Definitions
contracts/payment-vault-contract/src/types.rs
Updates BookingStatus enum to add Rejected = 2 variant and shifts Reclaimed discriminant from 2 to 3.
Test Suite
contracts/payment-vault-contract/src/test.rs
Adds six comprehensive unit tests covering expert rejection of pending sessions, authorization validation, state transition edge cases (Complete and Reclaimed bookings), wrong expert rejection attempts, and non-existent booking handling.

Sequence Diagram

sequenceDiagram
    participant Expert
    participant Contract as Payment Vault<br/>Contract
    participant Storage as Booking<br/>Storage
    participant User

    Expert->>Contract: reject_session(booking_id)
    Contract->>Contract: expert.require_auth()
    Contract->>Storage: Load booking
    Storage-->>Contract: booking data
    Contract->>Contract: Verify caller == booking.expert
    Contract->>Contract: Check booking.status == Pending
    Contract->>User: Transfer total_deposit
    User-->>Contract: Refund received
    Contract->>Storage: Update status to Rejected
    Storage-->>Contract: Status updated
    Contract->>Contract: Emit session_rejected event
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #14: Modifies BookingStatus and BookingRecord type definitions in the same types.rs file; the main PR adds the Rejected variant while interacting with existing Reclaimed and Complete statuses introduced in that PR.
  • PR #11: Both PRs modify the booking lifecycle across contract.rs, events.rs, lib.rs, and test.rs; this PR extends the lifecycle with rejection semantics alongside existing finalization and reclamation flows.

Poem

A clever fox rejects with grace,
Refunds returned to rightful place,
Pending sessions meet their end,
Hopping onward, funds to send! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature addition of implementing reject and refund functionality for experts.
Linked Issues check ✅ Passed Code changes fully implement issue #16 requirements: BookingStatus enum updated with Rejected/Reclaimed variants [#16], session_rejected event function added [#16], reject_session implemented with expert auth and pending status check [#16], fund transfer and status update logic present [#16], comprehensive test coverage added [#16].
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #16 requirements. No unrelated modifications detected in contract logic, event handling, types, or test additions.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed PR description includes issue reference, test attestation, evidence (screenshots), and code changes overview, but lacks detail on breaking changes impact and specific comments about edge cases.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dinahmaccodes
Copy link
Contributor Author

@Bosun-Josh121 Please review PR

@Bosun-Josh121 Bosun-Josh121 merged commit d9463b5 into LightForgeHub:main Jan 29, 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.

Implement "Reject & Refund" (Expert Action)

2 participants