Fix broken code in the choosing-the-right-storage guide - #2835
Open
kaankacar wants to merge 1 commit into
Open
Conversation
The temporary storage snippet could not compile. It called `e.ledger()` twice while its `Env` parameter is named `env`, declared no `AuctionContract` type for the `impl` block, took a `Symbol` where `DataKey::Bid` holds an `Address`, returned `i64` for an `i128` bid value, and annotated `storage().temporary().get()` as `Bid` when it returns `Option<Bid>`. The same snippet also had its expiry check inverted. It returned the bid value when `expiration_ledger_seq` had already passed, and 0 while the bid was still valid, which is the opposite of what its own comments describe. The persistent and instance snippets were missing the `contract` and `contracttype` imports that they use.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes compilation errors and inverted expiry logic in the storage guide’s Soroban Rust examples.
Changes:
- Adds missing SDK imports and contract declaration.
- Corrects temporary bid types, environment access, and expiry handling.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Automated message from Kaan's Automated Triage Bot.
The temporary storage snippet on this guide could not compile, and its expiry check was inverted: it returned a bid's value after the bid expired, and 0 while the bid was still valid. This fixes that check and the compile errors around it, and adds the two missing SDK imports in the persistent and instance snippets. Prose, links and the storage table are unchanged.
Refs #1841
I checked every construct against soroban-sdk v26.1.1 source, because
cargois not available in my environment.storage().temporary().get()returnsOption<V>(soroban-sdk/src/storage.rs:458) andLedger::sequence()returnsu32(ledger.rs:65). Two#[contractimpl]blocks on one contract are legal, so the second block stays as it is (lib.rs:447).I used "Refs", not "Closes". The issue asks for a full guide review, and two prose claims stay unverified: that the instance entry size limit can never go down, and the relative order of the "Cost" column. Please close #1841 if you read this as the review being done.