Skip to content

Commit

Permalink
Merge pull request #796 from rainlanguage/2024-08-27-rainlang-compose…
Browse files Browse the repository at this point in the history
…-bug

Bug fix for generating Rainlang strings
  • Loading branch information
hardyjosh authored Aug 27, 2024
2 parents bfed539 + d72e51b commit a06f93c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/settings/src/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
2 changes: 1 addition & 1 deletion crates/settings/src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/settings/src/orderbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion crates/settings/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
12 changes: 8 additions & 4 deletions tauri-app/src-tauri/src/commands/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +168,11 @@ pub async fn order_remove_calldata(
}

#[tauri::command]
pub async fn compose_from_scenario(dotrain: String, scenario: Scenario) -> CommandResult<String> {
let order = DotrainOrder::new(dotrain.clone(), None).await?;
pub async fn compose_from_scenario(
dotrain: String,
settings: Option<String>,
scenario: Scenario,
) -> CommandResult<String> {
let order = DotrainOrder::new(dotrain.clone(), settings).await?;
Ok(order.compose_scenario_to_rainlang(scenario.name).await?)
}
2 changes: 2 additions & 0 deletions tauri-app/src/lib/services/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ export async function orderRemoveCalldata(id: string) {

export async function orderAddComposeRainlang(
dotrain: string,
settings: string,
scenario: Scenario,
): Promise<string> {
return await invoke('compose_from_scenario', {
dotrain,
settings,
scenario,
});
}
6 changes: 5 additions & 1 deletion tauri-app/src/routes/orders/add/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a06f93c

Please sign in to comment.