diff --git a/neveko-core/src/order.rs b/neveko-core/src/order.rs index 38f2d4f..a16ff28 100644 --- a/neveko-core/src/order.rs +++ b/neveko-core/src/order.rs @@ -298,12 +298,13 @@ pub async fn finalize_order(orid: &String) -> reqres::FinalizeOrderResponse { } /// Send order request to vendor and start multisig flow -pub async fn transmit_order_request(contact: String, request: reqres::OrderRequest) -> Result> { +pub async fn transmit_order_request(contact: String, jwp: String, request: reqres::OrderRequest) -> Result> { let host = utils::get_i2p_http_proxy(); let proxy = reqwest::Proxy::http(&host)?; let client = reqwest::Client::builder().proxy(proxy).build(); match client? .post(format!("http://{}/market/order/create", contact)) + .header("proof", jwp) .json(&request) .send() .await @@ -312,7 +313,7 @@ pub async fn transmit_order_request(contact: String, request: reqres::OrderReque let res = response.json::().await; debug!("create order response: {:?}", res); match res { - Ok(r) => Ok(r), + Ok(_r) => Ok(Default::default()), _ => Ok(Default::default()), } } diff --git a/neveko-gui/src/apps/market.rs b/neveko-gui/src/apps/market.rs index 881959a..b1a1b66 100644 --- a/neveko-gui/src/apps/market.rs +++ b/neveko-gui/src/apps/market.rs @@ -228,12 +228,21 @@ impl eframe::App for MarketApp { quantity: qty, ..Default::default() }; + log::debug!("new order: {:?}", &new_order); self.is_loading = true; - submit_order_req(self.submit_order_tx.clone(), ctx.clone(), new_order); + submit_order_req( + self.submit_order_tx.clone(), + self.vendor_status.i2p.clone(), + ctx.clone(), + self.vendor_status.jwp.clone(), + new_order + ); self.new_order = Default::default(); self.new_order_price = 0; self.new_order_quantity = utils::empty_string(); self.new_order_shipping_address = utils::empty_string(); + self.is_ordering = false; + self.is_showing_products = false; } } ui.label("\n"); @@ -928,12 +937,19 @@ fn vendor_status_timeout(tx: Sender, ctx: egui::Context) { }); } -fn submit_order_req(tx: Sender, ctx: egui::Context, request: reqres::OrderRequest) { +fn submit_order_req(tx: Sender, contact: String, ctx: egui::Context, jwp: String, request: reqres::OrderRequest) { tokio::spawn(async move { log::info!("submit order"); - let contact = String::from(&request.cid); - let order = order::transmit_order_request(contact, request).await; - let _ = tx.send(order.unwrap_or(Default::default())); + let r_contact = String::from(&contact); + let order = order::transmit_order_request(r_contact, jwp, request).await; + let u_order = order.unwrap_or(Default::default()); + // cache order request to db + utils::write_gui_db( + String::from("gui-orid"), + String::from(&contact), + String::from(&u_order.orid), + ); + let _ = tx.send(u_order); ctx.request_repaint(); }); }