diff --git a/crates/quote/src/js_api/mod.rs b/crates/quote/src/js_api/mod.rs index 1803373df..f5f1fa2f8 100644 --- a/crates/quote/src/js_api/mod.rs +++ b/crates/quote/src/js_api/mod.rs @@ -1,11 +1,13 @@ use crate::{error::Error, BatchQuoteSpec as MainBatchQuoteSpec, QuoteSpec as MainQuoteSpec}; -use crate::{BatchQuoteTarget as MainBatchQuoteTarget, QuoteTarget as MainQuoteTarget}; +use crate::{ + get_order_quotes, BatchQuoteTarget as MainBatchQuoteTarget, QuoteTarget as MainQuoteTarget, +}; use alloy::primitives::{ hex::{encode_prefixed, FromHex}, Address, U256, }; use rain_orderbook_bindings::js_api::{Quote, SignedContextV1}; -use rain_orderbook_subgraph_client::utils::make_order_id; +use rain_orderbook_subgraph_client::{types::common::Order, utils::make_order_id}; use serde::{Deserialize, Serialize}; use serde_wasm_bindgen::to_value; use std::str::FromStr; @@ -175,3 +177,18 @@ pub async fn get_batch_quote_target_from_subgraph( )?), } } + +#[derive(Debug, Clone, Serialize, Deserialize, Tsify)] +#[serde(transparent)] +#[tsify(into_wasm_abi, from_wasm_abi)] +pub struct WasmOrder(pub Order); + +#[wasm_bindgen(js_name = "getOrderQuote")] +pub async fn get_order_quote( + order: WasmOrder, + rpc_url: String, + block_number: Option, +) -> Result { + let result = get_order_quotes(vec![order.0], block_number, rpc_url).await?; + Ok(to_value(&result)?) +}