Skip to content

Commit

Permalink
pass by ref
Browse files Browse the repository at this point in the history
  • Loading branch information
lisicky committed Oct 14, 2024
1 parent 29a5661 commit 0980b26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/sidan-csl-rs/src/core/utils/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use uplc::{
#[wasm_bindgen]
pub fn evaluate_tx_scripts_js(
tx_hex: String,
resolved_utxos: JsVecString,
additional_txs: JsVecString,
resolved_utxos: &JsVecString,
additional_txs: &JsVecString,
network: String,
) -> WasmResult {
let mut deserialized_utxos: Vec<UTxO> = Vec::new();
Expand All @@ -50,7 +50,7 @@ pub fn evaluate_tx_scripts_js(
let eval_result = evaluate_tx_scripts(
&tx_hex,
&deserialized_utxos,
&additional_txs.into_vec(),
&additional_txs.as_ref_vec(),
&deserialize_network,
);

Expand Down Expand Up @@ -422,8 +422,8 @@ mod test {

let result = evaluate_tx_scripts_js(
tx_hex.to_string(),
resolved_utxos,
additional_txs,
&resolved_utxos,
&additional_txs,
"preprod".to_string()
);

Expand Down
13 changes: 13 additions & 0 deletions packages/sidan-csl-rs/src/model/js_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ impl JsVecString {
pub(crate) fn into_vec(self) -> Vec<String> {
self.0
}

pub(crate) fn as_ref_vec(&self) -> &Vec<String> {
&self.0
}
}

impl IntoIterator for JsVecString {
Expand All @@ -41,6 +45,15 @@ impl IntoIterator for JsVecString {
}
}

impl<'a> IntoIterator for &'a JsVecString {
type Item = &'a String;
type IntoIter = std::slice::Iter<'a, String>;

fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}

impl JsVecString {
pub fn iter(&self) -> std::slice::Iter<String> {
self.0.iter()
Expand Down

0 comments on commit 0980b26

Please sign in to comment.