Skip to content

Extract the repeated TTL-extension boilerplate in the contract into storage helpers #236

Description

@Otaiki1

Context

This five-line incantation appears in create_circle, fund, claim, and cancel_circle in
contracts/sharibo/src/lib.rs:

env.storage().persistent().set(&key, &circle);
env.storage().persistent().extend_ttl(&key, LEDGER_THRESHOLD, LEDGER_EXTEND_TO);
env.storage().instance().extend_ttl(LEDGER_THRESHOLD, LEDGER_EXTEND_TO);

Four copies means four chances to forget one — and cancel_circle already does forget the instance
extension, which is arguably a bug in its own right.

Where to build it

  • contracts/sharibo/src/storage.rs (new, or wherever the module split lands) — load_circle, save_circle, bump_instance.
  • contracts/sharibo/src/lib.rs — replace the four copies.

What to do

  • Add fn load_circle(env: &Env, id: u64) -> Circle that panics with CircleNotFound, replacing four identical unwrap_or_else blocks.
  • Add fn save_circle(env: &Env, id: u64, circle: &Circle) that sets and extends the persistent TTL.
  • Add fn bump_instance(env: &Env).
  • Decide deliberately whether cancel_circle should also bump instance TTL, and note the answer in a comment.

Acceptance criteria

  • LEDGER_THRESHOLD and LEDGER_EXTEND_TO are referenced in exactly one module.
  • cargo test passes, including instance_ttl_extended_after_create_fund_claim.

Activity

  1. gorrettivibes-coder commented on Aug 29, 2026

    @gorrettivibes-coder
    Contributor

    @gorrettivibes-coder has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hello maintainer please kindly assign this to me so I can see issues to solve this wave at all and I will deliver

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

  2. Adeyemiadigun commented on Aug 29, 2026

    @Adeyemiadigun
    Contributor

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

    Hi Maintainer, reviewed the issue in detail. Full stack background with solid experience refactoring Soroban smart contracts, optimizing state management, and cleaning up storage TTL patterns.

    Repeating the storage set and TTL extension boilerplate across multiple functions creates unnecessary maintenance overhead and risks oversights like the missing instance extension currently present in cancel_circle. I plan to extract these patterns into clean helper functions (load_circle, save_circle, and bump_instance) within a new contracts/sharibo/src/storage.rs module, centralize the TTL constants, update lib.rs, and ensure all tests pass successfully.

    No blockers on my end — I'm ready to submit a PR shortly. Please assign!

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

  3. dotmantissa commented on Aug 30, 2026

    @dotmantissa
    Contributor

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

    Please, assign this issue to me.

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

  4. Dantama022 commented on Aug 30, 2026

    @Dantama022
    Contributor

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

    i would love to work on this

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

  5. drips-wave commented on Aug 30, 2026

    @drips-wave

    Congratulations, @Dantama022! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @Dantama022: 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 🌊

  6. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractsSoroban smart contract (contracts/)good first issueGood for newcomersrefactorCode structure improvements

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions