Skip to content

Add compressMetadata and decompressMetadata to compression.ts #619

Closed

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!

  7. Malcolm-Wander commented on Oct 21, 2026

    @Malcolm-Wander

    @Malcolm-Wander has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello maintainer,I’d love to work on this issue please…promise to do an accurate and swift job,thank you.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Malcolm-Wander to this issue.

  8. OmniZlatoon commented on Oct 21, 2026

    @OmniZlatoon

    @OmniZlatoon has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I love this issue. Please assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @OmniZlatoon to this issue.

  9. Cynthiaoma commented on Oct 21, 2026

    @Cynthiaoma

    @Cynthiaoma has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hey Maintainer,I would like to work on this issue. I've understood the bug/feature and can fix it. Please assign me.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Cynthiaoma to this issue.

  10. ChoiceDigitalTech5 commented on Oct 21, 2026

    @ChoiceDigitalTech5

    @ChoiceDigitalTech5 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Please let me take on this issue please
    Am begging

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @ChoiceDigitalTech5 to this issue.

  11. GreatShinro commented on Oct 21, 2026

    @GreatShinro

    @GreatShinro has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi, can I work this please?

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @GreatShinro to this issue.

  12. Phantomcall commented on Oct 21, 2026

    @Phantomcall

    @Phantomcall has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    i would love to work on this

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Phantomcall to this issue.

  13. drips-wave commented on Oct 21, 2026

    @drips-wave

    Congratulations, @Phantomcall! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @Phantomcall: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  14. drips-wave commented on Oct 21, 2026

    @drips-wave

    This issue has been completed by @Phantomcall as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @Phantomcall: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignStellar WaveIssues in the Stellar wave programcomplexity: highfeatureNew SDK featuregrantfoxIssue for GrantFox program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions