Skip to content

fix(api,export): resolve stream statuses, accept full-width IDs, inde… - #1720

Merged
blurbeast merged 1 commit into
LabsCrypt:mainfrom
Rampop01:fix/issues-1698-1699-1700-1701
Oct 22, 2026
Merged

blurbeast merged 1 commit into
LabsCrypt:mainfrom
Rampop01:fix/issues-1698-1699-1700-1701

Conversation

@Rampop01

Copy link
Copy Markdown
Contributor

Description

This pull request addresses four assigned backend issues in GraphQL stream filtering, full-width identifier parsing, accounting export fee accuracy, and streaming error lifecycle termination:

  1. Resolves GraphQL stream statuses distinctly without collapsing inactive states.
  2. Accepts full-width Soroban u64 stream identifiers in the GraphQL schema and resolvers.
  3. Derives reported accounting export fees and net payouts directly from indexed protocol fee events and transaction metadata, eliminating hardcoded withdrawal fees.
  4. Terminates and destroys accounting export HTTP response sockets when streaming errors occur mid-export.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #1698
Closes #1699
Closes #1700
Closes #1701

Changes Made

  • backend/src/graphql/resolvers/stream.resolver.ts:
    • Mapped filter.status distinctly across 'active', 'paused', 'cancelled', and 'completed' states rather than evaluating status against a single boolean isActive.
    • Added explicit validation rejecting unknown status strings with descriptive error messages.
    • Added $0 \le \text{streamId} \le 2^{64}-1$ range validation in resolveStream to safely handle Soroban u64 stream identifiers.
  • backend/src/graphql/schema.ts:
    • Updated streamId argument types in Query.stream and Subscription.streamUpdated from 32-bit intArg() to lossless stringArg().
  • backend/src/services/export.service.ts:
    • Removed fabricated 0.5% withdrawal fee logic in calculateProtocolFee.
    • Implemented getProtocolFeeForEvent to derive actual protocol fees from indexed FEE_COLLECTED events and transaction metadata.
    • Added socket termination logic (res.destroy(error) with res.end() fallback) in both streamTransactionCSV and streamTransactionJSON catch blocks when errors occur after headers are sent.
    • Exported helper methods for unit testing.
  • backend/tests/graphql.test.ts:
    • Added test suites asserting status mapping for all supported stream states, rejection of unknown statuses, and lossless querying with stream IDs $> 2^{31}-1$.
  • backend/tests/export.service.test.ts:
    • Created unit tests asserting zero fees on withdrawals, nonzero fee derivation from indexed events and metadata, and deterministic socket destruction on mid-stream errors.

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

  1. Run backend unit tests:
    npm test -- tests/graphql.test.ts tests/export.service.test.ts

@blurbeast
blurbeast merged commit e49b1f0 into LabsCrypt:main Oct 22, 2026
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants