From f9395af29671345d41daffa2bc3f3a04652c8c7d Mon Sep 17 00:00:00 2001 From: Marvin Bertin Date: Tue, 5 Dec 2023 09:32:04 +0300 Subject: [PATCH 01/19] fix README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6636c7..61dbee7 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ ## Installation -### [Crates Reference](TODO) +### Crates Reference ```bash # TODO From 5d33f8fa25c031cb52c38ff5432f7d445e74fc75 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 10:24:13 -0500 Subject: [PATCH 02/19] adds `stake_pool_delegator_history` endpoint. --- src/client/pools.rs | 14 ++++++++++++++ src/models/pools.rs | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/client/pools.rs b/src/client/pools.rs index b1714f0..fbbb99c 100644 --- a/src/client/pools.rs +++ b/src/client/pools.rs @@ -103,4 +103,18 @@ impl Maestro { serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box)?; Ok(stake_pool_updates) } + + pub async fn stake_pool_delegator_history( + &self, + pool_id: &str, + epoch_no: i64, + params: Option, + ) -> Result> { + let formatted_params = params.map(|p| p.format()).unwrap_or_default(); + let url = format!("/pools/{}/delegators/{}{}", pool_id, epoch_no, formatted_params); + let resp = self.get(&url).await?; + let stake_pool_delegator_history = + serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box)?; + Ok(stake_pool_delegator_history) + } } diff --git a/src/models/pools.rs b/src/models/pools.rs index d879f5b..e06cb3d 100644 --- a/src/models/pools.rs +++ b/src/models/pools.rs @@ -142,3 +142,9 @@ pub struct StakePoolUpdates { pub data: Vec, pub last_updated: utils::LastUpdated, } + +#[derive(Deserialize)] +pub struct StakePoolDelegatorHistory { + pub amount: String, + pub stake_address: String, +} From 9cfc383f0f413496b7599c7a8633f8d2b39e6be4 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 10:38:26 -0500 Subject: [PATCH 03/19] fixes return type. --- src/client/pools.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/pools.rs b/src/client/pools.rs index fbbb99c..bfb0d37 100644 --- a/src/client/pools.rs +++ b/src/client/pools.rs @@ -1,8 +1,9 @@ use super::maestro::Maestro; use crate::{ models::pools::{ - PoolMintedBlocks, RegisteredPools, StakePoolDelegators, StakePoolHistory, - StakePoolInformation, StakePoolMetadata, StakePoolRelays, StakePoolUpdates, + PoolMintedBlocks, RegisteredPools, StakePoolDelegatorHistory, StakePoolDelegators, + StakePoolHistory, StakePoolInformation, StakePoolMetadata, StakePoolRelays, + StakePoolUpdates, }, utils::Parameters, }; @@ -109,9 +110,12 @@ impl Maestro { pool_id: &str, epoch_no: i64, params: Option, - ) -> Result> { + ) -> Result, Box> { let formatted_params = params.map(|p| p.format()).unwrap_or_default(); - let url = format!("/pools/{}/delegators/{}{}", pool_id, epoch_no, formatted_params); + let url = format!( + "/pools/{}/delegators/{}{}", + pool_id, epoch_no, formatted_params + ); let resp = self.get(&url).await?; let stake_pool_delegator_history = serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box)?; From b0dd2a4481e2001962773c1f4a1d7c5671f44124 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 10:41:11 -0500 Subject: [PATCH 04/19] _really_ fixes return types. --- src/client/pools.rs | 2 +- src/models/pools.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/pools.rs b/src/client/pools.rs index bfb0d37..804ee4a 100644 --- a/src/client/pools.rs +++ b/src/client/pools.rs @@ -110,7 +110,7 @@ impl Maestro { pool_id: &str, epoch_no: i64, params: Option, - ) -> Result, Box> { + ) -> Result> { let formatted_params = params.map(|p| p.format()).unwrap_or_default(); let url = format!( "/pools/{}/delegators/{}{}", diff --git a/src/models/pools.rs b/src/models/pools.rs index e06cb3d..25d62f3 100644 --- a/src/models/pools.rs +++ b/src/models/pools.rs @@ -144,7 +144,14 @@ pub struct StakePoolUpdates { } #[derive(Deserialize)] -pub struct StakePoolDelegatorHistory { +pub struct StakePoolDelegatorHistoryData { pub amount: String, pub stake_address: String, } + +#[derive(Deserialize)] +pub struct StakePoolDelegatorHistory { + pub data: Vec, + pub last_updated: utils::LastUpdated, + pub next_cursor: Option, +} From 516d586fae6c64923006523a13934174c98f47a2 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 10:48:04 -0500 Subject: [PATCH 05/19] le sigh. --- src/models/pools.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/pools.rs b/src/models/pools.rs index 25d62f3..b8b801d 100644 --- a/src/models/pools.rs +++ b/src/models/pools.rs @@ -151,7 +151,7 @@ pub struct StakePoolDelegatorHistoryData { #[derive(Deserialize)] pub struct StakePoolDelegatorHistory { - pub data: Vec, + pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } From 3f8e2b5aa3eff93fde33c46b0dcbfb05dad3fac9 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 12:20:26 -0500 Subject: [PATCH 06/19] margin seems to be a float. --- src/models/pools.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/pools.rs b/src/models/pools.rs index b8b801d..e4e4ff9 100644 --- a/src/models/pools.rs +++ b/src/models/pools.rs @@ -56,7 +56,7 @@ pub struct StakePoolHistoryData { pub epoch_no: i64, pub epoch_ros: String, pub fixed_cost: i64, - pub margin: i64, + pub margin: serde_json::Value, pub pool_fees: i64, pub saturation_pct: serde_json::Value, } From 07be8052f5a9eba5ccb14b753c463af83f40bd42 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Tue, 12 Mar 2024 16:55:59 -0500 Subject: [PATCH 07/19] updates types to match api spec. --- src/models/epochs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/epochs.rs b/src/models/epochs.rs index b1e4019..65192f7 100644 --- a/src/models/epochs.rs +++ b/src/models/epochs.rs @@ -5,8 +5,8 @@ use serde::Deserialize; pub struct Epoch { pub blk_count: i32, pub epoch_no: i32, - pub fees: i32, - pub start_time: i32, + pub fees: String, + pub start_time: i64, pub tx_count: i32, } From 93cce39f4b422e6f3bdf91fcb36602ebf8235a6f Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Mon, 18 Mar 2024 10:12:43 -0500 Subject: [PATCH 08/19] adds markets dex pair ohlc endpoint. --- Cargo.toml | 5 +++- src/client/markets.rs | 23 +++++++++++++++++ src/client/mod.rs | 1 + src/models/markets.rs | 60 +++++++++++++++++++++++++++++++++++++++++++ src/models/mod.rs | 1 + 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/client/markets.rs create mode 100644 src/models/markets.rs diff --git a/Cargo.toml b/Cargo.toml index 3dd4d17..3f08535 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,7 @@ license = "Apache-2.0" [dependencies] reqwest = "0.11" serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" \ No newline at end of file +serde_json = "1.0" +rust_decimal = "1.34" +serde_qs = "0.12" +chrono = { version = "0.4", features = ["serde"] } diff --git a/src/client/markets.rs b/src/client/markets.rs new file mode 100644 index 0000000..e770433 --- /dev/null +++ b/src/client/markets.rs @@ -0,0 +1,23 @@ +use crate::models::markets::{DexPairOHLC, DexPairOHLCParameters}; + +use super::maestro::Maestro; +use std::{error::Error, fmt::Display}; + +impl Maestro { + /// Returns market activity in candlestick OHLC format for a specific DEX and token pair + pub async fn markets_dex_pair_ohlc( + &self, + dex: impl Display, + pair: impl Display, + parameters: Option, + ) -> Result, Box> { + let ps = parameters + .and_then(|p| serde_qs::to_string(&p).ok()) + .map(|x| format!("?{x}")) + .unwrap_or_default(); + let url = format!("/markets/dexs/ohlc/{dex}/{pair}{ps}"); + let resp = self.get(&url).await?; + + serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box) + } +} diff --git a/src/client/mod.rs b/src/client/mod.rs index 495fccc..fdb4af0 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -10,6 +10,7 @@ pub mod epochs; pub mod general; pub mod linear_vesting; pub mod maestro; +pub mod markets; pub mod pools; pub mod scripts; pub mod transactions; diff --git a/src/models/markets.rs b/src/models/markets.rs new file mode 100644 index 0000000..0c9f588 --- /dev/null +++ b/src/models/markets.rs @@ -0,0 +1,60 @@ +use chrono::{DateTime, Utc}; +use rust_decimal::Decimal; +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize)] +pub struct DexPairOHLC { + pub coin_a_change_pct: Decimal, + pub coin_a_close: Decimal, + pub coin_a_high: Decimal, + pub coin_a_low: Decimal, + pub coin_a_open: Decimal, + pub coin_a_volume: Decimal, + pub coin_b_change_pct: Decimal, + pub coin_b_close: Decimal, + pub coin_b_high: Decimal, + pub coin_b_low: Decimal, + pub coin_b_open: Decimal, + pub coin_b_volume: Decimal, + pub count: i64, + pub timestamp: DateTime, +} + +#[derive(Serialize)] +pub enum Resolution { + #[serde(rename = "1m")] + OneMinute, + #[serde(rename = "5m")] + FiveMinutes, + #[serde(rename = "15m")] + FifteenMinutes, + #[serde(rename = "30m")] + ThirtyMinutes, + #[serde(rename = "1h")] + OneHour, + #[serde(rename = "4h")] + FourHours, + #[serde(rename = "1d")] + OneDay, + #[serde(rename = "1w")] + OneWeek, + #[serde(rename = "1mo")] + OneMonth, +} + +#[derive(Serialize)] +pub enum Sort { + #[serde(rename = "asc")] + Asc, + #[serde(rename = "desc")] + Desc, +} + +#[derive(Default, Serialize)] +pub struct DexPairOHLCParameters { + pub resolution: Option, + pub from: Option, + pub to: Option, + pub limit: Option, + pub sort: Option, +} diff --git a/src/models/mod.rs b/src/models/mod.rs index 8eeb790..1daef17 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -7,6 +7,7 @@ pub mod datum; pub mod epochs; pub mod general; pub mod linear_vesting; +pub mod markets; pub mod pools; pub mod scripts; pub mod transactions; From 9af20094d0c4d72985374a91e889798ba09e7c34 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Mon, 18 Mar 2024 10:19:40 -0500 Subject: [PATCH 09/19] updates req/res for ohlc. --- src/models/markets.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/markets.rs b/src/models/markets.rs index 0c9f588..8f9981a 100644 --- a/src/models/markets.rs +++ b/src/models/markets.rs @@ -2,7 +2,7 @@ use chrono::{DateTime, Utc}; use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; -#[derive(Deserialize)] +#[derive(Clone, Debug, Deserialize)] pub struct DexPairOHLC { pub coin_a_change_pct: Decimal, pub coin_a_close: Decimal, @@ -20,7 +20,7 @@ pub struct DexPairOHLC { pub timestamp: DateTime, } -#[derive(Serialize)] +#[derive(Clone, Copy, Debug, Serialize)] pub enum Resolution { #[serde(rename = "1m")] OneMinute, @@ -42,7 +42,7 @@ pub enum Resolution { OneMonth, } -#[derive(Serialize)] +#[derive(Clone, Copy, Debug, Serialize)] pub enum Sort { #[serde(rename = "asc")] Asc, @@ -50,9 +50,9 @@ pub enum Sort { Desc, } -#[derive(Default, Serialize)] +#[derive(Clone, Debug, Default, Serialize)] pub struct DexPairOHLCParameters { - pub resolution: Option, + pub resolution: Option, pub from: Option, pub to: Option, pub limit: Option, From 25581cd45823fcda7f0ce5f683578494a6f7a436 Mon Sep 17 00:00:00 2001 From: RJ Regenold Date: Mon, 18 Mar 2024 10:56:47 -0500 Subject: [PATCH 10/19] fixes bad epoch endpoint. --- src/client/epochs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/epochs.rs b/src/client/epochs.rs index d2b8909..6b60a46 100644 --- a/src/client/epochs.rs +++ b/src/client/epochs.rs @@ -12,7 +12,7 @@ impl Maestro { } pub async fn specific_epoch(&self, epoch_no: i32) -> Result> { - let url = format!("/epochs/{}/info", epoch_no); + let url = format!("/epochs/{}", epoch_no); let resp = self.get(&url).await?; let specific_epoch = serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box)?; From 107bca4a7c3e5de8cc3ec9ca4d5423fceb00a0c2 Mon Sep 17 00:00:00 2001 From: Varderes Date: Tue, 19 Mar 2024 12:33:41 -0500 Subject: [PATCH 11/19] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3f08535..8e9435b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "maestro" -version = "1.0.0" +version = "1.1.0" edition = "2021" license = "Apache-2.0" From 88e9ad95ac26d05f30c7d96ec19983030d56cdac Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 4 Apr 2024 16:49:51 +0000 Subject: [PATCH 12/19] Fix ReferenceScrit model. --- src/client/transactions.rs | 4 ++-- src/models/addresses.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/transactions.rs b/src/client/transactions.rs index 8fcf4c9..1b92a8a 100644 --- a/src/client/transactions.rs +++ b/src/client/transactions.rs @@ -54,11 +54,11 @@ impl Maestro { params: Option>, ) -> Result> { let formatted_params = params.map_or("".to_string(), |p| { - p.iter() + "?".to_string() + p.iter() .map(|(k, v)| format!("{}={}", k, v)) .collect::>() .join("&") - .to_string() + .as_str() }); let url = format!( "/transactions/{}/outputs/{}/txo{}", diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 755c35e..6c09d4f 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -95,7 +95,7 @@ pub struct Utxo { pub struct ReferenceScript { pub bytes: String, pub hash: String, - pub json: HashMap, + pub json: Option>, pub r#type: String, } From 6e33b1ca043fb7db79d977ffd686b920d63a2e48 Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 4 Apr 2024 16:52:46 +0000 Subject: [PATCH 13/19] FixUtxo model. --- src/models/addresses.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 6c09d4f..2bde342 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -87,7 +87,6 @@ pub struct Utxo { pub index: i64, pub reference_script: ReferenceScript, pub tx_hash: String, - pub slot: i64, pub tx_out_cbor: String, } From 84f8bfe703b75b856937bace60a36a8f5761c24f Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 4 Apr 2024 16:55:29 +0000 Subject: [PATCH 14/19] Fix Utxo model txout_cbor. --- src/models/addresses.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 2bde342..9a17090 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -87,7 +87,7 @@ pub struct Utxo { pub index: i64, pub reference_script: ReferenceScript, pub tx_hash: String, - pub tx_out_cbor: String, + pub txout_cbor: String, } #[derive(Deserialize)] From ea20b362bd16faf3636d8709d564af7d05de85e8 Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 4 Apr 2024 16:57:50 +0000 Subject: [PATCH 15/19] Fix Utxo model add alias for tx_out_cbor. --- src/models/addresses.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 9a17090..2278b38 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -87,7 +87,8 @@ pub struct Utxo { pub index: i64, pub reference_script: ReferenceScript, pub tx_hash: String, - pub txout_cbor: String, + #[serde(alias="txout_cbor")] + pub tx_out_cbor: String, } #[derive(Deserialize)] From 8593c0496eb86606ceb429286e2e98f96ce109c5 Mon Sep 17 00:00:00 2001 From: Ilya Date: Fri, 5 Apr 2024 09:29:31 +0000 Subject: [PATCH 16/19] Fix structure Utxo, make reference_script optional. --- src/models/addresses.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 2278b38..56d2f7d 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -85,7 +85,7 @@ pub struct Utxo { pub assets: Vec, pub datum: Option>, pub index: i64, - pub reference_script: ReferenceScript, + pub reference_script: Option, pub tx_hash: String, #[serde(alias="txout_cbor")] pub tx_out_cbor: String, From d7ec83ef6d6215730578dafec4ccbe3ca6955354 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Thu, 11 Apr 2024 18:11:04 +0800 Subject: [PATCH 17/19] fix: remvoe duplicate header --- src/client/block_info.rs | 8 ++++---- src/client/config.rs | 4 ++-- src/client/linear_vesting.rs | 2 +- src/client/maestro.rs | 2 -- src/models/accounts.rs | 26 +++++++++++++------------- src/models/addresses.rs | 30 +++++++++++++++--------------- src/models/asset.rs | 22 +++++++++++----------- src/models/asset_policy.rs | 22 +++++++++++----------- src/models/common.rs | 2 +- src/models/datum.rs | 4 ++-- src/models/epochs.rs | 4 ++-- src/models/general.rs | 22 +++++++++++----------- src/models/linear_vesting.rs | 6 +++--- src/models/pools.rs | 36 ++++++++++++++++++------------------ src/models/scripts.rs | 6 +++--- src/models/transactions.rs | 20 ++++++++++---------- src/models/txmanager.rs | 2 +- src/utils/last_updated.rs | 2 +- 18 files changed, 109 insertions(+), 111 deletions(-) diff --git a/src/client/block_info.rs b/src/client/block_info.rs index 2b7da0d..75da424 100644 --- a/src/client/block_info.rs +++ b/src/client/block_info.rs @@ -3,7 +3,7 @@ use crate::utils; use serde::{Deserialize, Serialize}; use std::error::Error; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct OperationalCertificate { pub hot_vkey: String, pub kes_period: i64, @@ -11,13 +11,13 @@ pub struct OperationalCertificate { pub sequence_number: i64, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct TotalExUnits { pub mem: i64, pub steps: i64, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct BlockInfoData { pub absolute_slot: i64, pub block_producer: String, @@ -40,7 +40,7 @@ pub struct BlockInfoData { pub vrf_key: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct BlockInfo { pub data: BlockInfoData, pub last_updated: utils::last_updated::LastUpdated, diff --git a/src/client/config.rs b/src/client/config.rs index c5fbcfc..73ff20c 100644 --- a/src/client/config.rs +++ b/src/client/config.rs @@ -1,12 +1,12 @@ use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ClientConfig { pub version: String, pub timeout: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Config { pub client: ClientConfig, } diff --git a/src/client/linear_vesting.rs b/src/client/linear_vesting.rs index 31982c8..47c34b2 100644 --- a/src/client/linear_vesting.rs +++ b/src/client/linear_vesting.rs @@ -3,7 +3,7 @@ use crate::models::linear_vesting::{CollectTransaction, LockTransaction, Vesting use serde::{Deserialize, Serialize}; use std::error::Error; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct LockBody { pub sender: String, pub beneficiary: String, diff --git a/src/client/maestro.rs b/src/client/maestro.rs index 9f42b93..d57029d 100644 --- a/src/client/maestro.rs +++ b/src/client/maestro.rs @@ -64,8 +64,6 @@ impl Maestro { let req = self .http_client .post(format!("{}{}", &self.base_url, url)) - .header("Accept", "application/json") - .header("api-key", &self.api_key) .header("Content-Type", "application/json") .body(json_body); diff --git a/src/models/accounts.rs b/src/models/accounts.rs index e291f14..e028709 100644 --- a/src/models/accounts.rs +++ b/src/models/accounts.rs @@ -1,41 +1,41 @@ use crate::utils; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountAddresses { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountAsset { pub amount: i64, pub unit: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountAssets { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountHistoryItem { pub active_stake: i64, pub epoch_no: i64, pub pool_id: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountHistory { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountInformation { pub delegated_pool: String, pub registered: bool, @@ -47,20 +47,20 @@ pub struct AccountInformation { pub utxo_balance: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountInformation { pub data: AccountInformation, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub enum StakeRewardType { Member, Leader, Refund, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountReward { pub amount: i64, pub earned_epoch: i64, @@ -69,14 +69,14 @@ pub struct StakeAccountReward { pub r#type: StakeRewardType, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountRewards { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub enum StakeUpdateAction { Registration, Deregistration, @@ -84,7 +84,7 @@ pub enum StakeUpdateAction { Withdrawal, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountUpdate { pub absolute_slot: i64, pub action: StakeUpdateAction, @@ -92,7 +92,7 @@ pub struct StakeAccountUpdate { pub tx_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakeAccountUpdates { pub data: Vec, pub last_updated: utils::LastUpdated, diff --git a/src/models/addresses.rs b/src/models/addresses.rs index 56d2f7d..05989b7 100644 --- a/src/models/addresses.rs +++ b/src/models/addresses.rs @@ -2,26 +2,26 @@ use crate::utils; use serde::Deserialize; use std::collections::HashMap; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub enum Network { Mainnet, Testnet, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub enum CredentialKind { Key, Script, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct PaymentCredential { pub bech32: String, pub hex: String, pub kind: CredentialKind, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakingCredential { pub bech32: String, pub hex: String, @@ -30,7 +30,7 @@ pub struct StakingCredential { pub reward_address: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct DecodedAddress { pub bech32: String, pub hex: String, @@ -39,13 +39,13 @@ pub struct DecodedAddress { pub staking_cred: StakingCredential, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressTransactionCount { pub data: i32, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Transaction { pub input: bool, pub output: bool, @@ -53,33 +53,33 @@ pub struct Transaction { pub tx_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressTransactions { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct UtxoReference { pub index: i64, pub tx_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct UtxoReferencesAtAddress { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Asset { pub amount: i64, pub unit: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Utxo { pub address: String, pub assets: Vec, @@ -87,11 +87,11 @@ pub struct Utxo { pub index: i64, pub reference_script: Option, pub tx_hash: String, - #[serde(alias="txout_cbor")] + #[serde(alias = "txout_cbor")] pub tx_out_cbor: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ReferenceScript { pub bytes: String, pub hash: String, @@ -99,7 +99,7 @@ pub struct ReferenceScript { pub r#type: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct UtxosAtAddress { pub data: Vec, pub last_updated: utils::LastUpdated, diff --git a/src/models/asset.rs b/src/models/asset.rs index 5bd9f8c..45d1857 100644 --- a/src/models/asset.rs +++ b/src/models/asset.rs @@ -3,53 +3,53 @@ use crate::utils; use serde::Deserialize; use std::collections::HashMap; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountHoldingAsset { pub account: String, pub amount: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountsHoldingAsset { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressHoldingAsset { pub address: String, pub amount: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressesHoldingAsset { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetInformations { pub data: AssetInformation, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetTransactions { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Metadata { pub json: Option>, pub key: Option>, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetUpdate { pub block_timestamp: i64, pub metadata: Metadata, @@ -57,14 +57,14 @@ pub struct AssetUpdate { pub tx_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetUpdates { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetUtxo { pub address: String, pub amount: i64, @@ -73,7 +73,7 @@ pub struct AssetUtxo { pub tx_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetUtxos { pub data: Vec, pub last_updated: utils::LastUpdated, diff --git a/src/models/asset_policy.rs b/src/models/asset_policy.rs index 8c44f5e..eb0c579 100644 --- a/src/models/asset_policy.rs +++ b/src/models/asset_policy.rs @@ -3,45 +3,45 @@ use crate::utils; use serde::Deserialize; use std::collections::HashMap; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetNameAndAmount { pub name: String, pub amount: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountHolding { pub account: String, pub assets: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AccountsHoldingPolicy { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressHolding { pub address: String, pub assets: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AddressesHoldingPolicy { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Standards { pub cip25_metadata: HashMap, pub cip68_metadata: HashMap, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct AssetInformation { pub asset_name: String, pub asset_name_ascii: String, @@ -56,28 +56,28 @@ pub struct AssetInformation { pub total_supply: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct PolicyInformation { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct PolicyTransaction { pub block_height: i64, pub epoch_no: i64, pub tx_hash: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct PolicyTransactions { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct UtxosContainingPolicy { pub data: Vec, pub last_updated: utils::LastUpdated, diff --git a/src/models/common.rs b/src/models/common.rs index a7738f6..50ea745 100644 --- a/src/models/common.rs +++ b/src/models/common.rs @@ -1,7 +1,7 @@ use crate::utils::LastUpdated; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct BasicResponse { pub data: String, pub last_updated: LastUpdated, diff --git a/src/models/datum.rs b/src/models/datum.rs index 450181f..3e25c64 100644 --- a/src/models/datum.rs +++ b/src/models/datum.rs @@ -2,13 +2,13 @@ use crate::utils; use serde::{Deserialize, Serialize}; use serde_json::Value; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct Datum { pub bytes: String, pub json: Value, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct DatumFromHash { pub data: Datum, pub last_updated: utils::LastUpdated, diff --git a/src/models/epochs.rs b/src/models/epochs.rs index 65192f7..7007e09 100644 --- a/src/models/epochs.rs +++ b/src/models/epochs.rs @@ -1,7 +1,7 @@ use crate::utils; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Epoch { pub blk_count: i32, pub epoch_no: i32, @@ -10,7 +10,7 @@ pub struct Epoch { pub tx_count: i32, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct EpochResp { pub data: Epoch, pub last_updated: utils::LastUpdated, diff --git a/src/models/general.rs b/src/models/general.rs index 6bd98c2..e08af62 100644 --- a/src/models/general.rs +++ b/src/models/general.rs @@ -1,71 +1,71 @@ use crate::utils; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ChainTipData { pub block_hash: String, pub height: i64, pub slot: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ChainTip { pub data: ChainTipData, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct EraTimeStamp { pub epoch: i64, pub slot: i64, pub time: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct EraParams { pub epoch_length: i64, pub safe_zone: i64, pub slot_length: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Era { pub end: EraTimeStamp, pub parameters: EraParams, pub start: EraTimeStamp, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct EraHistory { pub data: Vec, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ProtocolParameters { pub data: ProtocolParams, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ExUnits { pub memory: i64, pub steps: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StringExUnits { pub memory: String, pub steps: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ProtocolVersion { pub major: i64, pub minor: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ProtocolParams { pub coins_per_utxo_byte: i64, pub collateral_percentage: i64, diff --git a/src/models/linear_vesting.rs b/src/models/linear_vesting.rs index aac97d2..1dcce62 100644 --- a/src/models/linear_vesting.rs +++ b/src/models/linear_vesting.rs @@ -1,12 +1,12 @@ use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct LockTransaction { pub cbor_hex: String, pub tx_hash: String, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct VestingState { pub asset_name: String, pub asset_symbol: String, @@ -17,7 +17,7 @@ pub struct VestingState { pub vesting_period_end: i64, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct CollectTransaction { pub cbor_hex: String, pub tx_hash: String, diff --git a/src/models/pools.rs b/src/models/pools.rs index e4e4ff9..4e3d791 100644 --- a/src/models/pools.rs +++ b/src/models/pools.rs @@ -1,20 +1,20 @@ use crate::utils; use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Pool { pub pool_id_bech32: String, pub ticker: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct RegisteredPools { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Block { pub abs_slot: i64, pub block_hash: String, @@ -24,14 +24,14 @@ pub struct Block { pub epoch_slot: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct PoolMintedBlocks { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolDelegator { pub active_epoch_no: i64, pub amount: String, @@ -39,14 +39,14 @@ pub struct StakePoolDelegator { pub stake_address: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolDelegators { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolHistoryData { pub active_stake: i64, pub active_stake_pct: String, @@ -61,14 +61,14 @@ pub struct StakePoolHistoryData { pub saturation_pct: serde_json::Value, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolHistory { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Relay { pub dns: String, pub ipv4: String, @@ -77,7 +77,7 @@ pub struct Relay { pub srv: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolDetails { pub active_epoch_no: i64, pub active_stake: i64, @@ -105,13 +105,13 @@ pub struct StakePoolDetails { pub vrf_key_hash: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolInformation { pub data: StakePoolDetails, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Poolmetadata { pub meta_hash: String, pub meta_json: serde_json::Value, @@ -119,37 +119,37 @@ pub struct Poolmetadata { pub pool_id_bech32: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolMetadata { pub data: Poolmetadata, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct RelaysAndId { pub pool_id_bech32: String, pub relays: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolRelays { pub data: Vec, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolUpdates { pub data: Vec, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolDelegatorHistoryData { pub amount: String, pub stake_address: String, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct StakePoolDelegatorHistory { pub data: Vec, pub last_updated: utils::LastUpdated, diff --git a/src/models/scripts.rs b/src/models/scripts.rs index 36fcc13..bb2520d 100644 --- a/src/models/scripts.rs +++ b/src/models/scripts.rs @@ -2,13 +2,13 @@ use crate::utils; use serde::Deserialize; use serde::Serialize; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub enum ScriptVersion { PlutusV1, PlutusV2, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct Script { pub bytes: String, pub hash: String, @@ -16,7 +16,7 @@ pub struct Script { pub r#type: ScriptVersion, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ScriptByHash { pub data: Script, pub last_updated: utils::LastUpdated, diff --git a/src/models/transactions.rs b/src/models/transactions.rs index fa717d7..bfc4ab6 100644 --- a/src/models/transactions.rs +++ b/src/models/transactions.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use super::{addresses::Utxo, scripts::Script}; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Certificates { pub mir_transfers: Vec, pub pool_registrations: Vec, @@ -13,7 +13,7 @@ pub struct Certificates { pub stake_registrations_reserves: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct Redeemers { pub certificates: Vec, pub mints: Vec, @@ -21,7 +21,7 @@ pub struct Redeemers { pub withdrawals: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct TransactionDetail { pub additional_signers: Vec, pub block_absolute_slot: i64, @@ -49,44 +49,44 @@ pub struct TransactionDetail { pub withdrawals: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct TransactionDetails { pub data: TransactionDetail, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct TransactionOutputFromReference { pub data: Utxo, pub last_updated: utils::LastUpdated, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct TxoReference { pub tx_hash: String, pub index: i32, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct TransactionOutputsFromReferences { pub data: Vec, pub last_updated: utils::LastUpdated, pub next_cursor: Option, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct EvaluateTx { pub cbor: String, pub additional_utxos: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct ExecutionUnits { pub mem: i64, pub steps: i64, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct RedeemerEvaluation { pub ex_units: ExecutionUnits, pub redeemer_index: i32, diff --git a/src/models/txmanager.rs b/src/models/txmanager.rs index 7036107..7f8f442 100644 --- a/src/models/txmanager.rs +++ b/src/models/txmanager.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct TxManagerState { pub block: String, pub state: String, diff --git a/src/utils/last_updated.rs b/src/utils/last_updated.rs index ef4cfeb..b32eb42 100644 --- a/src/utils/last_updated.rs +++ b/src/utils/last_updated.rs @@ -1,6 +1,6 @@ use serde::Deserialize; -#[derive(Deserialize)] +#[derive(Deserialize, Debug, Clone)] pub struct LastUpdated { pub block_hash: String, pub block_slot: i64, From 212541b5f3e5e902b6b228014b47a6a32cb82b8d Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Thu, 11 Apr 2024 18:13:42 +0800 Subject: [PATCH 18/19] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8e9435b..ae33769 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "maestro" -version = "1.1.0" +version = "1.1.2" edition = "2021" license = "Apache-2.0" From f9057b9f81e53122e369fb64d897409fa5feb7be Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Thu, 11 Apr 2024 20:51:17 +0800 Subject: [PATCH 19/19] fix: fixing evaluation type: --- src/client/transactions.rs | 17 +++++++++-------- src/models/transactions.rs | 9 ++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/client/transactions.rs b/src/client/transactions.rs index 1b92a8a..dafc0c7 100644 --- a/src/client/transactions.rs +++ b/src/client/transactions.rs @@ -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}; @@ -54,11 +54,12 @@ impl Maestro { params: Option>, ) -> Result> { let formatted_params = params.map_or("".to_string(), |p| { - "?".to_string() + p.iter() - .map(|(k, v)| format!("{}={}", k, v)) - .collect::>() - .join("&") - .as_str() + "?".to_string() + + p.iter() + .map(|(k, v)| format!("{}={}", k, v)) + .collect::>() + .join("&") + .as_str() }); let url = format!( "/transactions/{}/outputs/{}/txo{}", @@ -92,7 +93,7 @@ impl Maestro { pub async fn evaluate_tx( &self, tx_cbor: &str, - additional_utxos: Vec, + additional_utxos: Vec, ) -> Result, Box> { let url = "/transactions/evaluate"; let body = EvaluateTx { diff --git a/src/models/transactions.rs b/src/models/transactions.rs index bfc4ab6..92daae4 100644 --- a/src/models/transactions.rs +++ b/src/models/transactions.rs @@ -74,10 +74,17 @@ pub struct TransactionOutputsFromReferences { pub next_cursor: Option, } +#[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, + pub additional_utxos: Vec, } #[derive(Deserialize, Debug, Clone)]