Skip to content

Fix/trade indexer and pagination helpers - #639

Merged
Chucks1093 merged 10 commits into
accesslayerorg:mainfrom
Mosas2000:fix/trade-indexer-and-pagination-helpers
Jul 26, 2026
Merged

Fix/trade indexer and pagination helpers#639
Chucks1093 merged 10 commits into
accesslayerorg:mainfrom
Mosas2000:fix/trade-indexer-and-pagination-helpers

Conversation

@Mosas2000

Copy link
Copy Markdown
Contributor

Summary

Testing

  • pnpm lint
  • pnpm build
  • pnpm exec prisma generate when schema or generated types changed

Checklist

This PR resolves issues #619, #625, #630, and #631.

  1. Closes Add integration test for trade indexer correctly persisting buy events from Soroban transaction stream #619: Trade Indexer Buy Event Persistence & Integration Test
    Added Trade Prisma model in prisma/schema/trade.prisma with a compound unique index on (ledger, txHash) to support idempotent event writes.
    Added processTradeEvent service in src/modules/indexer/trade-indexer.service.ts to validate required fields (buyer, creator_id, quantity, price, ledger, tx_hash, timestamp), persist valid events, skip duplicate events, and warn-log malformed inputs.
    Created integration test src/modules/indexer/trade-indexer.integration.test.ts to verify field accuracy, idempotency, malformed event skipping, and warn logging.
  2. Closes Add helper for paginating database queries with a keyset cursor on the trade history table #625: Keyset Cursor Pagination Helper for Trade History
    Added queryTradesPage(creatorId: string, cursor: string | null, limit: number, db: any) helper in src/utils/trade-pagination.utils.ts.
    Encodes/decodes (ledger, tx_hash) using HMAC-signed base64url cursors for stable keyset pagination ordered by ledger desc, txHash desc.
    Added unit tests in src/utils/tests/trade-pagination.utils.test.ts asserting first page ordering, cursor page traversal, has_more correctness, and record uniqueness across pages.
  3. Closes Add integration test for creator detail endpoint returning correct holder count after sequential buys and sells #630: Creator Detail Holder Count Integration Test
    Updated httpGetCreatorStats in src/modules/creators/creators.controllers.ts and mapPublicCreatorStats in src/modules/creators/creators.stats.ts to query active key holders (KeyOwnership records with balance > 0) and expose both holderCount and holder_count.
    Created integration test src/modules/creators/creator-detail-holder-count-sequential.integration.test.ts verifying holder count changes across sequential buys and sells across multiple wallets (0 → 1 → 2 → 2 → 1 → 0).
  4. Closes Add helper for formatting structured log fields consistently across all server modules #631: Shared Log Fields Formatting Builder
    Added buildLogFields(base: LogFields): Record<string, unknown> in src/utils/log-fields.utils.ts to enforce snake_case keys, ISO 8601 timestamps, and truncation of string values exceeding 500 characters with a [TRUNCATED] suffix.
    Applied buildLogFields across server log call sites.
    Added unit tests in src/utils/tests/log-fields.utils.test.ts verifying key conversion, ISO timestamp formatting, and string truncation rules.
  • Linked issue or backlog item
  • No secrets or live credentials added
  • Docs updated if setup or env changed
  • Change is scoped to one problem

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

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

@Chucks1093
Chucks1093 merged commit 5c1cd17 into accesslayerorg:main Jul 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment