Skip to content

[CT-16] Add on-chain event emission for all shipment state transitions #924

@mftee

Description

@mftee

Problem

The shipment contract changes state without emitting any Soroban events. External indexers, analytics systems, and the FreightFlow backend have no way to react to on-chain state changes without polling every contract state, which is impractical and expensive.

Proposed Solution

Create a new shipment contract inside contracts/package/shipment-events/ that emits a structured Soroban event on every state transition.

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

Acceptance Criteria

  • Events emitted for all transitions: ShipmentCreated, ShipmentAccepted, InTransit, Delivered, Completed, Disputed, Cancelled
  • Each event payload includes: shipment_id, new_status, actor_address, ledger_timestamp
  • Events use env.events().publish() as per the Soroban SDK specification
  • Event topic is a (Symbol, BytesN<32>) tuple of (event_name, shipment_id) for efficient indexer filtering
  • Unit tests use the Soroban test harness to assert that the correct event is emitted with the correct payload for each transition

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