Problem
contracts/order/src/lib.rs - place_order() accepts caller-provided unit_price values per item with no on-chain validation. This has three attack vectors:
- A caller can submit any price (e.g., 1 stroop for a 50,000-stroop meal)
- A caller can submit a
menu_item_id from a different restaurant, polluting order history
- If prices change between order creation and dispute resolution, there is no historical record of what was charged
Proposed Solution
- Add a
MenuItemSnapshot { menu_item_id: u64, name: Symbol, price_at_order: i128 } struct
- In
place_order(), make a cross-contract call to validate menu_item_id belongs to restaurant_id and retrieve the authoritative price
- Ignore the caller-supplied
unit_price; use only the on-chain price for total calculation
- Store the
MenuItemSnapshot on each OrderItem in persistent storage
Acceptance Criteria
Problem
contracts/order/src/lib.rs-place_order()accepts caller-providedunit_pricevalues per item with no on-chain validation. This has three attack vectors:menu_item_idfrom a different restaurant, polluting order historyProposed Solution
MenuItemSnapshot { menu_item_id: u64, name: Symbol, price_at_order: i128 }structplace_order(), make a cross-contract call to validatemenu_item_idbelongs torestaurant_idand retrieve the authoritative priceunit_price; use only the on-chain price for total calculationMenuItemSnapshoton eachOrderItemin persistent storageAcceptance Criteria
place_order()with amenu_item_idnot belonging torestaurant_idpanics with"item not on menu"OrderItemin storage containsprice_at_orderfrom the snapshotunit_price = 1for a 50,000-stroop item pays 50,000 stroops