From d9e470403e341443f8f406dc630765e3d9f4df70 Mon Sep 17 00:00:00 2001 From: highonhopium Date: Tue, 27 Aug 2024 12:25:44 +0100 Subject: [PATCH] bug fix and better errors --- crates/settings/src/deployer.rs | 2 +- crates/settings/src/order.rs | 2 +- crates/settings/src/orderbook.rs | 2 +- crates/settings/src/token.rs | 2 +- tauri-app/src-tauri/src/commands/order.rs | 12 ++++++++---- tauri-app/src/lib/services/order.ts | 2 ++ tauri-app/src/routes/orders/add/+page.svelte | 6 +++++- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/settings/src/deployer.rs b/crates/settings/src/deployer.rs index f9eec6f7a..2473e566a 100644 --- a/crates/settings/src/deployer.rs +++ b/crates/settings/src/deployer.rs @@ -19,7 +19,7 @@ pub struct Deployer { pub enum ParseDeployerConfigSourceError { #[error("Failed to parse address")] AddressParseError(alloy::primitives::hex::FromHexError), - #[error("Network not found: {0}")] + #[error("Network not found for Deployer: {0}")] NetworkNotFoundError(String), } diff --git a/crates/settings/src/order.rs b/crates/settings/src/order.rs index 16f22b397..67678e779 100644 --- a/crates/settings/src/order.rs +++ b/crates/settings/src/order.rs @@ -39,7 +39,7 @@ pub enum ParseOrderConfigSourceError { OrderbookParseError(ParseOrderbookConfigSourceError), #[error("Failed to parse token")] TokenParseError(ParseTokenConfigSourceError), - #[error("Network not found: {0}")] + #[error("Network not found for Order: {0}")] NetworkNotFoundError(String), #[error("Network does not match")] NetworkNotMatch, diff --git a/crates/settings/src/orderbook.rs b/crates/settings/src/orderbook.rs index c7d9a7d7b..7ef40033d 100644 --- a/crates/settings/src/orderbook.rs +++ b/crates/settings/src/orderbook.rs @@ -24,7 +24,7 @@ pub struct Orderbook { pub enum ParseOrderbookConfigSourceError { #[error("Failed to parse address")] AddressParseError(FromHexError), - #[error("Network not found: {0}")] + #[error("Network not found for Orderbook: {0}")] NetworkNotFoundError(String), #[error("Subgraph not found: {0}")] SubgraphNotFoundError(String), diff --git a/crates/settings/src/token.rs b/crates/settings/src/token.rs index 0dab93cb1..a04c0c9b3 100644 --- a/crates/settings/src/token.rs +++ b/crates/settings/src/token.rs @@ -24,7 +24,7 @@ pub enum ParseTokenConfigSourceError { AddressParseError(FromHexError), #[error("Failed to parse decimals")] DecimalsParseError(std::num::ParseIntError), - #[error("Network not found: {0}")] + #[error("Network not found for Token: {0}")] NetworkNotFoundError(String), } diff --git a/tauri-app/src-tauri/src/commands/order.rs b/tauri-app/src-tauri/src/commands/order.rs index 33273c435..41cc1c926 100644 --- a/tauri-app/src-tauri/src/commands/order.rs +++ b/tauri-app/src-tauri/src/commands/order.rs @@ -3,9 +3,9 @@ use crate::{toast::toast_error, transaction_status::TransactionStatusNoticeRwLoc use alloy::primitives::Bytes; use rain_orderbook_app_settings::{deployment::Deployment, scenario::Scenario}; use rain_orderbook_common::{ - add_order::AddOrderArgs, csv::TryIntoCsv, + add_order::AddOrderArgs, csv::TryIntoCsv, dotrain_order::DotrainOrder, remove_order::RemoveOrderArgs, subgraph::SubgraphArgs, transaction::TransactionArgs, - types::OrderDetailExtended, types::OrderFlattened, types::FlattenError, dotrain_order::DotrainOrder + types::FlattenError, types::OrderDetailExtended, types::OrderFlattened, }; use rain_orderbook_subgraph_client::{types::orders_list, PaginationArgs}; use std::fs; @@ -168,7 +168,11 @@ pub async fn order_remove_calldata( } #[tauri::command] -pub async fn compose_from_scenario(dotrain: String, scenario: Scenario) -> CommandResult { - let order = DotrainOrder::new(dotrain.clone(), None).await?; +pub async fn compose_from_scenario( + dotrain: String, + settings: Option, + scenario: Scenario, +) -> CommandResult { + let order = DotrainOrder::new(dotrain.clone(), settings).await?; Ok(order.compose_scenario_to_rainlang(scenario.name).await?) } diff --git a/tauri-app/src/lib/services/order.ts b/tauri-app/src/lib/services/order.ts index 1e31e8e3b..fce53fcc6 100644 --- a/tauri-app/src/lib/services/order.ts +++ b/tauri-app/src/lib/services/order.ts @@ -56,10 +56,12 @@ export async function orderRemoveCalldata(id: string) { export async function orderAddComposeRainlang( dotrain: string, + settings: string, scenario: Scenario, ): Promise { return await invoke('compose_from_scenario', { dotrain, + settings, scenario, }); } diff --git a/tauri-app/src/routes/orders/add/+page.svelte b/tauri-app/src/routes/orders/add/+page.svelte index 1634b9571..d1e41ff8b 100644 --- a/tauri-app/src/routes/orders/add/+page.svelte +++ b/tauri-app/src/routes/orders/add/+page.svelte @@ -179,7 +179,11 @@ composedRainlangForScenarios = new Map(); for (const scenario of Object.values(scenarios)) { try { - const composedRainlang = await orderAddComposeRainlang(dotrainText, scenario); + const composedRainlang = await orderAddComposeRainlang( + dotrainText, + $settingsText, + scenario, + ); composedRainlangForScenarios.set(scenario, composedRainlang); } catch (e) { composedRainlangForScenarios.set(