fix(storage): fix #6 typed storage errors#26
Merged
EmeditWeb merged 1 commit intoJun 16, 2026
Conversation
Contributor
Author
|
kindly review and merge |
11 tasks
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.
Closes #6
PR Description
Fixed #6 by replacing opaque storage-layer panic paths with typed contract errors across the active StepFi contracts. Previously, missing required storage values could surface as string panics or VM traps, which made it difficult for API clients to distinguish expected contract states like
NotInitializedorLoanNotFoundfrom unexpected failures. This change moves those storage reads onto typedResult<T, ContractError>paths so generated Soroban clients can expose structured failures throughtry_*calls.The storage flow now keeps intentional protocol defaults, such as zero pool balances, zero active debt, false updater status, or missing optional dependency addresses, while still returning them through typed storage helper results. Public functions either propagate typed errors where their API already returns
Result, or convert internal invariant failures into existing typed contract errors withpanic_with_error!. This preserves existing public behavior while making missing storage state machine-readable for API handling.This PR also completes the related storage hygiene required by #6. Persistent writes now immediately extend TTL for loan/user indexes, user active debt, vendor records, vendor counts, and LP share records. Regression tests verify before-initialize getters return typed
NotInitializederrors instead of opaque panics. The full workspace build, tests, formatting, and clippy checks were run after the changes.Changed
Result<T, ContractError>paths..expect(...)and bare.unwrap()matches fromcontracts/*/src/storage.rs.NotInitializedand vendor countOverflow.try_*clients.context/progress-tracker.mdwith the completed storage hardening work.