Context
YieldVault tracks tokenized RWA cargo via ShipmentStatus (Pending, InTransit, Delivered, Cancelled) with admin-only add_shipment and update_shipment_status.
Problem / Gap
update_shipment_status allows arbitrary transitions (e.g., Delivered → Pending) with no lifecycle rules. Cancelled shipments can be moved back to InTransit, undermining auditability of real-world asset backing.
Proposed approach
- Define an allowed transition matrix (e.g., Delivered and Cancelled are terminal).
- Return a typed error instead of silently mutating lists on invalid transitions.
- Add tests for each valid/invalid transition and list index consistency after updates.
Files/areas affected
contracts/vault/src/lib.rs (update_shipment_status, ShipmentStatus)
contracts/vault/src/test.rs (test_update_shipment_full_lifecycle_statuses)
Context
YieldVault tracks tokenized RWA cargo via
ShipmentStatus(Pending, InTransit, Delivered, Cancelled) with admin-onlyadd_shipmentandupdate_shipment_status.Problem / Gap
update_shipment_statusallows arbitrary transitions (e.g., Delivered → Pending) with no lifecycle rules. Cancelled shipments can be moved back to InTransit, undermining auditability of real-world asset backing.Proposed approach
Files/areas affected
contracts/vault/src/lib.rs(update_shipment_status,ShipmentStatus)contracts/vault/src/test.rs(test_update_shipment_full_lifecycle_statuses)