Skip to content

feat: escrow partial release, portfolio analytics, team collaboration, review moderation (#601-604) - #695

Open
a-malik-gh wants to merge 2 commits into
Dfunder:mainfrom
a-malik-gh:feature/issues-601-602-603-604
Open

feat: escrow partial release, portfolio analytics, team collaboration, review moderation (#601-604)#695
a-malik-gh wants to merge 2 commits into
Dfunder:mainfrom
a-malik-gh:feature/issues-601-602-603-604

Conversation

@a-malik-gh

Copy link
Copy Markdown
Contributor

Summary

This PR implements all four issues assigned to a-malik-gh.

Closes #601
Closes #602
Closes #603
Closes #604


#601 – Escrow Partial Release for Milestone-Based Work

Files: contracts/escrow/src/lib.rs, contracts/escrow/src/storage.rs, contracts/escrow/src/tests.rs, contracts/escrow/src/storage_edge_tests.rs

  • Added partial_release(commission_id, release_amount, config_contract): releases a fixed amount from a Locked or PartiallyReleased escrow to the artist (minus platform fee split). Transitions to Released when the full amount has been paid out.
  • Added auto_release_on_deadline(commission_id, auto_release_ledger, config_contract): releases the remaining balance automatically once the ledger sequence meets or exceeds auto_release_ledger.
  • Added PartiallyReleased = 5 variant to CommissionStatus enum.
  • Added released_amount: i128 field to EscrowRecord to track cumulative partial releases.
  • All operations follow CEI ordering and are protected by the re-entrancy guard.
  • Overflow-safe arithmetic (checked_add, checked_sub, checked_mul) throughout.
  • Tests cover: state machine transitions, fee split calculations, deadline boundary, amount validation, and end-to-end partial → full release flow.

#602 – Portfolio Analytics Contract

Files: contracts/analytics/ (new package)

  • record_earning: tracks earnings per category and client, increments completed_count, appends a paginated EarningsRecord.
  • record_cancellation: increments cancelled_count for completion rate calculation.
  • record_response_time: rolling sum for average response-time analytics.
  • record_satisfaction: score_x10 (range 10–50) rolling average for satisfaction trends.
  • predict_earnings: returns mean payout per commission as an earnings forecast.
  • Read functions: get_metrics, get_completion_rate, get_avg_response_time, get_avg_satisfaction, get_earning, get_earning_count.
  • Admin-only write operations; data retained for ~90 days (ANALYTICS_TTL_LEDGERS).
  • Full test suite covering all five acceptance criteria.

#603 – Team Collaboration Features

Files: contracts/commission_agreement/src/lib.rs, contracts/commission_agreement/src/types.rs, contracts/commission_agreement/src/errors.rs, contracts/commission_agreement/src/test.rs

  • invite_team_member: lead artist invites members with TeamRole (Lead/Contributor/Viewer), payment_share_bps (cumulative cap at 10 000 bps), dedup, max 10 members.
  • accept_team_invitation / decline_team_invitation: only the invited member can act on their own Pending invitation.
  • update_contribution_note: member or lead artist can update the contribution description.
  • get_team_members: returns the full team list for a commission.
  • New types: TeamRole, InvitationStatus, TeamMember.
  • New errors: MemberAlreadyExists, PaymentShareExceeded, InvalidInvitationStatus, TeamSizeLimit.
  • Tests cover: invite, duplicate guard, share cap, accept, decline, role assignment, empty team, and status guard.

#604 – Review Moderation & Appeal System

Files: contracts/reputation/ (new package)

  • submit_review: rating_x10 range 10–50, dedup by review_id, reviewer auth required.
  • report_review: reason enum (Spam/Abuse/Misleading/Other), dedup by reporter+review_id, transitions review → UnderReview, adds to admin moderation queue.
  • moderate_review: admin-only, sets Removed or Cleared, appends a ModerationRecord to decision history.
  • file_appeal: only the affected artist or original reviewer may appeal a Removed review; one appeal per review enforced.
  • resolve_appeal: Upheld reinstates the review to Active; Denied leaves it Removed.
  • escalate_appeal: marks appeal Escalated for the external dispute arbiter.
  • Full test suite covering all five acceptance criteria.

Code Quality

  • 0 compiler errors, 0 warnings on cargo build
  • Removed 3 unnecessary mut bindings in commission_agreement/lib.rs
  • Wrapped escrow/integration_tests under #[cfg(test)]
  • Added #[allow(dead_code)] on get_suggestion helpers (public introspection API, consumed by SDK/frontend)

Testing

cargo build passes cleanly. Unit tests are written and structured for all four contracts. The cargo test runner is blocked environment-wide by a pre-existing ed25519-dalek version conflict in soroban-env-host (not introduced by this PR — affects all packages in the workspace equally).

…laboration, and review moderation

Closes Dfunder#601 – Implement Escrow Partial Release for Milestone-Based Work
Closes Dfunder#602 – Implement Portfolio Analytics Contract
Closes Dfunder#603 – Implement Team Collaboration Features
Closes Dfunder#604 – Add Review Moderation & Appeal System

## Dfunder#601 – Escrow Partial Release
- Add `partial_release` to EscrowContract: supports percentage or fixed
  amount releases from Locked/PartiallyReleased escrows with overflow-safe
  fee split (fee_bps) and CEI ordering under reentrancy guard
- Add `auto_release_on_deadline`: releases remaining balance to artist
  when ledger sequence >= auto_release_ledger
- Add `PartiallyReleased` status to CommissionStatus enum with discriminant 5
- Add `released_amount` field to EscrowRecord (tracks cumulative releases)
- Transitions to Released automatically when released_amount == amount
- Tests: state machine transitions, fee split math, deadline guard,
  boundary values (storage_edge_tests.rs + tests.rs)

## Dfunder#602 – Portfolio Analytics Contract
- New contracts/analytics/ package with full Soroban contract
- record_earning: tracks earnings by category + client, increments
  completed_count, appends EarningsRecord log with pagination support
- record_cancellation: increments cancelled_count for completion rate
- record_response_time: rolling sum for average response time analytics
- record_satisfaction: score_x10 (10-50 range) rolling average
- predict_earnings: mean payout per commission (rolling average)
- get_metrics, get_completion_rate, get_avg_response_time,
  get_avg_satisfaction, get_earning, get_earning_count
- Admin-only write operations, ANALYTICS_TTL_LEDGERS (~90 days) TTL

## Dfunder#603 – Team Collaboration
- invite_team_member: role-based (Lead/Contributor/Viewer), payment_share_bps
  validation (0-10000 bps cumulative cap), max 10 members, dedup
- accept_team_invitation / decline_team_invitation: only the invited
  member can change their Pending status
- update_contribution_note: member or lead artist can update
- get_team_members: returns Vec<TeamMember> for a commission
- New types: TeamRole, InvitationStatus, TeamMember
- New errors: MemberAlreadyExists, PaymentShareExceeded,
  InvalidInvitationStatus, TeamSizeLimit

## Dfunder#604 – Review Moderation & Appeal System
- New contracts/reputation/ package with full Soroban contract
- submit_review: rating_x10 (10-50), dedup by review_id, reviewer auth
- report_review: reason enum (Spam/Abuse/Misleading/Other), dedup by
  reporter+review_id, transitions review to UnderReview, adds to queue
- moderate_review: admin-only, sets Removed/Cleared, appends
  ModerationRecord history, maintains queue size counter
- file_appeal: only artist or original reviewer, one appeal per review,
  only on Removed reviews
- resolve_appeal: Upheld reinstates review to Active; Denied leaves Removed
- escalate_appeal: marks appeal Escalated for external dispute arbiter

## Fixes
- Remove 3 unnecessary `mut` bindings in commission_agreement/lib.rs
- Wrap escrow integration_tests under #[cfg(test)]
- Add #[allow(dead_code)] on get_suggestion helpers (public API, used
  by SDK/frontend consumers)
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@a-malik-gh 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant