π Title
Create `StellarService` β centralize Horizon client instantiation currently duplicated across modules
π Description
`src/blockchain/stellar/` exists in the architecture but contains only a `.gitkeep`. The Stellar Horizon client is instantiated independently in at least two places, with diverging retry strategies and no shared error normalization:
- `src/modules/transactions/transactions.service.ts` β creates its own `StellarSdk.Horizon.Server` instance inline
- `src/jobs/transaction-status-checker/transaction-status-checker.processor.ts` β creates a second independent instance with its own inline retry loop using different timing constants
This duplication means:
- Horizon URL and network passphrase are read from env vars in two different places
- Retry/back-off logic differs between the two β a bug fix in one doesn't fix the other
- No single place to add observability hooks, circuit breaking, or connection pooling
- Unit tests must mock `StellarSdk` globally instead of injecting a service
β
Tasks to complete
π Documentation/context for AI
(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs
Relevant files:
- `src/blockchain/stellar/` (currently empty β create here)
- `src/modules/transactions/transactions.service.ts`
- `src/jobs/transaction-status-checker/transaction-status-checker.processor.ts`
- `src/jobs/transaction-status-checker/transaction-status-checker.module.ts`
- `src/modules/transactions/transactions.module.ts`
ποΈ Additional notes
- Follow the same NestJS module pattern used by `SupabaseModule` (`src/database/supabase/`) β make it a `@Global()` module so all consumers just import it once
- Normalized error types should extend `Error` and carry the original Horizon error for logging
- The retry strategy should use exponential back-off: 500ms β 1000ms β 2000ms with jitter
- Network passphrase (`STELLAR_NETWORK_PASSPHRASE`) must be added to `src/config/env.ts` validation if not already present
π Title
Create `StellarService` β centralize Horizon client instantiation currently duplicated across modules
π Description
`src/blockchain/stellar/` exists in the architecture but contains only a `.gitkeep`. The Stellar Horizon client is instantiated independently in at least two places, with diverging retry strategies and no shared error normalization:
This duplication means:
β Tasks to complete
π Documentation/context for AI
(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs
Relevant files:
ποΈ Additional notes