Skip to content

feat: add royalty earnings tracker and claim UI to creator dashboard - #1013

Open
sojetunde8 wants to merge 2 commits into
accesslayerorg:devfrom
sojetunde8:feature/987-royalty-earnings-tracker
Open

sojetunde8 wants to merge 2 commits into
accesslayerorg:devfrom
sojetunde8:feature/987-royalty-earnings-tracker

Conversation

@sojetunde8

Copy link
Copy Markdown

Closes #987

Summary

Adds a royalty earnings section to the creator key management dashboard. The section shows total earned / pending / claimed totals, a per-transfer breakdown of the royalty events, a Claim Royalties button wired to a claim_royalties contract-call mutation, and claimed history with Stellar Expert transaction hash links. Earnings data is fetched via React Query with a 60-second refetchInterval, matching the issue's refresh requirement and the existing useNotifications cadence.

Scope

  • src/services/royaltyEarnings.service.ts (new) — RoyaltyEarnings/RoyaltyEarningsEvent/RoyaltyClaim types and GET /creators/:creatorId/royalties fetcher following the BaseApiService convention.
  • src/hooks/useRoyaltyEarnings.ts (new) — React Query hook, key ['creators', creatorId, 'royalties'], refetchInterval: 60_000; queryFn injectable for tests.
  • src/hooks/useRoyaltyClaim.ts (new) — claim_royalties mutation following useCreatorContractActions' simulated-signing convention (on-chain wiring not in the client yet); invalidates the royalties query and toasts on success.
  • src/components/creator/RoyaltyEarningsSection.tsx (new) — totals card, per-transfer breakdown list, claim button (disabled + "Claiming…" while pending), claimed history with buildStellarExpertTxUrl links, loading/empty/error states.
  • src/lib/queryKeys.ts — adds creators.royalties(creatorId).
  • src/pages/CreatorDashboardPage.tsx — renders the section on the Overview tab, below the stats card.

Testing

  • src/components/creator/__tests__/RoyaltyEarningsSection.test.tsx (new) covers all acceptance criteria: totals rendered from the payload, per-transfer list, claim button invoking the mutation, claimed history with tx-hash links, 60s refresh (fake timers advance past ROYALTY_EARNINGS_REFETCH_INTERVAL_MS), empty and error states, and disabled claim while pending.
  • Tests follow the repo's vitest + RTL + injected-queryFn conventions (no module-level API mocks needed).
  • Dependency installs are intentionally skipped in this environment (Windows-mounted filesystem makes pnpm install time out; CI covers the actual vitest run and typecheck). Static checks: no leftover conflict markers, balanced JSX after rebasing onto the latest dev, imports resolve to existing utils (formatNumber, formatRelativeTimeLabel, truncateTxHash, buildStellarExpertTxUrl).

Files changed

  • src/services/royaltyEarnings.service.ts (new)
  • src/hooks/useRoyaltyEarnings.ts (new)
  • src/hooks/useRoyaltyClaim.ts (new)
  • src/components/creator/RoyaltyEarningsSection.tsx (new)
  • src/components/creator/__tests__/RoyaltyEarningsSection.test.tsx (new)
  • src/lib/queryKeys.ts
  • src/pages/CreatorDashboardPage.tsx

@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@sojetunde8 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

Development

Successfully merging this pull request may close these issues.

Add royalty earnings tracker and claim UI in creator key management dashboard

1 participant