Skip to content

fix(market): transfer tokens after purchase effects - #1426

Open
DeePrincipal-dev-lang wants to merge 1 commit into
BrainTease:mainfrom
DeePrincipal-dev-lang:fix/market-token-transfer-order
Open

DeePrincipal-dev-lang wants to merge 1 commit into
BrainTease:mainfrom
DeePrincipal-dev-lang:fix/market-token-transfer-order

Conversation

@DeePrincipal-dev-lang

Copy link
Copy Markdown
Contributor

Title: Fix market purchase state ordering around token transfers

Description

Summary

Update the market purchase flow to follow checks-effects-interactions and ensure a failed token transfer does not leave a purchase recorded.

Changes

  • Validate the buyer and product, acquire the reentrancy lock, then update the product, listing, and purchase record before calling the token contract.
  • Keep the lock held during the external token call.
  • Add successful and failing token stubs for purchase tests.
  • Add a regression test verifying a failed transfer leaves the product unsold, the listing available, no purchase record created, and the lock released.

Validation

  • git diff --check passed; editor diagnostics reported no errors.
  • cargo test -p market and the Rust pre-commit checks could not run because cargo is unavailable in the environment.

closes #1315

This branch had an error being deployed

1 failed deployment
preview-pr-1426 — 3224c7c6 Deployed Oct 23, 2026 by DeePrincipal-dev-lang via Deploy Preview Environment #375
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.

[Contracts] #58 Audit market state update ordering

1 participant