Skip to content

feat(royalties): implement multi-recipient royalty splits for collaborative beats (#8) - #25

Open
Simultech369 wants to merge 1 commit into
Crate-Protocol:mainfrom
Simultech369:feat/multi-recipient-royalty-splits
Open

feat(royalties): implement multi-recipient royalty splits for collaborative beats (#8)#25
Simultech369 wants to merge 1 commit into
Crate-Protocol:mainfrom
Simultech369:feat/multi-recipient-royalty-splits

Conversation

@Simultech369

Copy link
Copy Markdown

Summary of Changes

This pull request resolves #8 by implementing multi-recipient royalty splits for collaborative beats, allowing beatmakers, vocalists, songwriters, and mixing engineers to automatically split on-chain license sales.

🎯 Key Implementations

  1. Contract Interfaces & Split Math (src/contracts/crate.ts)

    • Defined strongly-typed RoyaltySplit interface (recipient, bps: basis points where 10,000 bps = 100%, role).
    • Added validateSplits helper enforcing 100% sum allocation (10,000 bps) and valid recipient addresses.
    • Added calculateSplitPayouts helper calculating pro-rata revenue allocations across collaborators while deterministically attributing fractional remainders to eliminate rounding drift.
    • Extended SampleData and uploadSample with splits?: RoyaltySplit[].
  2. Upload UI with Dynamic Collaborator Splitting (src/pages/Upload.tsx)

    • Added dynamic collaborator rows allowing multiple contributor addresses, customizable roles (Producer, Co-Producer, Vocalist, Songwriter, Mixing & Mastering, Featured Artist), and percentage shares.
    • Quick-split presets: Solo (100%), 50/50 Split, and Equal Split.
    • Dynamic real-time allocation badge (green on 100% allocated, amber on remaining, red on exceeded) and validation preventing upload until total is 100%.
    • Live revenue breakdown preview displaying estimated XLM payouts per collaborator per sale.
  3. Sample Detail & Profile Integration (src/pages/SampleDetail.tsx, src/pages/Profile.tsx)

    • SampleDetail.tsx: Displays collaborative royalty splits breakdown with role badges, recipient abbreviations, and percentage shares.
    • Profile.tsx: Displays individual contributor royalty shares and earnings on collaborative tracks, supporting per-collaborator withdrawal tracking.
  4. Comprehensive Unit Tests (src/__tests__/royaltySplits.test.tsx)

    • 11 dedicated test cases verifying solo/multi-collaborator split validations, sum-to-100% boundary checks, basis points division, zero rounding drift, and error feedback.

🧪 Verification & Testing

  • npx vitest run:

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.

feat: multi-recipient royalty splits for collaborative beats

1 participant