Skip to content

[CT-15] Build cross-contract shipment and escrow validation #923

@mftee

Description

@mftee

Problem

The shipment and escrow contracts are entirely independent. A carrier could call release_funds on the escrow contract while the corresponding on-chain shipment record still shows InTransit, bypassing the delivery confirmation requirement and receiving payment before the goods are received.

Proposed Solution

Create a validator contract inside contracts/package/cross-contract-validator/ that performs atomic cross-contract checks before allowing escrow release.

Note: All work must be done inside the contracts/package/ directory. Do not modify any existing contract files outside this folder.

Acceptance Criteria

  • validate_and_release(shipment_id: BytesN<32>, escrow_id: BytesN<32>) function
  • Calls the shipment contract to verify shipment status is DELIVERED; returns ShipmentNotDelivered otherwise
  • Calls the escrow contract to verify escrow is in FUNDED state; returns EscrowNotFunded otherwise
  • Only proceeds with release if both checks pass
  • Uses Soroban cross-contract invocation (soroban_sdk invoke_contract)
  • Returns a structured result indicating which check failed if the release is blocked
  • Unit tests mock both the shipment and escrow contracts using the Soroban test environment

Metadata

Metadata

Assignees

Labels

Type

No type
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