Skip to content

Refactor string assertions to use custom contract errors #14

Description

@Code-Paragon

Problem

The contract currently uses assert! with string literals (e.g., "Deposit amount must be strictly positive"), which inflates the compiled WASM size and makes programmatic error handling difficult for the SDK.

Expected behavior

A #[contracterror] enum is created to define structured error codes, and standard assert! calls are replaced with Soroban's native error handling patterns.

Files to update

  • src/lib.rs
  • src/vault.rs
  • src/strategy.rs

Project relevance

This significantly optimizes the final WASM footprint and allows the yieldstream-sdk to catch and parse deterministic error codes for better frontend UI feedback.

Acceptance criteria

  • Feature works as described
  • Tests are added or updated where needed
  • Documentation is updated where needed
  • A custom error enum like VaultError is defined with #[contracterror]
  • No TypeScript, lint, test, or build errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions