Skip to content

feat(chain-watcher): Publish chain transactions to Redis Streams#58

Merged
geminimir merged 1 commit intomainfrom
feature/chain-tx-redis-publisher
Mar 15, 2026
Merged

feat(chain-watcher): Publish chain transactions to Redis Streams#58
geminimir merged 1 commit intomainfrom
feature/chain-tx-redis-publisher

Conversation

@geminimir
Copy link
Owner

Summary

After detecting a chain transaction, publish it to a Redis Stream so the Correlator and Finality Tracker can consume it. Implements idempotent publishing using chain+tx_hash deduplication.

Changes

  • Add RedisTransactionPublisher class for publishing to chain-transactions stream
  • Implement idempotent publish using chain:tx_hash as dedup key with 7-day TTL
  • Add ChainTransactionMessage type to shared package with required fields:
    • chain, tx_hash, block_number, block_hash, amount, sender, receiver, token_contract, detected_at
  • Add fromTransferLog static helper for converting TransferLog to ChainTransactionMessage
  • Add ioredis dependency for Redis connectivity

How to Test

  1. npm ci
  2. npm run typecheck
  3. npm test --workspace=@stripeonchain/chain-watcher

Tests

  • Tests added/updated (12 new tests for TransactionPublisher)
  • All tests pass (npm test - 51 total)
  • Lint passes (npm run lint)
  • Type-check passes (npm run typecheck for chain-watcher)
  • Formatting passes (npm run format:check)

Test Coverage

  • New tx appears in stream after detection
  • Duplicate tx is not re-published (idempotency)
  • Same tx_hash on different chains treated as separate
  • Custom stream key support
  • TransferLog to message conversion

Checklist

  • No secrets or credentials committed
  • Migrations run cleanly up and down (npm run migrate:up / npm run migrate:down)
  • Docker Compose starts without errors (docker compose up)

Related Issues

Closes #15

Made with Cursor

- Add RedisTransactionPublisher for publishing to chain-transactions stream
- Implement idempotent publish using chain+tx_hash dedup key with 7-day TTL
- Add ChainTransactionMessage type with all required fields
- Add fromTransferLog helper for converting TransferLog to message
- Add ioredis dependency for Redis connectivity
- Add comprehensive unit tests (12 tests)

Closes #15

Made-with: Cursor
@geminimir geminimir merged commit e38f20e into main Mar 15, 2026
1 check passed
@geminimir geminimir deleted the feature/chain-tx-redis-publisher branch March 15, 2026 15:28
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.

Publish discovered chain transactions to Redis Streams

1 participant