Skip to content

fix: implement validation and fund transfer for release_partial - #276

Merged
Cybermaxi7 merged 1 commit into
MarketXpress:mainfrom
lishmanTech:newcom
Aug 22, 2026
Merged

fix: implement validation and fund transfer for release_partial#276
Cybermaxi7 merged 1 commit into
MarketXpress:mainfrom
lishmanTech:newcom

Conversation

@lishmanTech

Copy link
Copy Markdown
Contributor

Summary

This PR fixes release_partial, which was previously a public no-op that returned Ok(()) without releasing funds, validating the escrow, checking authorization, updating state, or emitting a release event.

The implementation now makes release_partial behave consistently with the existing release flows.

What changed

  • Implemented buyer authorization for release_partial

  • Added escrow existence validation

  • Added amount validation for:

    • amount <= 0
    • amount > remaining escrow balance
  • Reused the existing fee calculation helper

  • Transferred the requested partial amount

  • Persisted the reduced escrow balance

  • Transitions the escrow to Released when the remaining balance reaches zero

  • Emits FundsReleasedEvent

  • Updates total released amount and release count

  • Preserved the existing partial_releases_enabled feature-flag check

  • Added documentation for release_partial, including its arguments and errors

  • Defined and tested interaction between release_partial and release_item to prevent over-release

  • Corrected the stale README claim regarding refund_escrow

  • Audited the remaining public entry points for unused parameters/silent no-op implementations

Tests

Added coverage for the enabled release_partial path, including:

  • Non-existent escrow → EscrowNotFound
  • Zero/negative amount → InvalidEscrowAmount
  • Amount greater than remaining balance → InvalidEscrowAmount
  • Non-buyer caller → Unauthorized
  • Correct fee handling
  • Correct balance/state updates
  • Release event and counters
  • Interaction with release_item
  • Existing disabled feature-flag behavior remains unchanged

Issue

Closes #271

CI

All required CI checks must pass:

  • Formatting
  • Clippy
  • Build Optimized WASM
  • Tests
  • Dependency Audit
  • Coverage
  • SDK Error Code Parity

@Cybermaxi7
Cybermaxi7 merged commit 661fc42 into MarketXpress:main Aug 22, 2026
7 checks 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.

[critical] release_partial is a public no-op that reports success while releasing nothing

2 participants