Problem
contracts/order/src/lib.rs:125-135 - place_order() accepts any restaurant_id: u64 without cross-contract validation:
pub fn place_order(env: Env, customer: Address, restaurant_id: u64, items: Vec<OrderItem>, ...) -> u64 {
customer.require_auth();
// No call to RestaurantRegistry to verify restaurant_id exists or is active
}
Orders can be placed against ghost restaurant IDs. The payment escrow will fund a wallet address that may not exist, permanently locking customer funds.
Proposed Solution
- Add
restaurant_registry_address: Address to the Order contract's initialize() and store in persistent storage
- In
place_order(), make a cross-contract call:
let registry_client = RestaurantRegistryClient::new(&env, ®istry_addr);
let restaurant = registry_client.get_restaurant(&restaurant_id);
if !restaurant.is_active { panic!("restaurant is not active"); }
Acceptance Criteria
Problem
contracts/order/src/lib.rs:125-135-place_order()accepts anyrestaurant_id: u64without cross-contract validation:Orders can be placed against ghost restaurant IDs. The payment escrow will fund a wallet address that may not exist, permanently locking customer funds.
Proposed Solution
restaurant_registry_address: Addressto the Order contract'sinitialize()and store in persistent storageplace_order(), make a cross-contract call:Acceptance Criteria
place_order()with a non-existentrestaurant_idpanics with"restaurant not found"place_order()for an inactive restaurant panics with"restaurant is not active"MockRestaurantRegistryin unit testsinitialize()stores the registry address and all existing tests are updated