Skip to content

Commit

Permalink
fix: fixing evaluation type:
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Apr 11, 2024
1 parent 212541b commit f9057b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/client/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::maestro::Maestro;
use crate::models::{
common::BasicResponse,
transactions::{
EvaluateTx, RedeemerEvaluation, TransactionDetails, TransactionOutputFromReference,
TransactionOutputsFromReferences,
AdditionalUtxo, EvaluateTx, RedeemerEvaluation, TransactionDetails,
TransactionOutputFromReference, TransactionOutputsFromReferences,
},
};
use std::{collections::HashMap, error::Error};
Expand Down Expand Up @@ -54,11 +54,12 @@ impl Maestro {
params: Option<HashMap<String, String>>,
) -> Result<TransactionOutputFromReference, Box<dyn Error>> {
let formatted_params = params.map_or("".to_string(), |p| {
"?".to_string() + p.iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<String>>()
.join("&")
.as_str()
"?".to_string()
+ p.iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<String>>()
.join("&")
.as_str()
});
let url = format!(
"/transactions/{}/outputs/{}/txo{}",
Expand Down Expand Up @@ -92,7 +93,7 @@ impl Maestro {
pub async fn evaluate_tx(
&self,
tx_cbor: &str,
additional_utxos: Vec<String>,
additional_utxos: Vec<AdditionalUtxo>,
) -> Result<Vec<RedeemerEvaluation>, Box<dyn Error>> {
let url = "/transactions/evaluate";
let body = EvaluateTx {
Expand Down
9 changes: 8 additions & 1 deletion src/models/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ pub struct TransactionOutputsFromReferences {
pub next_cursor: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AdditionalUtxo {
pub tx_hash: String,
pub index: u32,
pub txout_cbor: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EvaluateTx {
pub cbor: String,
pub additional_utxos: Vec<String>,
pub additional_utxos: Vec<AdditionalUtxo>,
}

#[derive(Deserialize, Debug, Clone)]
Expand Down

0 comments on commit f9057b9

Please sign in to comment.