Skip to content

Transaction Operation Effect Aggregator #524

Description

@Kingsman-99

Description

After a transaction is submitted, its effects (balance changes, offer fills, trust line creations) are scattered across multiple Horizon /effects pages. The SDK surfaces raw operation records but does not aggregate the net effect across all operations in a transaction, making it difficult for callers to show a simple "what changed" summary. An effect aggregator should consolidate all effects into a per-account balance delta summary.

Technical Context

Add src/effectAggregator.ts. Uses @stellar/stellar-sdk Server.operations() with includeFailed: false and .effects() sub-resource to fetch effects per operation. Produces AccountEffectSummary[] in src/types.ts. Integrates with src/receipt.ts to attach the effect summary to PaymentReceipt. Uses src/horizonPaginator.ts to walk all effect pages.

Acceptance Criteria

  • aggregateEffects(txHash: string): Promise<AccountEffectSummary[]> returns one summary per affected account with { accountId, assetDeltas: { asset, delta }[] }
  • Correctly handles multi-operation transactions by summing deltas across all operations for the same account and asset
  • Filters out intermediate DEX effects (intermediate offer fills) and reports only the net asset change per account
  • Attaches effectSummary to PaymentReceipt in src/receipt.ts when includeEffects: true is set in config
  • Unit tests use mock effect page sequences and assert correct aggregation for a two-recipient payment with path conversion
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions