Skip to content

Commit

Permalink
Merge branch 'main' into 2025-02-14-vault-id-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyjosh authored Feb 15, 2025
2 parents 80e3122 + e776932 commit f65fbff
Show file tree
Hide file tree
Showing 65 changed files with 1,483 additions and 626 deletions.
11 changes: 11 additions & 0 deletions crates/js_api/src/gui/select_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ impl DotrainOrderGui {
Ok(())
}

#[wasm_bindgen(js_name = "getNetworkKey")]
pub fn get_network_key(&self) -> Result<String, GuiError> {
let order_key = Deployment::parse_order_key(
self.dotrain_order.dotrain_yaml().documents,
&self.selected_deployment,
)?;
let network_key =
Order::parse_network_key(self.dotrain_order.dotrain_yaml().documents, &order_key)?;
Ok(network_key)
}

#[wasm_bindgen(js_name = "saveSelectToken")]
pub async fn save_select_token(
&mut self,
Expand Down
1 change: 1 addition & 0 deletions crates/js_api/src/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use thiserror::Error;
use wasm_bindgen::{JsError, JsValue};

pub mod order;
pub mod transaction;
pub mod vault;

#[derive(Error, Debug)]
Expand Down
16 changes: 16 additions & 0 deletions crates/js_api/src/subgraph/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use cynic::Id;
use rain_orderbook_bindings::wasm_traits::prelude::*;
use rain_orderbook_subgraph_client::{OrderbookSubgraphClient, OrderbookSubgraphClientError};
use reqwest::Url;

/// Internal function to fetch a single transaction
/// Returns the Transaction struct
#[wasm_bindgen(js_name = "getTransaction")]
pub async fn get_transaction(
url: &str,
tx_hash: &str,
) -> Result<JsValue, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let transaction = client.transaction_detail(Id::new(tx_hash)).await?;
Ok(to_value(&transaction)?)
}
28 changes: 23 additions & 5 deletions crates/settings/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ impl_all_wasm_traits!(Gui);
pub struct NameAndDescription {
pub name: String,
pub description: String,
pub short_description: Option<String>,
}

#[cfg(target_family = "wasm")]
impl_all_wasm_traits!(NameAndDescription);

Expand Down Expand Up @@ -376,7 +378,17 @@ impl Gui {
Some("gui".to_string()),
)?;

return Ok(NameAndDescription { name, description });
let short_description = require_string(
get_hash_value(gui, "short-description", Some("gui".to_string()))?,
None,
Some("gui".to_string()),
)?;

return Ok(NameAndDescription {
name,
description,
short_description: Some(short_description),
});
}
}
Err(YamlError::Field {
Expand Down Expand Up @@ -422,8 +434,14 @@ impl Gui {
Some(location.clone()),
)?;

deployment_details
.insert(deployment_key, NameAndDescription { name, description });
deployment_details.insert(
deployment_key,
NameAndDescription {
name,
description,
short_description: None,
},
);
}
}
}
Expand Down Expand Up @@ -1474,8 +1492,8 @@ gui:
- binding: test
name: test
presets:
- value:
- test
- value:
wrong: map
"#;
let error = Gui::parse_from_yaml_optional(
vec![get_document(&format!("{yaml_prefix}{yaml}"))],
Expand Down
1 change: 1 addition & 0 deletions crates/settings/src/yaml/dotrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ mod tests {
gui:
name: Test gui
description: Test description
short-description: Test short description
deployments:
deployment1:
name: Test deployment
Expand Down
16 changes: 16 additions & 0 deletions crates/subgraph/src/orderbook_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::types::order::{
OrdersListQuery,
};
use crate::types::order_trade::{OrderTradeDetailQuery, OrderTradesListQuery};
use crate::types::transaction::TransactionDetailQuery;
use crate::types::vault::{VaultDetailQuery, VaultsListQuery};
use crate::vault_balance_changes_query::VaultBalanceChangesListPageQueryClient;
use cynic::Id;
Expand All @@ -25,6 +26,8 @@ pub enum OrderbookSubgraphClientError {
CynicClientError(#[from] CynicClientError),
#[error("Subgraph query returned no data")]
Empty,
#[error("Request timed out")]
RequestTimedOut,
#[error(transparent)]
PaginationClientError(#[from] PaginationClientError),
#[error(transparent)]
Expand Down Expand Up @@ -379,4 +382,17 @@ impl OrderbookSubgraphClient {
}
Ok(all_pages_merged)
}

pub async fn transaction_detail(
&self,
id: Id,
) -> Result<Transaction, OrderbookSubgraphClientError> {
let data = self
.query::<TransactionDetailQuery, IdQueryVariables>(IdQueryVariables { id: &id })
.await?;
let transaction = data
.transaction
.ok_or(OrderbookSubgraphClientError::Empty)?;
Ok(transaction)
}
}
1 change: 1 addition & 0 deletions crates/subgraph/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod impls;
pub mod order;
pub mod order_detail_traits;
pub mod order_trade;
pub mod transaction;
pub mod vault;

pub use cynic::Id;
12 changes: 12 additions & 0 deletions crates/subgraph/src/types/transaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use super::common::*;
use crate::schema;
use typeshare::typeshare;

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "IdQueryVariables")]
#[typeshare]
pub struct TransactionDetailQuery {
#[arguments(id: $id)]
#[typeshare(typescript(type = "TransactionSubgraph"))]
pub transaction: Option<Transaction>,
}
119 changes: 83 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f65fbff

Please sign in to comment.