Skip to content

Conversation

@KevinMB0220
Copy link
Contributor

@KevinMB0220 KevinMB0220 commented Jan 25, 2026

🧠 SkillSphere Pull Request 🌐

Close #15

Mark with an x all the checkboxes that apply (like [x])

  • Closes # (Insert Issue Number)
  • Added tests (if necessary)
  • Ran cargo test (All tests passed)
  • Evidence attached (Screenshots, Logs, or Transaction Hashes)
  • Commented the code

📌 Type of Change

  • 📚 Documentation (updates to README, docs, or comments)
  • 🐛 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

This PR enhances the Payment Vault smart contract by improving its internal logic, storage handling, and test coverage.

Summary of changes:

  • Updated core contract logic in contract.rs to improve payment flow validation and safety.
  • Refined on-chain storage structures in storage.rs for clearer state management.
  • Updated public exports in lib.rs to align with the new contract behavior.
  • Added and updated unit tests in test.rs to cover new logic and relevant edge cases.

Impact:

  • Storage: No breaking changes to existing storage layout.
  • Gas: Minor increase due to additional validations, considered acceptable for improved safety.

📸 Evidence

  • cargo test executed successfully
  • All contract tests passed without errors

(Logs or screenshots attached if required.)


🌌 Comments

  • Focused on contract safety and correctness.
  • Reviewers may want to pay special attention to edge cases around payment execution and state updates.

Thank you for contributing to SkillSphere! 🌍
Together we’re building a trustless, peer-to-peer consulting economy on Stellar 🚀

Summary by CodeRabbit

  • New Features

    • Users and experts can retrieve their complete booking histories.
    • Detailed booking lookup available by booking ID.
    • New bookings are now recorded so they appear in both user and expert histories immediately.
  • Tests

    • Added end-to-end tests verifying booking creation, history listing for users/experts, and booking detail queries.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Adds per-user and per-expert booking lists: storage keys and helpers to append/retrieve booking IDs, exposes read-only getters on the contract, and updates the booking creation flow to register booking IDs in both user and expert lists before emitting the creation event.

Changes

Cohort / File(s) Summary
Storage Layer
contracts/payment-vault-contract/src/storage.rs
Added DataKey variants UserBookings(Address) and ExpertBookings(Address) and implemented add_booking_to_user_list, add_booking_to_expert_list, get_user_bookings, and get_expert_bookings to persist and retrieve booking ID lists.
Public API
contracts/payment-vault-contract/src/lib.rs
Added public getters get_user_bookings(env, user) -> Vec<u64>, get_expert_bookings(env, expert) -> Vec<u64>, and get_booking(env, booking_id) -> Option<BookingRecord>; updated imports for Vec and BookingRecord.
Booking Creation
contracts/payment-vault-contract/src/contract.rs
In book_session, after saving a booking, call storage::add_booking_to_user_list(env, user, booking_id) and storage::add_booking_to_expert_list(env, expert, booking_id) before emitting the booking_created event and returning the ID.
Tests
contracts/payment-vault-contract/src/test.rs
Added test_get_user_and_expert_bookings which creates two bookings for one user with two experts, asserts get_user_bookings returns both IDs in order, asserts each expert's bookings, and verifies get_booking returns expected data and None for missing IDs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client
  participant Contract as PaymentVaultContract
  participant Storage as Storage
  participant EventSys as EventEmitter

  Client->>Contract: book_session(user, expert, params)
  Contract->>Storage: save_booking(BookingRecord) -> booking_id
  Note over Contract,Storage: new flow: register booking id
  Contract->>Storage: add_booking_to_user_list(user, booking_id)
  Contract->>Storage: add_booking_to_expert_list(expert, booking_id)
  Contract->>EventSys: emit booking_created(booking_id)
  Contract-->>Client: return booking_id
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hop, hop! A booking trails its mark,
I stash each hop from dawn to dark,
User hops and expert hops align,
IDs in rows, all neat and fine —
✨📋

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feat/payment vault enhancements' is broad and does not specifically highlight the primary change of implementing user and expert booking lists. Consider a more specific title like 'Add user/expert booking list tracking and dashboard queries' to clearly describe the main feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description follows the template structure with checkboxes, type of change, changes description, and evidence, though the changes description is somewhat vague.
Linked Issues check ✅ Passed All primary requirements from issue #15 are implemented: DataKey variants added, storage helpers created, book_session modified, new query methods exposed, and tests added.
Out of Scope Changes check ✅ Passed All changes directly support the 'My Bookings' feature implementation with no unrelated modifications detected.

✏️ 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.

@Bosun-Josh121 Bosun-Josh121 merged commit cdc4def into LightForgeHub:main Jan 25, 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 "My Bookings" (Dashboard Data)

2 participants