Skip to content

Add helper for safely serializing BigInt values in JSON API responses #485

Description

@Chucks1093

Summary

XLM amounts and ledger sequences are stored as BigInt in JavaScript but JSON.stringify throws on BigInt values by default. A shared serialization helper should convert BigInt fields to strings before they reach the response layer so the app never throws a silent serialization error.

Scope

  • Add a serializeBigInt(value: unknown): unknown helper that recursively converts BigInt values to strings in objects and arrays
  • Use the helper in the response serializer for all endpoints that return price or amount fields
  • Add unit tests for: top-level BigInt, nested BigInt in object, BigInt in array, non-BigInt value unchanged

Acceptance Criteria

  • Top-level BigInt converts to string
  • Nested BigInt in an object converts correctly
  • BigInt inside an array converts correctly
  • Non-BigInt values pass through unchanged

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions