Skip to content

feat(earnings): event-sourced payout history via rpc.getEvents (fixes #9) - #26

Open
NePreby wants to merge 10 commits into
Flow-Pulse:mainfrom
NePreby:feat/event-sourced-payout-history
Open

NePreby wants to merge 10 commits into
Flow-Pulse:mainfrom
NePreby:feat/event-sourced-payout-history

Conversation

@NePreby

@NePreby NePreby commented Nov 6, 2026

Copy link
Copy Markdown

Overview

Resolves #9 by implementing event-sourced payout history using Soroban rpc.getEvents, replacing the empty-state on fresh browsers while maintaining seamless integration with local RFC-8785 audit receipts.

Changes

  1. Event Decoder & Fetcher (frontend/src/lib/events.ts):

    • Queries server.getEvents with lookback across StreamRouter and CascadeSplitter contracts.
    • Robustly decodes contract event topics (withdrawn, created, topped_up, cancelled, distributed, splits_set) and map/tuple values via scValToNative.
    • Filters events dynamically to the connected maintainer address (as recipient, sender, owner, or payer).
    • Graceful fallback: handles RPC timeouts, network failures, and RPC ledger retention limits without breaking the UI.
  2. Deduplicating Merger (mergeEventsWithReceipts):

    • Combines on-chain RPC events with locally cached RFC-8785 receipts.
    • De-duplicates by tx_hash, pairing audit receipts with their verified on-chain event records.
    • Sorts history chronologically (newest first).
  3. Earnings Page Integration (frontend/src/pages/Earnings.tsx):

    • Added usePayoutLedger hook with live loading pip indicator.
    • Displays unified transaction ledger with action icons, settled amounts, relative timestamps, and tx hash links.
    • Badges differentiate between local Receipt (opens audit verification modal) and RPC Event ↗ (opens Stellar Expert transaction explorer).
  4. Unit Tests & Verification (frontend/src/lib/__tests__/events.test.ts):

    • Unit tests covering withdrawn, created, and distributed event decodings, invalid topic handling, and receipt de-duplication.
    • All 79 vitest unit tests pass cleanly, tsc -b clean, and production Vite bundle compiles without errors.

Closes #9.


Bounty Payout Wallet (TRC20 USDT / TRX):
TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv

This branch has not been deployed

No deployments
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.

Event-sourced payout history (replace localStorage-only ledger)

1 participant