cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

commit 11c706f8f2453d61cbb91d0c1078d106cef06ebe
parent 48900011c281245c96d11c2acff1253be9dc12b3
Author: triesap <tyson@radroots.org>
Date:   Tue,  5 May 2026 17:50:14 +0000

order: cover missing exact economics source

- keep market display amounts decimal-friendly
- test missing exact listing economics failure
- preserve fail-closed order quote behavior
- align cli views with replica decimal projections

Diffstat:
Msrc/domain/runtime.rs | 4++--
Msrc/operation_market.rs | 4++--
Msrc/runtime/order.rs | 37+++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/domain/runtime.rs b/src/domain/runtime.rs @@ -2428,7 +2428,7 @@ pub struct FindResultHyfView { #[derive(Debug, Clone, Serialize)] pub struct FindQuantityView { - pub total_amount: i64, + pub total_amount: f64, pub total_unit: String, #[serde(skip_serializing_if = "Option::is_none")] pub label: Option<String>, @@ -2440,7 +2440,7 @@ pub struct FindQuantityView { pub struct FindPriceView { pub amount: f64, pub currency: String, - pub per_amount: u32, + pub per_amount: f64, pub per_unit: String, } diff --git a/src/operation_market.rs b/src/operation_market.rs @@ -495,7 +495,7 @@ mod tests { fn quantity() -> FindQuantityView { FindQuantityView { - total_amount: 1, + total_amount: 1.0, total_unit: "each".to_owned(), label: None, available_amount: Some(1), @@ -506,7 +506,7 @@ mod tests { FindPriceView { amount: 6.0, currency: "USD".to_owned(), - per_amount: 1, + per_amount: 1.0, per_unit: "each".to_owned(), } } diff --git a/src/runtime/order.rs b/src/runtime/order.rs @@ -8825,6 +8825,43 @@ mod tests { } #[test] + fn order_economics_fails_when_exact_listing_source_is_missing() { + let listing = ResolvedOrderListing { + listing_addr: "30402:seller:AAAAAAAAAAAAAAAAAAAAAg".to_owned(), + listing_event_id: "1".repeat(64), + seller_pubkey: "seller".to_owned(), + economics_product: Some(ResolvedOrderEconomicsProduct { + qty_amt_exact: None, + qty_unit: "kg".to_owned(), + price_amt_exact: Some("3.25".to_owned()), + price_currency: "USD".to_owned(), + price_qty_amt_exact: Some("1".to_owned()), + price_qty_unit: "kg".to_owned(), + primary_bin_id: Some("bin-a".to_owned()), + notes: None, + }), + }; + let items = vec![OrderDraftItem { + bin_id: "bin-a".to_owned(), + bin_count: 1, + }]; + + let error = order_economics_from_resolved_listing( + "ord_AAAAAAAAAAAAAAAAAAAAAg", + Some(&listing), + items.as_slice(), + &[], + ) + .expect_err("missing exact source should fail"); + + assert!(matches!( + error, + crate::runtime::RuntimeError::Config(message) + if message.contains("listing qty_amt_exact exact source is missing") + )); + } + + #[test] fn order_draft_requires_listing_event_id_for_submit_readiness() { let document = OrderDraftDocument { version: 1,