Skip to content

fix(storage): fix #6 typed storage errors#26

Merged
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Dopezapha:feat/issue-6-typed-storage-errors
Jun 16, 2026
Merged

fix(storage): fix #6 typed storage errors#26
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Dopezapha:feat/issue-6-typed-storage-errors

Conversation

@Dopezapha

Copy link
Copy Markdown
Contributor

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 NotInitialized or LoanNotFound from unexpected failures. This change moves those storage reads onto typed Result<T, ContractError> paths so generated Soroban clients can expose structured failures through try_* 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 with panic_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 NotInitialized errors instead of opaque panics. The full workspace build, tests, formatting, and clippy checks were run after the changes.

Changed

  • Converted storage getters/readers across creditline, liquidity pool, parameters, reputation, and vendor registry to typed Result<T, ContractError> paths.
  • Removed all .expect(...) and bare .unwrap() matches from contracts/*/src/storage.rs.
  • Added missing typed error variants where needed, including NotInitialized and vendor count Overflow.
  • Updated contract callers to propagate or convert storage failures into typed contract errors.
  • Added TTL extension after every persistent storage write in the active contracts.
  • Added before-initialize regression tests using generated try_* clients.
  • Updated context/progress-tracker.md with the completed storage hardening work.

@Dopezapha

Copy link
Copy Markdown
Contributor Author

kindly review and merge

@EmeditWeb EmeditWeb merged commit 6151054 into StepFi-app:main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[6] Harden storage.rs expect() panics to typed errors

2 participants