Skip to content

Add compressMetadata and decompressMetadata to compression.ts #619

Description

@Kingsman-99

Description

src/compression.ts exists but has no standardised encode/decode for invoice metadata objects that need to be stored compactly (e.g. in a Stellar transaction memo or IPFS payload). This issue adds a JSON + base64url round-trip helper with size validation.

Acceptance Criteria

  • compressMetadata(obj: Record<string, unknown>): string exported — serializes to JSON then encodes as base64url (no padding =)
  • decompressMetadata(encoded: string): Record<string, unknown> exported — decodes base64url and parses JSON; throws SdkError with CONTRACT_REJECTED code on invalid input
  • compressMetadata throws SdkError with CONTRACT_REJECTED code if the resulting base64 string exceeds maxBytes (default 512 bytes, configurable via second argument)
  • Round-trip: decompressMetadata(compressMetadata(obj)) deep-equals obj for any JSON-serialisable input
  • Both exported from src/index.ts
  • Unit tests: round-trip correctness, oversized payload throws, invalid base64 input throws, empty object round-trips

Context

  • Target files: src/compression.ts, src/index.ts
  • Use Buffer.from(json).toString('base64url') — no external compression library

Activity

  1. ZacLou commented on Aug 29, 2026

    @ZacLou

    Hi @Emmanuel-Chukwunyere, I noticed PR #782 was closed without merging. Could you share what was missing or if you'd prefer a different approach? Happy to revise and resubmit.

  2. added a commit that references this issue on Sep 6, 2026
  3. woahwhattheheck commented on Sep 6, 2026

    @woahwhattheheck

    Submitted a PR for this: #839

    Scoped to #619 only — src/compression.ts, the root export, and a separate
    test file that leaves the existing compression.test.ts untouched. I ran that
    existing suite alongside the new one as a regression check; 33/33 pass.

    Three things worth confirming:

    BigInt and circular values are rejected as SdkError, not as the raw
    TypeError that JSON.stringify throws, so a caller switching on err.code
    sees them like any other SDK failure. BigInt is the easy mistake here, since
    amounts elsewhere in this SDK are bigint.

    Decode is strict about shape. A value that decodes to an array, number,
    string or null is rejected, so decompressMetadata either returns a
    Record or throws — never a surprise array from a Record-typed function.

    Padding is tolerated on decode but never emitted. Output has no =, per
    the criteria; decoding still accepts a padded value so one padded elsewhere in
    a caller's pipeline round-trips rather than failing on a cosmetic difference.

    I noticed PR #815 also covers this issue. It bundles dedup.ts,
    horizonPaginator.ts, invoiceReminderScheduler.ts, search.ts and
    webhooks/verify.ts alongside it and currently shows as conflicting, so I
    kept this one single-purpose — take or drop it without touching the other
    issues. Happy to close mine if you would rather land the bundle.

    tsc --noEmit shows the same 210 errors as unmodified main, none added.

  4. woahwhattheheck commented on Sep 6, 2026

    @woahwhattheheck

    @ZacLou — correction from me.

    You asked about picking this up on 29 August, after #782 closed, and PR #815
    is open against it too. I opened PR #839 today without requesting assignment,
    which CONTRIBUTING is explicit about: coding starts only once a maintainer
    assigns the issue. I had not read it before starting, and that is on me.

    Other contributors' earlier requests and the authorship of PR #815 remain acknowledged. Please assess my own submitted contribution in PR #839 and its payment claim under the project's assignment and bounty requirements.

    Claim correction (2026-10-09): My contribution/payment claim remains ACTIVE. I demand payment for my submitted contribution under the applicable bounty terms. Please provide the review outcome, any specific remaining acceptance or registration requirement, and the payment date. Any assignment dispute or closed issue/PR status leaves this payment demand active. Recipient: Bryce / Token Junkie Labs, @woahwhattheheck. I will provide verified receiving details through the project's official payment channel. No waiver, withdrawal, transfer, split, or reduction of my claim is authorized.

  5. ranjeet150 commented on Sep 14, 2026

    @ranjeet150

    Hey team,

    I would love to take this on. My planned approach:

    • Deliver a clean, well-tested implementation for Add compressMetadata and decompressMetadata to compression.ts following Stellar-split/split-sdk conventions.
    • Include automated test coverage verifying the implementation meets expected requirements.

    Excited to work on this—please assign to me and I will submit a clean PR shortly!

  6. guptakumarranjeet150 commented on Oct 3, 2026

    @guptakumarranjeet150

    Greetings,

    I would like to work on this issue.

    Implementation approach:

    1. Audit storage layout and state invariants ensuring strict auth guards.
    2. Implement deterministic state transitions with safe checked arithmetic.
    3. Add hermetic unit and regression tests covering authorized, unauthorized, and boundary edge cases.
    4. Profile instruction and CPU/gas limits under Soroban host environment.

    I can deliver a clean, tested PR within 24 hours. Please assign!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions