Skip to content

ContractModule: Fix deposit_partial duplicate detection and escrow ID mapping #13

Description

@grantfox-oss

deposit() derives an idempotent escrow ID and checks both modern and legacy commitments. deposit_partial() creates a commitment directly and writes it without checking existing escrow state or escrow ID mappings, risking accidental overwrites and inconsistent idempotency.

Affected areas: app/contract/contracts/src/escrow.rs, app/contract/contracts/src/escrow_id.rs, app/contract/contracts/src/storage.rs, app/contract/contracts/src/errors.rs, app/contract/contracts/src/test.rs, snapshots/docs.

Implementation scope:

  • Derive escrow IDs for partial deposits using token, amount due, initial payment, owner, salt, timeout, and arbiter.
  • Reject duplicate commitments and duplicate legacy commitments consistently.
  • Store and expose escrow ID to commitment mapping for partial escrows.
  • Add regression tests for identical retry, same salt different initial payment, and existing commitment collision.

Acceptance criteria:

  • deposit_partial cannot overwrite an existing escrow.
  • Identical retry returns or reports the existing escrow deterministically.
  • Backend/indexer can correlate partial escrow events with stable IDs.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions