Skip to content

feat: Stellar Transaction History Importer module [#642]#7

Closed
gidson5 wants to merge 1 commit into
Ukobach-3:mainfrom
gidson5:feat/stellar-history-importer
Closed

feat: Stellar Transaction History Importer module [#642]#7
gidson5 wants to merge 1 commit into
Ukobach-3:mainfrom
gidson5:feat/stellar-history-importer

Conversation

@gidson5

@gidson5 gidson5 commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Closes #642

Implements the full Stellar Transaction History Importer module:

  • HistoryImportJob entity with PENDING/RUNNING/COMPLETED/FAILED status and resumable cursor
  • StellarHistoryImporterService: importHistory, getImportStatus, syncNewTransactions, mapHorizonTxToInternal, deduplicateByTxHash, resumeFromCursor
  • Cursor-based Horizon pagination (200 tx/page), saves progress after each page so jobs are resumable on failure
  • Deduplication by txHash via ON CONFLICT DO NOTHING; gracefully handles missing table on first run
  • HistoryImportProcessor (BullMQ WorkerHost) with 3 retries and exponential backoff
  • StellarHistoryImporterController: POST /wallets/:id/import-history, GET /wallets/:id/import-status
  • WalletVerifiedListener auto-triggers import on wallet.verified EventEmitter event
  • BullModule.forRootAsync wired into AppModule (reads REDIS_HOST, REDIS_PORT, REDIS_PASSWORD)
  • In-app notification via wallet.history.imported event on completion
  • 22 unit tests covering all public methods with mocked Horizon SDK and TypeORM repository

- HistoryImportJob entity (id, walletId, status, totalImported, cursor,
  startedAt, completedAt) with PENDING/RUNNING/COMPLETED/FAILED states
- StellarHistoryImporterService with importHistory, getImportStatus,
  syncNewTransactions, mapHorizonTxToInternal, deduplicateByTxHash,
  and resumeFromCursor methods
- Cursor-based Horizon pagination (200 tx/page), progress saved after
  each page so jobs are resumable on failure
- Deduplication by txHash via stellar_transactions table with graceful
  fallback when table does not exist yet
- HistoryImportProcessor (BullMQ WorkerHost) with 3 retries and
  exponential backoff
- StellarHistoryImporterController: POST /wallets/:id/import-history
  and GET /wallets/:id/import-status
- WalletVerifiedListener auto-triggers import on wallet.verified event
- BullModule.forRootAsync wired into AppModule with Redis config
- Unit tests (22 cases) covering all public methods with mocked Horizon
  SDK and repository
- Added @nestjs/bullmq, bullmq, ioredis, @nestjs/event-emitter to deps
@gidson5 gidson5 closed this Mar 30, 2026
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.

1 participant