diff --git a/stellar_rust_sdk/src/accounts/mod.rs b/stellar_rust_sdk/src/accounts/mod.rs index bb2da0a..39e18a8 100644 --- a/stellar_rust_sdk/src/accounts/mod.rs +++ b/stellar_rust_sdk/src/accounts/mod.rs @@ -131,11 +131,20 @@ pub mod test { assert_eq!(response.flags().auth_required(), AUTH_REQUIRED); assert_eq!(response.flags().auth_revocable(), AUTH_REVOCABLE); assert_eq!(response.flags().auth_immutable(), AUTH_IMMUTABLE); - assert_eq!(response.flags().auth_clawback_enabled(), AUTH_CLAWBACK_ENABLED); + assert_eq!( + response.flags().auth_clawback_enabled(), + AUTH_CLAWBACK_ENABLED + ); assert_eq!(response.balances()[0].balance(), BALANCE); assert_eq!(response.balances()[0].asset_type(), ASSET_TYPE); - assert_eq!(response.balances()[0].buying_liabilities(), BUYING_LIABILITY); - assert_eq!(response.balances()[0].selling_liabilities(), SELLING_LIABILITY); + assert_eq!( + response.balances()[0].buying_liabilities(), + BUYING_LIABILITY + ); + assert_eq!( + response.balances()[0].selling_liabilities(), + SELLING_LIABILITY + ); assert_eq!(response.signers()[0].key(), ACCOUNT_ID); assert_eq!(response.signers()[0].weight(), WEIGHT); assert_eq!(response.signers()[0].singer_type(), SIGNER_TYPE); @@ -172,11 +181,20 @@ pub mod test { assert_eq!(response.flags().auth_required(), AUTH_REQUIRED); assert_eq!(response.flags().auth_revocable(), AUTH_REVOCABLE); assert_eq!(response.flags().auth_immutable(), AUTH_IMMUTABLE); - assert_eq!(response.flags().auth_clawback_enabled(), AUTH_CLAWBACK_ENABLED); + assert_eq!( + response.flags().auth_clawback_enabled(), + AUTH_CLAWBACK_ENABLED + ); assert_eq!(response.balances()[0].balance(), BALANCE); assert_eq!(response.balances()[0].asset_type(), ASSET_TYPE); - assert_eq!(response.balances()[0].buying_liabilities(), BUYING_LIABILITY); - assert_eq!(response.balances()[0].selling_liabilities(), SELLING_LIABILITY); + assert_eq!( + response.balances()[0].buying_liabilities(), + BUYING_LIABILITY + ); + assert_eq!( + response.balances()[0].selling_liabilities(), + SELLING_LIABILITY + ); assert_eq!(response.signers()[0].key(), ACCOUNT_ID); assert_eq!(response.signers()[0].weight(), WEIGHT); assert_eq!(response.signers()[0].singer_type(), SIGNER_TYPE); diff --git a/stellar_rust_sdk/src/assets/mod.rs b/stellar_rust_sdk/src/assets/mod.rs index b9d4d9f..7a006bb 100644 --- a/stellar_rust_sdk/src/assets/mod.rs +++ b/stellar_rust_sdk/src/assets/mod.rs @@ -76,7 +76,7 @@ pub mod prelude { #[cfg(test)] pub mod test { use super::prelude::*; - use crate::{horizon_client::HorizonClient}; + use crate::horizon_client::HorizonClient; #[tokio::test] async fn test_get_all_assets() { @@ -101,7 +101,6 @@ pub mod test { static AUTH_IMMUTABLE: &bool = &false; static AUTH_CLAWBACK_ENABLED: &bool = &false; - // Initialize horizon client let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); @@ -126,9 +125,15 @@ pub mod test { assert_eq!(response.num_liquidity_pools(), NUM_LIQUIDITY_POOLS); assert_eq!(response.amount(), AMOUNT); assert_eq!(response.accounts().authorized(), AUTHORIZED); - assert_eq!(response.accounts().authorized_to_maintain_liabilities(), AUTHORIZED_TO_MAINTAIN_LIABILITIES); + assert_eq!( + response.accounts().authorized_to_maintain_liabilities(), + AUTHORIZED_TO_MAINTAIN_LIABILITIES + ); assert_eq!(response.accounts().unauthorized(), UNAUTHORIZED); - assert_eq!(response.claimable_balances_amount(), CLAIMABLE_BALANCES_AMOUNT); + assert_eq!( + response.claimable_balances_amount(), + CLAIMABLE_BALANCES_AMOUNT + ); assert_eq!(response.liquidity_pools_amount(), LIQUIDITY_POOLS_AMOUNT); assert_eq!(response.contracts_amount(), CONTRACTS_AMOUNT); assert_eq!(response.balances().authorized(), BALANCES_AUTHORIZED); @@ -136,6 +141,9 @@ pub mod test { assert_eq!(response.flags().auth_required(), AUTH_REQUIRED); assert_eq!(response.flags().auth_revocable(), AUTH_REVOCABLE); assert_eq!(response.flags().auth_immutable(), AUTH_IMMUTABLE); - assert_eq!(response.flags().auth_clawback_enabled(), AUTH_CLAWBACK_ENABLED); + assert_eq!( + response.flags().auth_clawback_enabled(), + AUTH_CLAWBACK_ENABLED + ); } } diff --git a/stellar_rust_sdk/src/claimable_balances/mod.rs b/stellar_rust_sdk/src/claimable_balances/mod.rs index 675f910..be00ebb 100644 --- a/stellar_rust_sdk/src/claimable_balances/mod.rs +++ b/stellar_rust_sdk/src/claimable_balances/mod.rs @@ -89,14 +89,16 @@ fn parse_epoch(epoch_str: &str) -> DateTime { } pub mod prelude { - pub use super::{all_claimable_balances_request::*, response::*, single_claimable_balance_request::*}; + pub use super::{ + all_claimable_balances_request::*, response::*, single_claimable_balance_request::*, + }; } #[cfg(test)] mod tests { use super::parse_epoch; use super::prelude::*; - use crate::{horizon_client::HorizonClient}; + use crate::horizon_client::HorizonClient; use chrono::DateTime; use chrono::{TimeZone, Utc}; use lazy_static::lazy_static; @@ -151,7 +153,8 @@ mod tests { #[tokio::test] async fn test_get_all_claimable_balances() { - static ID: &str = "0000000010a8f6991f79df306f22a2032f6007ad594dd30f966b21556f7d75658ec1c4e9"; + static ID: &str = + "0000000010a8f6991f79df306f22a2032f6007ad594dd30f966b21556f7d75658ec1c4e9"; static ASSET: &str = "native"; static AMOUNT: &str = "3.0000000"; static SPONSOR: &str = "GCRHSLTKEPLLRLC4MB5OJPO4DJYIMYHYBDHX4TET3XKUKFAYMWERHXVG"; @@ -183,44 +186,35 @@ mod tests { assert_eq!(predicate.is_valid(valid_date), true); let record = &binding.embedded().records()[0]; - assert_eq!( - record.id(), - ID - ); + assert_eq!(record.id(), ID); - assert_eq!( - record.asset(), - ASSET - ); + assert_eq!(record.asset(), ASSET); assert_eq!(record.amount(), AMOUNT); - assert_eq!( - record.sponsor(), - SPONSOR - ); + assert_eq!(record.sponsor(), SPONSOR); assert_eq!(record.last_modified_ledger(), LAST_MODIFIED_LEDGER); - assert_eq!( - record.last_modified_time().to_string(), - LAST_MODIFIED_TIME - ); + assert_eq!(record.last_modified_time().to_string(), LAST_MODIFIED_TIME); assert_eq!(record.flags().clawback_enabled(), CLAWBACK_ENABLED); } #[tokio::test] async fn test_get_single_claimable_balance() { - static CLAIMABLE_BALANCE_ID: &str = "00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; - static ID: &str = "00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; + static CLAIMABLE_BALANCE_ID: &str = + "00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; + static ID: &str = + "00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; static ASSET: &str = "IOM:GBSUM7J4W2IH5LAMSQGI7Y2OZBV2BJB6EOK7TIK66DXNJUU4JAY36VR2"; static AMOUNT: &str = "2.0000000"; static SPONSOR: &str = "GA7UL5DDCP6WR7KV5GXKXSHBMP577U7TBDBTBY33J57RZE2A37KW67JB"; static LAST_MODIFIED_LEDGER: &i64 = &9234; static LAST_MODIFIED_TIME: &str = "2024-06-12T10:19:12Z"; static CLAWBACK_ENABLED: &bool = &false; - static PAGING_TOKEN: &str = "9234-00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; + static PAGING_TOKEN: &str = + "9234-00000000fe3d8209ed9662e92f0d3a5c55068e18bd5e0697c3c6db6ac4c0870c6f3e0b38"; // Initialize horizon client let horizon_client = @@ -245,39 +239,40 @@ mod tests { assert_eq!(predicate.is_valid(valid_date), true); let single_claimable_balance_response = single_claimable_balance_response.unwrap(); - assert_eq!( - single_claimable_balance_response.id().to_string(), - ID - ); + assert_eq!(single_claimable_balance_response.id().to_string(), ID); - assert_eq!( - single_claimable_balance_response.asset().to_string(), - ASSET); + assert_eq!(single_claimable_balance_response.asset().to_string(), ASSET); assert_eq!( single_claimable_balance_response.amount().to_string(), - AMOUNT); + AMOUNT + ); assert_eq!( single_claimable_balance_response.sponsor().to_string(), - SPONSOR); + SPONSOR + ); assert_eq!( single_claimable_balance_response.last_modified_ledger(), - LAST_MODIFIED_LEDGER); + LAST_MODIFIED_LEDGER + ); assert_eq!( single_claimable_balance_response .last_modified_time() .to_string(), - LAST_MODIFIED_TIME); + LAST_MODIFIED_TIME + ); assert_eq!( single_claimable_balance_response.flags().clawback_enabled(), - CLAWBACK_ENABLED); + CLAWBACK_ENABLED + ); assert_eq!( single_claimable_balance_response.paging_token().to_string(), - PAGING_TOKEN); + PAGING_TOKEN + ); } } diff --git a/stellar_rust_sdk/src/effects/all_effects_request.rs b/stellar_rust_sdk/src/effects/all_effects_request.rs index 8500826..c2e4918 100644 --- a/stellar_rust_sdk/src/effects/all_effects_request.rs +++ b/stellar_rust_sdk/src/effects/all_effects_request.rs @@ -79,4 +79,4 @@ mod tests { assert!(request.is_err()); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/effects/effects_for_liquidity_pools_request.rs b/stellar_rust_sdk/src/effects/effects_for_liquidity_pools_request.rs index 4590f4f..526a193 100644 --- a/stellar_rust_sdk/src/effects/effects_for_liquidity_pools_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_liquidity_pools_request.rs @@ -89,7 +89,7 @@ impl Request for EffectsForLiquidityPoolRequest { #[cfg(test)] mod tests { use super::*; - use crate::{BuildQueryParametersExt}; + use crate::BuildQueryParametersExt; #[test] fn test_effects_for_liquidity_pools_request() { diff --git a/stellar_rust_sdk/src/effects/effects_for_operation_request.rs b/stellar_rust_sdk/src/effects/effects_for_operation_request.rs index c28a949..9457166 100644 --- a/stellar_rust_sdk/src/effects/effects_for_operation_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_operation_request.rs @@ -107,4 +107,4 @@ mod tests { let url = request.build_url(base_url); assert_eq!(url, "https://horizon-testnet.stellar.org/effects"); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs b/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs index 5f05672..4dbc52e 100644 --- a/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs @@ -1,4 +1,7 @@ -use crate::{models::{Order, Request}, BuildQueryParametersExt}; +use crate::{ + models::{Order, Request}, + BuildQueryParametersExt, +}; use stellar_rust_sdk_derive::pagination; /// Represents a request to fetch effect data from the Stellar Horizon API. @@ -43,10 +46,7 @@ impl EffectForTransactionRequest { /// # Arguments /// * `liquidity_pool_id` - A `String` value representing the liquidity pool id. /// - pub fn set_transaction_hash( - self, - transaction_hash: String, - ) -> EffectForTransactionRequest { + pub fn set_transaction_hash(self, transaction_hash: String) -> EffectForTransactionRequest { EffectForTransactionRequest { transaction_hash: Some(transaction_hash), ..self @@ -106,6 +106,9 @@ mod tests { url, "https://horizon-testnet.stellar.org/effects?transaction_hash=transaction_hash&cursor=1&limit=10&order=asc" ); - assert_eq!(query_parameters, "?transaction_hash=transaction_hash&cursor=1&limit=10&order=asc"); + assert_eq!( + query_parameters, + "?transaction_hash=transaction_hash&cursor=1&limit=10&order=asc" + ); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/effects/mod.rs b/stellar_rust_sdk/src/effects/mod.rs index 155febb..484b411 100644 --- a/stellar_rust_sdk/src/effects/mod.rs +++ b/stellar_rust_sdk/src/effects/mod.rs @@ -1,7 +1,7 @@ /// Provides the `AllEffectsRequest` struct. /// /// This module contains the `AllEffectsRequest` struct, which is designed to create requests -/// for querying comprehensive lists of effects from the Horizon server. +/// for querying comprehensive lists of effects from the Horizon server. /// /// The `AllEffectsRequest` struct is meant to be used in conjunction with the [`HorizonClient`](crate::horizon_client::HorizonClient) /// to perform the actual API calls and fetch asset data. It adheres to the structure @@ -119,7 +119,7 @@ pub mod prelude { #[cfg(test)] mod tests { use super::prelude::*; - use crate::{horizon_client::HorizonClient}; + use crate::horizon_client::HorizonClient; #[test] fn dummy_test() { @@ -271,33 +271,19 @@ mod tests { let binding = effects_for_ledger_response.clone().unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!( - record.id, - ID); + assert_eq!(record.id, ID); - assert_eq!( - record.paging_token, - PAGING_TOKEN); + assert_eq!(record.paging_token, PAGING_TOKEN); - assert_eq!( - record.account, - ACCOUNT); + assert_eq!(record.account, ACCOUNT); - assert_eq!( - record.effect_type, - RECORD_TYPE); + assert_eq!(record.effect_type, RECORD_TYPE); - assert_eq!( - record.type_i, - TYPE_I); + assert_eq!(record.type_i, TYPE_I); - assert_eq!( - record.created_at, - CREATED_AT); + assert_eq!(record.created_at, CREATED_AT); - assert_eq!( - record.starting_balance.as_ref().unwrap(), - STARTING_BALANCE); + assert_eq!(record.starting_balance.as_ref().unwrap(), STARTING_BALANCE); } #[tokio::test] diff --git a/stellar_rust_sdk/src/fee_stats/fee_stats_request.rs b/stellar_rust_sdk/src/fee_stats/fee_stats_request.rs index 96b3179..09ac34c 100644 --- a/stellar_rust_sdk/src/fee_stats/fee_stats_request.rs +++ b/stellar_rust_sdk/src/fee_stats/fee_stats_request.rs @@ -38,4 +38,4 @@ impl Request for FeeStatsRequest { fn build_url(&self, base_url: &str) -> String { format!("{}/{}", base_url, super::FEE_STATS_PATH) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/fee_stats/response.rs b/stellar_rust_sdk/src/fee_stats/response.rs index c53422d..43e2bc7 100644 --- a/stellar_rust_sdk/src/fee_stats/response.rs +++ b/stellar_rust_sdk/src/fee_stats/response.rs @@ -70,4 +70,4 @@ impl Response for FeeStatsResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/horizon_client.rs b/stellar_rust_sdk/src/horizon_client.rs index cbce99f..75f9825 100644 --- a/stellar_rust_sdk/src/horizon_client.rs +++ b/stellar_rust_sdk/src/horizon_client.rs @@ -33,10 +33,10 @@ use crate::{ details_request::{BuyingAsset, DetailsRequest, SellingAsset}, response::DetailsResponse, }, + payments::prelude::*, trade_aggregations::prelude::*, - transactions::prelude::*, trades::prelude::*, - payments::prelude::* + transactions::prelude::*, }; use reqwest; use url::Url; @@ -1175,7 +1175,7 @@ impl HorizonClient { ) -> Result { self.get::(request).await } - + /// Retrieves a list of all operations for a specific transaction from the Horizon server. /// /// This asynchronous method fetches a list of all operations for a specific transaction from the Horizon server. @@ -1225,7 +1225,7 @@ impl HorizonClient { ) -> Result { self.get::(request).await } - + /// Retrieves a list of order book details from the Horizon server. /// /// This asynchronous method fetches a list of order book details from the Horizon server. diff --git a/stellar_rust_sdk/src/ledgers/ledgers_request.rs b/stellar_rust_sdk/src/ledgers/ledgers_request.rs index 1fb3890..0b44d46 100644 --- a/stellar_rust_sdk/src/ledgers/ledgers_request.rs +++ b/stellar_rust_sdk/src/ledgers/ledgers_request.rs @@ -70,4 +70,4 @@ mod tests { "https://horizon-testnet.stellar.org/ledgers" ); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/ledgers/mod.rs b/stellar_rust_sdk/src/ledgers/mod.rs index 380adfe..e562af4 100644 --- a/stellar_rust_sdk/src/ledgers/mod.rs +++ b/stellar_rust_sdk/src/ledgers/mod.rs @@ -85,7 +85,7 @@ pub mod prelude { #[cfg(test)] pub mod tests { use super::prelude::*; - use crate::{horizon_client::HorizonClient}; + use crate::horizon_client::HorizonClient; use base64::{engine::general_purpose, Engine}; #[tokio::test] @@ -125,15 +125,30 @@ pub mod tests { assert_eq!(all_ledgers_response.hash(), HASH); assert_eq!(all_ledgers_response.prev_hash(), PREV_HASH); assert_eq!(all_ledgers_response.sequence(), &SEQUENCE); - assert_eq!(all_ledgers_response.successful_transaction_count(), &SUCCESSFUL_TRANSACTION_COUNT); - assert_eq!(all_ledgers_response.failed_transaction_count(), &FAILED_TRANSACTION_COUNT); + assert_eq!( + all_ledgers_response.successful_transaction_count(), + &SUCCESSFUL_TRANSACTION_COUNT + ); + assert_eq!( + all_ledgers_response.failed_transaction_count(), + &FAILED_TRANSACTION_COUNT + ); assert_eq!(all_ledgers_response.operation_count(), &OPERATION_COUNT); - assert_eq!(all_ledgers_response.tx_set_operation_count(), &TX_SET_OPERATION_COUNT); + assert_eq!( + all_ledgers_response.tx_set_operation_count(), + &TX_SET_OPERATION_COUNT + ); assert_eq!(all_ledgers_response.closed_at(), CLOSED_AT); assert_eq!(all_ledgers_response.total_coins(), TOTAL_COINS); assert_eq!(all_ledgers_response.fee_pool(), FEE_POOL); - assert_eq!(all_ledgers_response.base_fee_in_stroops(), &BASE_FEE_IN_STROOPS); - assert_eq!(all_ledgers_response.base_reserve_in_stroops(), &BASE_RESERVE_IN_STROOPS); + assert_eq!( + all_ledgers_response.base_fee_in_stroops(), + &BASE_FEE_IN_STROOPS + ); + assert_eq!( + all_ledgers_response.base_reserve_in_stroops(), + &BASE_RESERVE_IN_STROOPS + ); assert_eq!(all_ledgers_response.max_tx_set_size(), &MAX_TX_SET_SIZE); assert_eq!(all_ledgers_response.protocol_version(), &PROTOCOL_VERSION); } @@ -145,10 +160,10 @@ pub mod tests { static HASH: &str = "546c5bccad35413e75324e0e63dd4d9f1ba87a3f4c97c84f83b7c09150f61caa"; static PREV_HASH: &str = "63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99"; static SEQUENCE: &i32 = &2; - static SUCCESSFUL_TRANSACTION_COUNT: &i32 = &0; - static FAILED_TRANSACTION_COUNT: &i32 = &0; - static OPERATION_COUNT: &i32 = &0; - static TX_SET_OPERATION_COUNT: &i32 = &0; + static SUCCESSFUL_TRANSACTION_COUNT: &i32 = &0; + static FAILED_TRANSACTION_COUNT: &i32 = &0; + static OPERATION_COUNT: &i32 = &0; + static TX_SET_OPERATION_COUNT: &i32 = &0; static CLOSED_AT: &str = "2024-06-11T20:49:11Z"; static TOTAL_COINS: &str = "100000000000.0000000"; static FEE_POOL: &str = "0.0000000"; @@ -178,15 +193,30 @@ pub mod tests { assert_eq!(single_ledger_response.hash(), HASH); assert_eq!(single_ledger_response.prev_hash(), PREV_HASH); assert_eq!(single_ledger_response.sequence(), SEQUENCE); - assert_eq!(single_ledger_response.successful_transaction_count(), SUCCESSFUL_TRANSACTION_COUNT); - assert_eq!(single_ledger_response.failed_transaction_count(), FAILED_TRANSACTION_COUNT); + assert_eq!( + single_ledger_response.successful_transaction_count(), + SUCCESSFUL_TRANSACTION_COUNT + ); + assert_eq!( + single_ledger_response.failed_transaction_count(), + FAILED_TRANSACTION_COUNT + ); assert_eq!(single_ledger_response.operation_count(), OPERATION_COUNT); - assert_eq!(single_ledger_response.tx_set_operation_count(), TX_SET_OPERATION_COUNT); + assert_eq!( + single_ledger_response.tx_set_operation_count(), + TX_SET_OPERATION_COUNT + ); assert_eq!(single_ledger_response.closed_at(), CLOSED_AT); assert_eq!(single_ledger_response.total_coins(), TOTAL_COINS); assert_eq!(single_ledger_response.fee_pool(), FEE_POOL); - assert_eq!(single_ledger_response.base_fee_in_stroops(), BASE_FEE_IN_STROOPS); - assert_eq!(single_ledger_response.base_reserve_in_stroops(), BASE_RESERVE_IN_STROOPS); + assert_eq!( + single_ledger_response.base_fee_in_stroops(), + BASE_FEE_IN_STROOPS + ); + assert_eq!( + single_ledger_response.base_reserve_in_stroops(), + BASE_RESERVE_IN_STROOPS + ); assert_eq!(single_ledger_response.max_tx_set_size(), MAX_TX_SET_SIZE); assert_eq!(single_ledger_response.protocol_version(), PROTOCOL_VERSION); diff --git a/stellar_rust_sdk/src/lib.rs b/stellar_rust_sdk/src/lib.rs index 6964690..c67d593 100644 --- a/stellar_rust_sdk/src/lib.rs +++ b/stellar_rust_sdk/src/lib.rs @@ -461,30 +461,30 @@ pub mod offers; pub mod operations; /// Provides `Request` and `Response` structs for retrieving order book details. -/// +/// /// The `order_book` module in the Stellar Horizon SDK includes structures and methods that facilitate /// querying order book data from the Horizon server. -/// +/// /// # Usage -/// +/// /// This module is used to construct requests for order book-related data and to parse the responses /// received from the Horizon server. It includes request and response structures for querying /// order book details. -/// +/// /// # Example -/// +/// /// To use this module, you can create an instance of a request struct, such as `DetailsRequest`, /// set any desired query parameters, and pass the request to the `HorizonClient`. The client will /// then execute the request and return the corresponding response struct, like `DetailsResponse`. -/// +/// /// ```rust /// use stellar_rs::horizon_client::HorizonClient; /// use stellar_rs::order_book::prelude::*; /// use stellar_rs::models::Request; -/// +/// /// # async fn example() -> Result<(), Box> { /// let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org".to_string())?; -/// +/// /// // Example: Fetching order book details /// let details_request = DetailsRequest::new() /// .set_buying_asset(AssetType::Native)? @@ -493,12 +493,12 @@ pub mod operations; /// asset_issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5".to_string(), /// }))?; /// let details_response = horizon_client.get_order_book_details(&details_request).await?; -/// +/// /// // Process the response... /// # Ok(()) /// # } /// ``` -/// +/// pub mod order_book; /// Provides `Request` and `Response` structs for retrieving trade aggregation details. @@ -730,4 +730,4 @@ impl BuildQueryParametersExt> for Vec> { false => format!("?{}", params), } } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs b/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs index 9a3c788..66c6b3c 100644 --- a/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs +++ b/stellar_rust_sdk/src/liquidity_pools/all_liquidity_pools_request.rs @@ -1,4 +1,7 @@ -use crate::{models::{Order, Request}, BuildQueryParametersExt}; +use crate::{ + models::{Order, Request}, + BuildQueryParametersExt, +}; use stellar_rust_sdk_derive::pagination; /// Represents a reserve for a liquidity pool. This struct is used to specify the asset code and @@ -171,7 +174,7 @@ impl Request for AllLiquidityPoolsRequest { #[cfg(test)] mod tests { use super::*; - + #[test] fn test_new() { let request = AllLiquidityPoolsRequest::new(); @@ -195,7 +198,9 @@ mod tests { #[test] fn test_set_order() { - let request = AllLiquidityPoolsRequest::new().set_order(Order::Desc).unwrap(); + let request = AllLiquidityPoolsRequest::new() + .set_order(Order::Desc) + .unwrap(); assert_eq!(request.order, Some(Order::Desc)); } diff --git a/stellar_rust_sdk/src/liquidity_pools/mod.rs b/stellar_rust_sdk/src/liquidity_pools/mod.rs index 0ca2d3c..4d986d6 100644 --- a/stellar_rust_sdk/src/liquidity_pools/mod.rs +++ b/stellar_rust_sdk/src/liquidity_pools/mod.rs @@ -70,10 +70,9 @@ pub mod prelude { #[tokio::test] async fn test_get_all_liquidity_pools() { - use crate::{horizon_client::HorizonClient}; + use crate::horizon_client::HorizonClient; use all_liquidity_pools_request::AllLiquidityPoolsRequest; - const RSP_1_LIQUIDITY_POOL_ID: &str = "4cd1f6defba237eecbc5fefe259f89ebc4b5edd49116beb5536c4034fc48d63f"; const RSP_1_LIQUIDITY_POOL_PAGING_TOKEN: &str = @@ -229,7 +228,7 @@ async fn test_get_all_liquidity_pools() { "GAGTRBIF75N7NUA37JGGJZKXIS4JJKTQERRFWTP5DN4SM4OC2T6QPMQB".to_string(), ) .set_limit(2) - .unwrap(); + .unwrap(); let all_liquidity_pools_response_3 = horizon_client .get_all_liquidity_pools(&all_liquidity_pools_request_3) @@ -292,8 +291,7 @@ async fn test_get_single_liquidity_pool() { const LIQUIDITY_POOL_TYPE: &str = "constant_product"; const LIQUIDITY_POOL_TOTAL_TRUSTLINES: &str = "1"; const LIQUIDITY_POOL_TOTAL_SHARES: &str = "249.0000000"; - const LIQUIDITY_POOL_RESERVE_ASSET_0: &str = - "native"; + const LIQUIDITY_POOL_RESERVE_ASSET_0: &str = "native"; const LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "2939.0000000"; const LIQUIDITY_POOL_RESERVE_ASSET_1: &str = "FLUTTER:GCGTOQSNERFVVJ6Y7YZYDF3MTZIY63KIEFMKA26Q7YPV3AFYD2JSRNYN"; diff --git a/stellar_rust_sdk/src/liquidity_pools/response.rs b/stellar_rust_sdk/src/liquidity_pools/response.rs index 60cd89c..4d427c2 100644 --- a/stellar_rust_sdk/src/liquidity_pools/response.rs +++ b/stellar_rust_sdk/src/liquidity_pools/response.rs @@ -1,7 +1,10 @@ use derive_getters::Getters; use serde::{Deserialize, Serialize}; -use crate::models::{prelude::{Embedded, Link, ResponseLinks, TemplateLink}, Response}; +use crate::models::{ + prelude::{Embedded, Link, ResponseLinks, TemplateLink}, + Response, +}; /// Represents the response from the Horizon server when querying for all liquidity pools. /// @@ -95,4 +98,4 @@ impl Response for LiquidityPool { Ok(ledger_record) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs b/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs index c6b58f7..f6ebca6 100644 --- a/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs +++ b/stellar_rust_sdk/src/liquidity_pools/single_liquidity_pool_request.rs @@ -55,7 +55,6 @@ impl SingleLiquidityPoolRequest { self, liquidity_pool_id: String, ) -> Result, String> { - Ok(SingleLiquidityPoolRequest { liquidity_pool_id: LiquidityPoolId(liquidity_pool_id), }) @@ -78,4 +77,4 @@ impl Request for SingleLiquidityPoolRequest { self.get_query_parameters() ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/models/response_models.rs b/stellar_rust_sdk/src/models/response_models.rs index a151481..c3e7ebc 100644 --- a/stellar_rust_sdk/src/models/response_models.rs +++ b/stellar_rust_sdk/src/models/response_models.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; /// Represents the navigational links in a response. /// /// Contains the links to the current, next, and previous pages of the response. -/// +/// #[derive(Default, Debug, Deserialize, Serialize, Clone, Getters)] pub struct ResponseLinks { #[serde(rename = "self")] @@ -16,7 +16,7 @@ pub struct ResponseLinks { /// Represents a navigational link in a response. /// /// Contains an optional url. -/// +/// #[derive(Default, Debug, Deserialize, Serialize, Clone, Getters)] pub struct Link { pub href: Option, @@ -25,15 +25,15 @@ pub struct Link { /// Represents a navigational link in a response. /// /// Contains an optional url, and an optional boolean to indicate whether a link is templated or not. -/// +/// #[derive(Default, Debug, Deserialize, Serialize, Clone, Getters)] pub struct TemplateLink { pub href: Option, pub templated: Option, } -/// Represents a collection of results in a response. -/// +/// Represents a collection of results in a response. +/// /// Contains a vector, which can hold any type of record returned by the API. #[derive(Default, Debug, Deserialize, Serialize, Clone, Getters)] pub struct Embedded { @@ -60,4 +60,4 @@ pub struct Flags { /// A `bool` indicating whether the asset supports the clawback operation. /// If `true`, the issuer can claw back the asset from user accounts. auth_clawback_enabled: bool, -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/offers/all_offers_request.rs b/stellar_rust_sdk/src/offers/all_offers_request.rs index ffb1064..982e65c 100644 --- a/stellar_rust_sdk/src/offers/all_offers_request.rs +++ b/stellar_rust_sdk/src/offers/all_offers_request.rs @@ -133,4 +133,4 @@ impl AllOffersRequest { ..self } } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/offers/mod.rs b/stellar_rust_sdk/src/offers/mod.rs index 19b7a8e..7e611d1 100644 --- a/stellar_rust_sdk/src/offers/mod.rs +++ b/stellar_rust_sdk/src/offers/mod.rs @@ -19,8 +19,8 @@ pub mod all_offers_request; /// Provides the `OffersForAccountRequest`. /// /// This module provides the `OffersForAccountRequest` struct, specifically designed for -/// constructing requests to query information about all offers a given account has -/// currently open from the Horizon server. It is tailored for use with the +/// constructing requests to query information about all offers a given account has +/// currently open from the Horizon server. It is tailored for use with the /// [`HorizonClient::get_offers_for_account`](crate::horizon_client::HorizonClient::get_offers_for_account) method. /// pub mod offers_for_account_request; @@ -74,10 +74,10 @@ pub(crate) static OFFERS_PATH: &str = "offers"; /// ``` /// pub mod prelude { - pub use super::single_offer_request::*; pub use super::all_offers_request::*; pub use super::offers_for_account_request::*; pub use super::response::*; + pub use super::single_offer_request::*; } #[cfg(test)] @@ -94,10 +94,12 @@ pub mod test { const SELLER: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E"; const SELLING_ASSET_TYPE: &str = "credit_alphanum12"; const SELLING_ASSET_CODE: &str = "MBAUDD"; - const SELLING_ASSET_ISSUER: &str = "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U"; + const SELLING_ASSET_ISSUER: &str = + "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U"; const BUYING_ASSET_TYPE: &str = "credit_alphanum12"; const BUYING_ASSET_CODE: &str = "TMB001128"; - const BUYING_ASSET_ISSUER: &str = "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F"; + const BUYING_ASSET_ISSUER: &str = + "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F"; const AMOUNT: &str = "20081.0000000"; const PRICE_R_N: &u32 = &50; const PRICE_R_D: &u32 = &467; @@ -106,32 +108,45 @@ pub mod test { const LAST_MODIFIED_TIME: &str = "2024-08-02T08:29:11Z"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); - let single_offer_request = - SingleOfferRequest::new() + let single_offer_request = SingleOfferRequest::new() .set_offer_id(OFFER_ID.to_string()) .unwrap(); - let single_offer_response = horizon_client - .get_single_offer(&single_offer_request) - .await; + let single_offer_response = horizon_client.get_single_offer(&single_offer_request).await; assert!(single_offer_response.clone().is_ok()); let response = single_offer_response.unwrap(); - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(response.links().offer_maker().href().as_ref().unwrap(), LINK_OFFER_MAKER); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + response.links().offer_maker().href().as_ref().unwrap(), + LINK_OFFER_MAKER + ); assert_eq!(response.id(), OFFER_ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.seller(), SELLER); assert_eq!(response.selling().asset_type(), SELLING_ASSET_TYPE); - assert_eq!(response.selling().asset_code().as_ref().unwrap(), SELLING_ASSET_CODE); - assert_eq!(response.selling().asset_issuer().as_ref().unwrap(), SELLING_ASSET_ISSUER); + assert_eq!( + response.selling().asset_code().as_ref().unwrap(), + SELLING_ASSET_CODE + ); + assert_eq!( + response.selling().asset_issuer().as_ref().unwrap(), + SELLING_ASSET_ISSUER + ); assert_eq!(response.buying().asset_type(), BUYING_ASSET_TYPE); - assert_eq!(response.buying().asset_code().as_ref().unwrap(), BUYING_ASSET_CODE); - assert_eq!(response.buying().asset_issuer().as_ref().unwrap(), BUYING_ASSET_ISSUER); + assert_eq!( + response.buying().asset_code().as_ref().unwrap(), + BUYING_ASSET_CODE + ); + assert_eq!( + response.buying().asset_issuer().as_ref().unwrap(), + BUYING_ASSET_ISSUER + ); assert_eq!(response.amount(), AMOUNT); assert_eq!(response.price_ratio().numenator(), PRICE_R_N); assert_eq!(response.price_ratio().denominator(), PRICE_R_D); @@ -150,39 +165,47 @@ pub mod test { const SELLING_ASSET_TYPE: &str = "native"; const BUYING_ASSET_TYPE: &str = "credit_alphanum12"; const BUYING_ASSET_CODE: &str = "NewDollar"; - const BUYING_ASSET_ISSUER: &str = "GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4"; + const BUYING_ASSET_ISSUER: &str = + "GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4"; const AMOUNT: &str = "10.0000000"; const PRICE_R_N: &u32 = &1; const PRICE_R_D: &u32 = &1; const PRICE: &str = "1.0000000"; const LAST_MODIFIED_LEDGER: &u32 = &5858; const LAST_MODIFIED_TIME: &str = "2024-06-12T05:23:41Z"; - + let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); // Create a request with no (optional) filters. - let all_offers_request = - AllOffersRequest::new(); + let all_offers_request = AllOffersRequest::new(); - let all_offers_response = horizon_client - .get_all_offers(&all_offers_request) - .await; + let all_offers_response = horizon_client.get_all_offers(&all_offers_request).await; assert!(all_offers_response.clone().is_ok()); let binding = all_offers_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().offer_maker().href().as_ref().unwrap(), LINK_OFFER_MAKER); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().offer_maker().href().as_ref().unwrap(), + LINK_OFFER_MAKER + ); assert_eq!(record.id(), OFFER_ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.seller(), SELLER); assert_eq!(record.selling().asset_type(), SELLING_ASSET_TYPE); assert_eq!(record.buying().asset_type(), BUYING_ASSET_TYPE); - assert_eq!(record.buying().asset_code().as_ref().unwrap(), BUYING_ASSET_CODE); - assert_eq!(record.buying().asset_issuer().as_ref().unwrap(), BUYING_ASSET_ISSUER); + assert_eq!( + record.buying().asset_code().as_ref().unwrap(), + BUYING_ASSET_CODE + ); + assert_eq!( + record.buying().asset_issuer().as_ref().unwrap(), + BUYING_ASSET_ISSUER + ); assert_eq!(record.amount(), AMOUNT); assert_eq!(record.price_ratio().numenator(), PRICE_R_N); assert_eq!(record.price_ratio().denominator(), PRICE_R_D); @@ -200,47 +223,63 @@ pub mod test { const SELLER: &str = "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO"; const SELLING_ASSET_TYPE: &str = "credit_alphanum4"; const SELLING_ASSET_CODE: &str = "EURC"; - const SELLING_ASSET_ISSUER: &str = "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO"; + const SELLING_ASSET_ISSUER: &str = + "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO"; const BUYING_ASSET_TYPE: &str = "credit_alphanum12"; const BUYING_ASSET_CODE: &str = "EURCAllow"; - const BUYING_ASSET_ISSUER: &str = "GA6HVGLFUF3BHHGR5CMYXIVZ3RYVUH5EUYAOAY4T3OKI5OQVIWVRK24R"; + const BUYING_ASSET_ISSUER: &str = + "GA6HVGLFUF3BHHGR5CMYXIVZ3RYVUH5EUYAOAY4T3OKI5OQVIWVRK24R"; const AMOUNT: &str = "922192119415.1975807"; const PRICE_R_N: &u32 = &1; const PRICE_R_D: &u32 = &1; const PRICE: &str = "1.0000000"; const LAST_MODIFIED_LEDGER: &u32 = &923809; const LAST_MODIFIED_TIME: &str = "2024-08-07T02:21:13Z"; - + let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); // Create a request and supply values for optional filters. - let all_offers_request = - AllOffersRequest::new() - .set_seller(SELLER.to_string()).unwrap() - .set_cursor(1).unwrap() - .set_limit(100).unwrap() - .set_order(Order::Asc).unwrap(); + let all_offers_request = AllOffersRequest::new() + .set_seller(SELLER.to_string()) + .unwrap() + .set_cursor(1) + .unwrap() + .set_limit(100) + .unwrap() + .set_order(Order::Asc) + .unwrap(); - let all_offers_response = horizon_client - .get_all_offers(&all_offers_request) - .await; + let all_offers_response = horizon_client.get_all_offers(&all_offers_request).await; assert!(all_offers_response.clone().is_ok()); let binding = all_offers_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().offer_maker().href().as_ref().unwrap(), LINK_OFFER_MAKER); + assert_eq!( + record.links().offer_maker().href().as_ref().unwrap(), + LINK_OFFER_MAKER + ); assert_eq!(record.id(), OFFER_ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.seller(), SELLER); assert_eq!(record.selling().asset_type(), SELLING_ASSET_TYPE); - assert_eq!(record.selling().asset_code().as_ref().unwrap(), SELLING_ASSET_CODE); - assert_eq!(record.selling().asset_issuer().as_ref().unwrap(), SELLING_ASSET_ISSUER); + assert_eq!( + record.selling().asset_code().as_ref().unwrap(), + SELLING_ASSET_CODE + ); + assert_eq!( + record.selling().asset_issuer().as_ref().unwrap(), + SELLING_ASSET_ISSUER + ); assert_eq!(record.buying().asset_type(), BUYING_ASSET_TYPE); - assert_eq!(record.buying().asset_code().as_ref().unwrap(), BUYING_ASSET_CODE); - assert_eq!(record.buying().asset_issuer().as_ref().unwrap(), BUYING_ASSET_ISSUER); + assert_eq!( + record.buying().asset_code().as_ref().unwrap(), + BUYING_ASSET_CODE + ); + assert_eq!( + record.buying().asset_issuer().as_ref().unwrap(), + BUYING_ASSET_ISSUER + ); assert_eq!(record.amount(), AMOUNT); assert_eq!(record.price_ratio().numenator(), PRICE_R_N); assert_eq!(record.price_ratio().denominator(), PRICE_R_D); @@ -259,45 +298,62 @@ pub mod test { const SELLER: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E"; const SELLING_ASSET_TYPE: &str = "credit_alphanum12"; const SELLING_ASSET_CODE: &str = "MBAUDD"; - const SELLING_ASSET_ISSUER: &str = "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U"; + const SELLING_ASSET_ISSUER: &str = + "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U"; const BUYING_ASSET_TYPE: &str = "credit_alphanum12"; const BUYING_ASSET_CODE: &str = "TMB001128"; - const BUYING_ASSET_ISSUER: &str = "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F"; + const BUYING_ASSET_ISSUER: &str = + "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F"; const AMOUNT: &str = "20081.0000000"; const PRICE_R_N: &u32 = &50; const PRICE_R_D: &u32 = &467; const PRICE: &str = "0.1070664"; const LAST_MODIFIED_LEDGER: &u32 = &845805; const LAST_MODIFIED_TIME: &str = "2024-08-02T08:29:11Z"; - + let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); - let offers_for_account_request = - OffersForAccountRequest::new() + let offers_for_account_request = OffersForAccountRequest::new() .set_account_id(ACCOUNT_ID.to_string()) .unwrap(); let offers_for_account_response = horizon_client .get_offers_for_account(&offers_for_account_request) .await; - + assert!(offers_for_account_response.clone().is_ok()); let binding = offers_for_account_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().offer_maker().href().as_ref().unwrap(), LINK_OFFER_MAKER); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().offer_maker().href().as_ref().unwrap(), + LINK_OFFER_MAKER + ); assert_eq!(record.id(), OFFER_ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.seller(), SELLER); assert_eq!(record.selling().asset_type(), SELLING_ASSET_TYPE); - assert_eq!(record.selling().asset_code().as_ref().unwrap(), SELLING_ASSET_CODE); - assert_eq!(record.selling().asset_issuer().as_ref().unwrap(), SELLING_ASSET_ISSUER); + assert_eq!( + record.selling().asset_code().as_ref().unwrap(), + SELLING_ASSET_CODE + ); + assert_eq!( + record.selling().asset_issuer().as_ref().unwrap(), + SELLING_ASSET_ISSUER + ); assert_eq!(record.buying().asset_type(), BUYING_ASSET_TYPE); - assert_eq!(record.buying().asset_code().as_ref().unwrap(), BUYING_ASSET_CODE); - assert_eq!(record.buying().asset_issuer().as_ref().unwrap(), BUYING_ASSET_ISSUER); + assert_eq!( + record.buying().asset_code().as_ref().unwrap(), + BUYING_ASSET_CODE + ); + assert_eq!( + record.buying().asset_issuer().as_ref().unwrap(), + BUYING_ASSET_ISSUER + ); assert_eq!(record.amount(), AMOUNT); assert_eq!(record.price_ratio().numenator(), PRICE_R_N); assert_eq!(record.price_ratio().denominator(), PRICE_R_D); @@ -305,4 +361,4 @@ pub mod test { assert_eq!(record.last_modified_ledger(), LAST_MODIFIED_LEDGER); assert_eq!(record.last_modified_time(), LAST_MODIFIED_TIME); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/offers/offers_for_account_request.rs b/stellar_rust_sdk/src/offers/offers_for_account_request.rs index a89f61f..15f19d7 100644 --- a/stellar_rust_sdk/src/offers/offers_for_account_request.rs +++ b/stellar_rust_sdk/src/offers/offers_for_account_request.rs @@ -31,7 +31,7 @@ impl OffersForAccountRequest { } Ok(OffersForAccountRequest { - account_id: OfferAccountId(account_id,), + account_id: OfferAccountId(account_id), cursor: self.cursor, limit: self.limit, order: self.order, @@ -60,4 +60,4 @@ impl Request for OffersForAccountRequest { super::OFFERS_PATH ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/offers/response.rs b/stellar_rust_sdk/src/offers/response.rs index 1a5fcaf..be572bd 100644 --- a/stellar_rust_sdk/src/offers/response.rs +++ b/stellar_rust_sdk/src/offers/response.rs @@ -26,7 +26,7 @@ impl Response for AllOffersResponse { /// Represents the asset to buy or to sell. /// -/// This struct details information about the asset to buy or to sell, including its type, +/// This struct details information about the asset to buy or to sell, including its type, /// code (optional) and issuer (optional). /// #[derive(Debug, Deserialize, Serialize, Clone, Getters)] @@ -109,4 +109,4 @@ impl Response for OfferResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/offers/single_offer_request.rs b/stellar_rust_sdk/src/offers/single_offer_request.rs index c575288..61a0795 100644 --- a/stellar_rust_sdk/src/offers/single_offer_request.rs +++ b/stellar_rust_sdk/src/offers/single_offer_request.rs @@ -54,15 +54,12 @@ impl SingleOfferRequest { /// # Returns /// A `SingleOfferRequest` with the specified offer ID, or an error if the offer ID is invalid. /// - pub fn set_offer_id( - self, - offer_id: String, - ) -> Result, String> { + pub fn set_offer_id(self, offer_id: String) -> Result, String> { match offer_id.parse::() { Ok(id) => { if id > 0 { Ok(SingleOfferRequest { - offer_id: OfferId(offer_id) + offer_id: OfferId(offer_id), }) } else { Err("offer ID must be greater than or equal to 1".to_string()) @@ -91,4 +88,4 @@ impl Request for SingleOfferRequest { self.get_query_parameters() ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/operations/mod.rs b/stellar_rust_sdk/src/operations/mod.rs index d930e0c..c3ddf1f 100644 --- a/stellar_rust_sdk/src/operations/mod.rs +++ b/stellar_rust_sdk/src/operations/mod.rs @@ -126,10 +126,9 @@ pub mod tests { operations::{ operations_for_account_request::OperationsForAccountRequest, prelude::{ - AllOperationsRequest, - OperationsForLedgerRequest, - OperationsForLiquidityPoolRequest, - OperationsForTransactionRequest, }, + AllOperationsRequest, OperationsForLedgerRequest, + OperationsForLiquidityPoolRequest, OperationsForTransactionRequest, + }, response::{Operation, OperationResponse}, single_operation_request::SingleOperationRequest, }, @@ -151,8 +150,7 @@ pub mod tests { const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let all_operations_request = AllOperationsRequest::new().set_limit(2).unwrap(); @@ -197,8 +195,7 @@ pub mod tests { const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let single_operation_request = SingleOperationRequest::new().set_operation_id(ID.to_string()); @@ -241,8 +238,7 @@ pub mod tests { const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let operations_for_account_request = OperationsForAccountRequest::new() .set_account_id(ACCOUNT_ID.to_string()) @@ -301,8 +297,7 @@ pub mod tests { const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let operations_for_ledger_request = OperationsForLedgerRequest::new().set_limit(2).unwrap(); @@ -356,8 +351,7 @@ pub mod tests { const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let operations_for_liquidity_pool_request = OperationsForLiquidityPoolRequest::new() .set_limit(2) @@ -405,7 +399,8 @@ pub mod tests { #[tokio::test] async fn test_get_operations_for_transaction() { - const REQUEST_TRANSACTION_HASH: &str = "b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020"; + const REQUEST_TRANSACTION_HASH: &str = + "b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020"; const ID: &str = "2314987376641"; const PAGING_TOKEN: &str = "2314987376641"; const TRANSACTION_SUCCESFULL: bool = true; @@ -419,8 +414,8 @@ pub mod tests { const FUNDER: &str = "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"; const ACCOUNT: &str = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"; - let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org".to_string()) - .unwrap(); + let horizon_client = + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let operations_for_transaction_request = OperationsForTransactionRequest::new() .set_transaction_hash(REQUEST_TRANSACTION_HASH.to_string()) diff --git a/stellar_rust_sdk/src/operations/operations_for_account_request.rs b/stellar_rust_sdk/src/operations/operations_for_account_request.rs index be4c506..89ab8cf 100644 --- a/stellar_rust_sdk/src/operations/operations_for_account_request.rs +++ b/stellar_rust_sdk/src/operations/operations_for_account_request.rs @@ -13,7 +13,6 @@ pub struct OperationsForAccountRequest { include_failed: Option, } - impl OperationsForAccountRequest { pub fn new() -> Self { OperationsForAccountRequest::default() diff --git a/stellar_rust_sdk/src/operations/operations_for_ledger_request.rs b/stellar_rust_sdk/src/operations/operations_for_ledger_request.rs index 8d8e163..5c8fb34 100644 --- a/stellar_rust_sdk/src/operations/operations_for_ledger_request.rs +++ b/stellar_rust_sdk/src/operations/operations_for_ledger_request.rs @@ -1,8 +1,8 @@ -use stellar_rust_sdk_derive::pagination; use crate::{ models::{IncludeFailed, Order, Request}, BuildQueryParametersExt, }; +use stellar_rust_sdk_derive::pagination; #[pagination] #[derive(Default)] diff --git a/stellar_rust_sdk/src/operations/operations_for_liquidity_pool_request.rs b/stellar_rust_sdk/src/operations/operations_for_liquidity_pool_request.rs index 7ee2b45..1ac219f 100644 --- a/stellar_rust_sdk/src/operations/operations_for_liquidity_pool_request.rs +++ b/stellar_rust_sdk/src/operations/operations_for_liquidity_pool_request.rs @@ -1,8 +1,8 @@ -use stellar_rust_sdk_derive::pagination; use crate::{ models::{IncludeFailed, Order, Request}, BuildQueryParametersExt, }; +use stellar_rust_sdk_derive::pagination; #[pagination] #[derive(Default)] @@ -38,7 +38,10 @@ impl OperationsForLiquidityPoolRequest { /// # Arguments /// * `account_id` - A `String` representing the account ID. /// - pub fn set_liquidity_pool_id(self, liquidity_pool_id: String) -> OperationsForLiquidityPoolRequest { + pub fn set_liquidity_pool_id( + self, + liquidity_pool_id: String, + ) -> OperationsForLiquidityPoolRequest { OperationsForLiquidityPoolRequest { liquidity_pool_id: Some(liquidity_pool_id), ..self diff --git a/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs b/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs index efe4d42..75d30ef 100644 --- a/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs +++ b/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs @@ -74,4 +74,4 @@ mod tests { "?cursor=1&limit=10&order=desc" ); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/operations/response.rs b/stellar_rust_sdk/src/operations/response.rs index d2002ac..e6883e1 100644 --- a/stellar_rust_sdk/src/operations/response.rs +++ b/stellar_rust_sdk/src/operations/response.rs @@ -53,7 +53,6 @@ pub struct OperationLinks { impl Response for OperationResponse { fn from_json(json: String) -> Result { - let operation_record = serde_json::from_str(&json).map_err(|e| e.to_string())?; Ok(operation_record) @@ -62,7 +61,6 @@ impl Response for OperationResponse { impl Response for Operation { fn from_json(json: String) -> Result { - let operation_record = serde_json::from_str(&json).map_err(|e| e.to_string())?; Ok(operation_record) diff --git a/stellar_rust_sdk/src/operations/single_operation_request.rs b/stellar_rust_sdk/src/operations/single_operation_request.rs index bccaeb1..ecdda8e 100644 --- a/stellar_rust_sdk/src/operations/single_operation_request.rs +++ b/stellar_rust_sdk/src/operations/single_operation_request.rs @@ -8,16 +8,16 @@ pub struct OperationId(pub String); pub struct NoOperationId; /// Represents a request to fetch details of a single operation from the Horizon API. -/// +/// /// `SingleOperationRequest` is a struct tailored to querying details of a specific operation /// on the Horizon API. This struct is designed to be used in conjunction with the /// [`HorizonClient::get_single_operation`](crate::horizon_client::HorizonClient::get_single_operation) method. -/// +/// /// # Fields /// Required: /// * `operation_id` - The ID of the operation. -/// -/// ## Usage +/// +/// ## Usage /// Instances of `SingleOperationRequest` are created and configured using setter methods for each /// parameter. /// ``` @@ -27,7 +27,7 @@ pub struct NoOperationId; /// .set_operation_id("123456".to_string()); /// // Use with HorizonClient::get_single_operation /// ``` -/// +/// #[derive(Default, Clone)] pub struct SingleOperationRequest { /// The ID of the operation. @@ -41,10 +41,10 @@ impl SingleOperationRequest { } /// Sets the operation ID for the request. - /// + /// /// # Arguments /// * `operation_id` - A `String` specifying the operation ID. - /// + /// pub fn set_operation_id(self, operation_id: String) -> SingleOperationRequest { SingleOperationRequest { operation_id: OperationId(operation_id), diff --git a/stellar_rust_sdk/src/order_book/details_request.rs b/stellar_rust_sdk/src/order_book/details_request.rs index dc9e16c..9e04594 100644 --- a/stellar_rust_sdk/src/order_book/details_request.rs +++ b/stellar_rust_sdk/src/order_book/details_request.rs @@ -40,10 +40,10 @@ impl DetailsRequest { } /// Sets the selling asset of the order book. - /// + /// /// # Arguments /// * `selling_asset` - An [`AssetType`] enum value specifying the selling asset. - /// + /// pub fn set_selling_asset( self, selling_asset: AssetType, @@ -55,7 +55,7 @@ impl DetailsRequest { } /// Sets the buying asset of the order book. - /// + /// /// # Arguments /// * `buying_asset` - An [`AssetType`] enum value specifying the buying asset. pub fn set_buying_asset( @@ -71,9 +71,8 @@ impl DetailsRequest { /// Implements the setting of a selling asset of the order book with a buying asset and no selling asset impl DetailsRequest { - /// Sets the selling asset of the order book. - /// + /// /// # Arguments /// * `selling_asset` - An [`AssetType`] enum value specifying the selling asset. pub fn set_selling_asset( @@ -89,9 +88,8 @@ impl DetailsRequest { /// Implements the setting of a buying asset of the order book with a selling asset and no buying asset impl DetailsRequest { - /// Sets the buying asset of the order book. - /// + /// /// # Arguments /// * `buying_asset` - An [`AssetType`] enum value specifying the buying asset. pub fn set_buying_asset( @@ -155,11 +153,11 @@ impl Request for DetailsRequest { } mod tests { - + #[test] fn test_details_request() { - use crate::models::Request; use super::{Asset, AssetType, DetailsRequest}; + use crate::models::Request; let details_request = DetailsRequest::new() .set_buying_asset(AssetType::Native) .unwrap() @@ -176,7 +174,8 @@ mod tests { .unwrap() .set_selling_asset(AssetType::Alphanumeric4(Asset { asset_code: "USDC".to_string(), - asset_issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5".to_string(), + asset_issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5" + .to_string(), })) .unwrap(); diff --git a/stellar_rust_sdk/src/order_book/mod.rs b/stellar_rust_sdk/src/order_book/mod.rs index 7e7cb7f..03a68a2 100644 --- a/stellar_rust_sdk/src/order_book/mod.rs +++ b/stellar_rust_sdk/src/order_book/mod.rs @@ -64,14 +64,8 @@ pub mod tests { binding.base().asset_type().as_deref(), Some(BASE_ASSET_TYPE) ); - assert_eq!( - binding.base().asset_code().as_deref(), - None - ); - assert_eq!( - binding.base().asset_issuer().as_deref(), - None - ); + assert_eq!(binding.base().asset_code().as_deref(), None); + assert_eq!(binding.base().asset_issuer().as_deref(), None); assert_eq!( binding.counter().asset_type().as_deref(), diff --git a/stellar_rust_sdk/src/order_book/response.rs b/stellar_rust_sdk/src/order_book/response.rs index f9cd4b3..62bb4d9 100644 --- a/stellar_rust_sdk/src/order_book/response.rs +++ b/stellar_rust_sdk/src/order_book/response.rs @@ -95,4 +95,3 @@ impl Response for DetailsResponse { Ok(operation_record) } } - diff --git a/stellar_rust_sdk/src/payments/all_payments_request.rs b/stellar_rust_sdk/src/payments/all_payments_request.rs index fd33e55..be2c537 100644 --- a/stellar_rust_sdk/src/payments/all_payments_request.rs +++ b/stellar_rust_sdk/src/payments/all_payments_request.rs @@ -26,7 +26,7 @@ impl Request for AllPaymentsRequest { self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), ] - .build_query_parameters() + .build_query_parameters() } fn build_url(&self, base_url: &str) -> String { diff --git a/stellar_rust_sdk/src/payments/mod.rs b/stellar_rust_sdk/src/payments/mod.rs index b2250f2..00b13a0 100644 --- a/stellar_rust_sdk/src/payments/mod.rs +++ b/stellar_rust_sdk/src/payments/mod.rs @@ -1,20 +1,20 @@ /// Provides the `AllPaymentsRequest` struct to build the request for the `/payments` endpoint -/// +/// /// # Usage /// This module provides the `AllPaymentsRequest` struct, specifically for constructing requests to query information /// about all payments made on the Stellar network. It is tailored for use in the `HorizonClient::get_all_payments` function. pub mod all_payments_request; /// Provides the `PaymentsForAccountRequest` struct to build the request for the `/accounts/{account_id}/payments` endpoint -/// +/// /// # Usage /// This module provides the `PaymentsForAccountRequest` struct, specifically for constructing requests to query information /// about payments made to a specific account on the Stellar network. It is tailored for use in the `HorizonClient::get_payments_for_account` function. -/// +/// pub mod payments_for_account_request; /// Provides the `PaymentsForLedgerRequest` struct to build the request for the `/ledgers/{ledger_sequence}/payments` endpoint -/// +/// /// # Usage /// This module provides the `PaymentsForLedgerRequest` struct, specifically for constructing requests to query information /// about payments made in a specific ledger on the Stellar network. It is tailored for use in the `HorizonClient::get_payments_for_ledger` function. @@ -22,25 +22,25 @@ pub mod payments_for_account_request; pub mod payments_for_ledger_request; /// Provides the `PaymentsForTransactionRequest` struct to build the request for the `/transactions/{transaction_hash}/payments` endpoint -/// +/// /// # Usage /// This module provides the `PaymentsForTransactionRequest` struct, specifically for constructing requests to query information /// about payments made in a specific transaction on the Stellar network. It is tailored for use in the `HorizonClient::get_payments_for_transaction` function. -/// +/// pub mod payments_for_transaction_request; /// Provides the `PaymentsResponse` struct to parse the response from the Horizon server when querying for payments -/// +/// /// This module defines structures representing the response from the Horizon API when querying /// for payments. The structures are designed to deserialize the JSON response into Rust /// objects, enabling straightforward access to various details of a single transaction. /// Some fields are optional because not every payment response is exactly alike, but not different enough to warrent /// different response structs for each type of payment. -/// +/// /// # Usage /// This module provides the `PaymentsResponse` struct, which represents the response from the Horizon server when querying for payments. /// It includes the links to the current, next, and previous pages of the response, as well as the embedded records of payments. -/// +/// pub mod response; static PAYMENTS_PATH: &str = "payments"; diff --git a/stellar_rust_sdk/src/payments/payments_for_account_request.rs b/stellar_rust_sdk/src/payments/payments_for_account_request.rs index 4bdda80..5995949 100644 --- a/stellar_rust_sdk/src/payments/payments_for_account_request.rs +++ b/stellar_rust_sdk/src/payments/payments_for_account_request.rs @@ -52,12 +52,14 @@ impl PaymentsForAccountRequest { impl Request for PaymentsForAccountRequest { fn get_query_parameters(&self) -> String { vec![ - self.include_failed.as_ref().map(|s| format!("include_failed={}", s)), + self.include_failed + .as_ref() + .map(|s| format!("include_failed={}", s)), self.cursor.as_ref().map(|c| format!("cursor={}", c)), self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), ] - .build_query_parameters() + .build_query_parameters() } fn build_url(&self, base_url: &str) -> String { diff --git a/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs b/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs index 8fd0ad1..1266f6d 100644 --- a/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs +++ b/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs @@ -48,11 +48,14 @@ impl PaymentsForLedgerRequest { impl Request for PaymentsForLedgerRequest { fn get_query_parameters(&self) -> String { vec![ - self.include_failed.as_ref().map(|s| format!("include_failed={}", s)), + self.include_failed + .as_ref() + .map(|s| format!("include_failed={}", s)), self.cursor.as_ref().map(|c| format!("cursor={}", c)), self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), - ].build_query_parameters() + ] + .build_query_parameters() } fn build_url(&self, base_url: &str) -> String { diff --git a/stellar_rust_sdk/src/payments/payments_for_transaction_request.rs b/stellar_rust_sdk/src/payments/payments_for_transaction_request.rs index 2d10392..df5fd6e 100644 --- a/stellar_rust_sdk/src/payments/payments_for_transaction_request.rs +++ b/stellar_rust_sdk/src/payments/payments_for_transaction_request.rs @@ -42,7 +42,7 @@ impl Request for PaymentsForTransactionRequest { self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), ] - .build_query_parameters() + .build_query_parameters() } fn build_url(&self, base_url: &str) -> String { diff --git a/stellar_rust_sdk/src/payments/response.rs b/stellar_rust_sdk/src/payments/response.rs index ab599cc..06fd64b 100644 --- a/stellar_rust_sdk/src/payments/response.rs +++ b/stellar_rust_sdk/src/payments/response.rs @@ -1,7 +1,7 @@ -use derive_getters::Getters; -use serde::{Deserialize, Serialize}; use crate::models::prelude::{Embedded, ResponseLinks}; use crate::models::Response; +use derive_getters::Getters; +use serde::{Deserialize, Serialize}; /// Represents the response from the Horizon server when querying for all payments. /// @@ -49,4 +49,4 @@ impl Response for PaymentsResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trade_aggregations/mod.rs b/stellar_rust_sdk/src/trade_aggregations/mod.rs index 68eaf91..b09da6f 100644 --- a/stellar_rust_sdk/src/trade_aggregations/mod.rs +++ b/stellar_rust_sdk/src/trade_aggregations/mod.rs @@ -55,13 +55,13 @@ static TRADE_AGGREGATIONS_PATH: &str = "trade_aggregations"; /// ``` /// pub mod prelude { - pub use super::trade_aggregations_request::*; pub use super::response::*; + pub use super::trade_aggregations_request::*; } #[cfg(test)] pub mod test { - use crate::{trade_aggregations::prelude::*, horizon_client::HorizonClient}; + use crate::{horizon_client::HorizonClient, trade_aggregations::prelude::*}; // Request constants. const BASE_ASSET_ACCOUNT: &str = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; @@ -92,14 +92,16 @@ pub mod test { async fn test_set_offset() { // Create the base of a valid request which can be cloned by the individual tests. let request = TradeAggregationsRequest::new() - .set_base_asset(AssetType::Alphanumeric4(AssetData{ - asset_issuer: BASE_ASSET_ACCOUNT.to_string(), - asset_code: BASE_ASSET_CODE.to_string()})) - .unwrap() - .set_counter_asset(AssetType::Alphanumeric4(AssetData{ - asset_issuer: COUNTER_ASSET_ACCOUNT.to_string(), - asset_code: COUNTER_ASSET_CODE.to_string()})) - .unwrap(); + .set_base_asset(AssetType::Alphanumeric4(AssetData { + asset_issuer: BASE_ASSET_ACCOUNT.to_string(), + asset_code: BASE_ASSET_CODE.to_string(), + })) + .unwrap() + .set_counter_asset(AssetType::Alphanumeric4(AssetData { + asset_issuer: COUNTER_ASSET_ACCOUNT.to_string(), + asset_code: COUNTER_ASSET_CODE.to_string(), + })) + .unwrap(); // Check if an error is returned when trying to set an offset, when the resolution is smaller than an hour. let result = request @@ -108,7 +110,10 @@ pub mod test { .unwrap() .set_offset(60000); assert!(result.is_err()); - assert_eq!(result.unwrap_err(), "Resolution must be greater than 1 hour when setting offset."); + assert_eq!( + result.unwrap_err(), + "Resolution must be greater than 1 hour when setting offset." + ); // Check if an error is returned when passing unwhole hours in milliseconds. let result = request @@ -126,7 +131,10 @@ pub mod test { .unwrap() .set_offset(7200000); // 2 hours assert!(result.is_err()); - assert_eq!(result.unwrap_err(), "Offset must be smaller than the resolution."); + assert_eq!( + result.unwrap_err(), + "Offset must be smaller than the resolution." + ); // Check if an error is returned if the offset is greater than 24 hours. let result = request @@ -141,18 +149,18 @@ pub mod test { #[tokio::test] async fn test_get_trade_aggregations() { let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let trade_aggregations_request = TradeAggregationsRequest::new() - .set_base_asset(AssetType::Alphanumeric4(AssetData{ + .set_base_asset(AssetType::Alphanumeric4(AssetData { asset_issuer: BASE_ASSET_ACCOUNT.to_string(), - asset_code: BASE_ASSET_CODE.to_string()})) + asset_code: BASE_ASSET_CODE.to_string(), + })) .unwrap() - .set_counter_asset(AssetType::Alphanumeric4(AssetData{ + .set_counter_asset(AssetType::Alphanumeric4(AssetData { asset_issuer: COUNTER_ASSET_ACCOUNT.to_string(), - asset_code: COUNTER_ASSET_CODE.to_string()})) + asset_code: COUNTER_ASSET_CODE.to_string(), + })) .unwrap() .set_resolution(Resolution(ResolutionData::Duration604800000)) .unwrap(); @@ -193,13 +201,15 @@ pub mod test { // Test 2 different, non-native, asset types. let request = TradeAggregationsRequest::new() - .set_base_asset(AssetType::Alphanumeric4(AssetData{ + .set_base_asset(AssetType::Alphanumeric4(AssetData { asset_issuer: "baseissuer".to_string(), - asset_code: "basecode".to_string()})) - .unwrap() - .set_counter_asset(AssetType::Alphanumeric12(AssetData{ + asset_code: "basecode".to_string(), + })) + .unwrap() + .set_counter_asset(AssetType::Alphanumeric12(AssetData { asset_issuer: "counterissuer".to_string(), - asset_code: "countercode".to_string()})) + asset_code: "countercode".to_string(), + })) .unwrap() .set_resolution(Resolution(ResolutionData::Duration604800000)) .unwrap(); @@ -211,9 +221,10 @@ pub mod test { let request = TradeAggregationsRequest::new() .set_counter_asset(AssetType::Native) .unwrap() - .set_base_asset(AssetType::Alphanumeric12(AssetData{ + .set_base_asset(AssetType::Alphanumeric12(AssetData { asset_issuer: "counterissuer".to_string(), - asset_code: "countercode".to_string()})) + asset_code: "countercode".to_string(), + })) .unwrap() .set_resolution(Resolution(ResolutionData::Duration604800000)) .unwrap(); @@ -223,9 +234,10 @@ pub mod test { // Test 1 non-native, 1 native asset type. let request = TradeAggregationsRequest::new() - .set_base_asset(AssetType::Alphanumeric4(AssetData{ + .set_base_asset(AssetType::Alphanumeric4(AssetData { asset_issuer: "counterissuer".to_string(), - asset_code: "countercode".to_string()})) + asset_code: "countercode".to_string(), + })) .unwrap() .set_resolution(Resolution(ResolutionData::Duration604800000)) .unwrap() @@ -243,8 +255,9 @@ pub mod test { .unwrap() .set_counter_asset(AssetType::Native) .unwrap(); - assert_eq!(request.get_query_parameters(), + assert_eq!( + request.get_query_parameters(), "?base_asset_type=native&counter_asset_type=native&resolution=604800000" ); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trade_aggregations/response.rs b/stellar_rust_sdk/src/trade_aggregations/response.rs index bcccf81..f0801d9 100644 --- a/stellar_rust_sdk/src/trade_aggregations/response.rs +++ b/stellar_rust_sdk/src/trade_aggregations/response.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; /// Represents the response for the trade aggregations query in the Horizon API. /// /// This struct defines the overall structure of the response for a trade aggregations query. -/// It includes navigational links and embedded results. +/// It includes navigational links and embedded results. /// #[derive(Debug, Clone, Serialize, Deserialize, Getters)] pub struct AllTradeAggregationsResponse { @@ -81,4 +81,4 @@ impl Response for TradeAggregationResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trade_aggregations/trade_aggregations_request.rs b/stellar_rust_sdk/src/trade_aggregations/trade_aggregations_request.rs index be835f4..da57641 100644 --- a/stellar_rust_sdk/src/trade_aggregations/trade_aggregations_request.rs +++ b/stellar_rust_sdk/src/trade_aggregations/trade_aggregations_request.rs @@ -9,7 +9,7 @@ pub struct BaseAsset(AssetType); pub struct NoBaseAsset; /// Represents the counter asset. Contains an enum of one of the possible asset types. -#[derive(Clone,PartialEq, Debug)] +#[derive(Clone, PartialEq, Debug)] pub struct CounterAsset(AssetType); /// Represents the absence of a counter asset. @@ -43,7 +43,7 @@ pub struct NoResolution; #[derive(PartialEq, Debug, Default, Clone)] pub struct Resolution(pub ResolutionData); -/// Represents the supported segment duration times in milliseconds. +/// Represents the supported segment duration times in milliseconds. #[derive(PartialEq, Debug, Default, Clone)] pub enum ResolutionData { #[default] @@ -70,7 +70,7 @@ impl std::fmt::Display for ResolutionData { /// /// This structure is used to construct a query to retrieve a comprehensive list of trade aggregations, which will be filtered /// by the mandatory base asset, counter asset and resolution fields. Additional filters such as start time, end time, limit -/// and order can be set. It adheres to the structure and parameters required by the Horizon API for retrieving a +/// and order can be set. It adheres to the structure and parameters required by the Horizon API for retrieving a /// list of trade aggregations. /// /// # Usage @@ -226,10 +226,7 @@ impl TradeAggregationsRequest { /// * `start_time` - The lower time boundary represented as milliseconds since epoch. /// pub fn set_start_time(self, start_time: Option) -> Result { - Ok(Self { - start_time, - ..self - }) + Ok(Self { start_time, ..self }) } /// Specifies the end time in the request. @@ -239,10 +236,7 @@ impl TradeAggregationsRequest { /// * `end_time` - The upper time boundary represented as milliseconds since epoch. /// pub fn set_end_time(self, end_time: Option) -> Result { - Ok(Self { - end_time, - ..self - }) + Ok(Self { end_time, ..self }) } /// Specifies the maximum number of records to be returned. @@ -256,7 +250,10 @@ impl TradeAggregationsRequest { if !(1..=200).contains(&limit) { Err("Limit must be between 1 and 200.".to_string()) } else { - Ok(Self { limit: Some(limit), ..self }) + Ok(Self { + limit: Some(limit), + ..self + }) } } @@ -268,22 +265,25 @@ impl TradeAggregationsRequest { /// pub fn set_order(self, order: Order) -> Result { // No validation required for setting the order in this context - Ok(Self { order: Some(order), ..self }) + Ok(Self { + order: Some(order), + ..self + }) } } -impl TradeAggregationsRequest { +impl TradeAggregationsRequest { /// Sets the `offset` field in the request. /// - /// Can only be used if the resolution is greater than 1 hour. Offset value must be in whole hours, + /// Can only be used if the resolution is greater than 1 hour. Offset value must be in whole hours, /// smaller than the provided resolution, and smaller than 24 hours. These conditions are first - /// checked before setting the offset field of the struct. Can only be set if the `resolution` + /// checked before setting the offset field of the struct. Can only be set if the `resolution` /// field has been set. /// /// # Arguments /// /// * `offset` - The offset represented as milliseconds. Note: although the `offset` field in the - /// [`TradeAggregationsRequest`] struct is of the type `String`, the `offset` argument is + /// [`TradeAggregationsRequest`] struct is of the type `String`, the `offset` argument is /// of the type `u64` as a part of the condition check. /// /// # Returns @@ -293,20 +293,24 @@ impl TradeAggregationsRequest { pub fn set_offset(self, offset: u64) -> Result { const ONE_HOUR: &u64 = &360000; const ONE_DAY: &u64 = &86400000; - let resolution = format!("{}", &self.resolution.0) - .parse::() - .unwrap(); + let resolution = format!("{}", &self.resolution.0).parse::().unwrap(); let conditions = [ - (&resolution < ONE_HOUR, "Resolution must be greater than 1 hour when setting offset."), + ( + &resolution < ONE_HOUR, + "Resolution must be greater than 1 hour when setting offset.", + ), (&offset % ONE_HOUR != 0, "Offset must be in whole hours."), - (&offset > &resolution, "Offset must be smaller than the resolution."), + ( + &offset > &resolution, + "Offset must be smaller than the resolution.", + ), (&offset > ONE_DAY, "Offset must be smaller than 24 hours."), ]; for (condition, message) in conditions { if condition { - return Err(message.to_string()) + return Err(message.to_string()); } } @@ -319,43 +323,62 @@ impl TradeAggregationsRequest { impl Request for TradeAggregationsRequest { fn get_query_parameters(&self) -> String { - let asset_parameters = - vec![&self.base_asset.0, &self.counter_asset.0] - .iter() - .enumerate() - .fold(Vec::new(), |mut parameters, (i, asset)| { - let asset_type_prefix = if i == 0 { "base_asset_type=" } // no `&` for `base_asset_type`, as the query begins with `?` - else { "&counter_asset_type=" }; - match asset { - AssetType::Native => parameters.push(format!("{}native", asset_type_prefix)), - AssetType::Alphanumeric4(asset_data) | AssetType::Alphanumeric12(asset_data) => { - let asset_type = match asset { - AssetType::Alphanumeric4(_) => "credit_alphanum4", - AssetType::Alphanumeric12(_) => "credit_alphanum12", - _ => "", // should not be reached - }; - let asset_issuer_prefix = if i == 0 { "&base_asset_issuer=" } else { "&counter_asset_issuer=" }; - let asset_code_prefix = if i == 0 { "&base_asset_code=" } else { "&counter_asset_code=" }; - parameters.push(format!( - "{}{}{}{}{}{}", - asset_type_prefix, asset_type, - asset_code_prefix, asset_data.asset_code, - asset_issuer_prefix, asset_data.asset_issuer - )); - } + let asset_parameters = vec![&self.base_asset.0, &self.counter_asset.0] + .iter() + .enumerate() + .fold(Vec::new(), |mut parameters, (i, asset)| { + let asset_type_prefix = if i == 0 { + "base_asset_type=" + } + // no `&` for `base_asset_type`, as the query begins with `?` + else { + "&counter_asset_type=" + }; + match asset { + AssetType::Native => parameters.push(format!("{}native", asset_type_prefix)), + AssetType::Alphanumeric4(asset_data) + | AssetType::Alphanumeric12(asset_data) => { + let asset_type = match asset { + AssetType::Alphanumeric4(_) => "credit_alphanum4", + AssetType::Alphanumeric12(_) => "credit_alphanum12", + _ => "", // should not be reached + }; + let asset_issuer_prefix = if i == 0 { + "&base_asset_issuer=" + } else { + "&counter_asset_issuer=" + }; + let asset_code_prefix = if i == 0 { + "&base_asset_code=" + } else { + "&counter_asset_code=" + }; + parameters.push(format!( + "{}{}{}{}{}{}", + asset_type_prefix, + asset_type, + asset_code_prefix, + asset_data.asset_code, + asset_issuer_prefix, + asset_data.asset_issuer + )); } - parameters - }) + } + parameters + }) .join(""); vec![ Some(asset_parameters), Some(format!("resolution={}", self.resolution.0)), - self.start_time.as_ref().map(|s| format!("start_time={}", s)), + self.start_time + .as_ref() + .map(|s| format!("start_time={}", s)), self.end_time.as_ref().map(|e| format!("end_time={}", e)), self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), - ].build_query_parameters() + ] + .build_query_parameters() } fn build_url(&self, base_url: &str) -> String { @@ -367,6 +390,3 @@ impl Request for TradeAggregationsRequest { ) } } - - - diff --git a/stellar_rust_sdk/src/trades/all_trades_request.rs b/stellar_rust_sdk/src/trades/all_trades_request.rs index 6015e1b..07acb9e 100644 --- a/stellar_rust_sdk/src/trades/all_trades_request.rs +++ b/stellar_rust_sdk/src/trades/all_trades_request.rs @@ -78,10 +78,7 @@ impl AllTradesRequest { /// # Returns /// /// The updated `AllTradesRequest` with the base asset set. - pub fn set_base_asset( - self, - base_asset: AssetType, - ) -> Result { + pub fn set_base_asset(self, base_asset: AssetType) -> Result { Ok(AllTradesRequest { base_asset: Some(TradeAsset(base_asset)), ..self @@ -100,10 +97,7 @@ impl AllTradesRequest { /// # Returns /// /// The updated `AllTradesRequest` with the counter asset set. - pub fn set_counter_asset( - self, - counter_asset: AssetType, - ) -> Result { + pub fn set_counter_asset(self, counter_asset: AssetType) -> Result { Ok(AllTradesRequest { counter_asset: Some(TradeAsset(counter_asset)), ..self @@ -114,7 +108,7 @@ impl AllTradesRequest { impl Request for AllTradesRequest { fn get_query_parameters(&self) -> String { let mut query: Vec = Vec::new(); - + if let Some(base_asset) = &self.base_asset { match &base_asset.0 { AssetType::Native => { @@ -161,4 +155,4 @@ impl Request for AllTradesRequest { self.get_query_parameters() ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trades/mod.rs b/stellar_rust_sdk/src/trades/mod.rs index 7fc38b1..aa3a12f 100644 --- a/stellar_rust_sdk/src/trades/mod.rs +++ b/stellar_rust_sdk/src/trades/mod.rs @@ -10,7 +10,7 @@ pub mod all_trades_request; /// Provides the `TradesForAccountRequest`. /// /// This module provides the `TradesForAccountRequest` struct, specifically designed for constructing requests to -/// retrieve all trades for a given account from the Horizon server. It is tailored for use with the +/// retrieve all trades for a given account from the Horizon server. It is tailored for use with the /// [`HorizonClient::get_trades_for_account`](crate::horizon_client::HorizonClient::get_trades_for_account) method. /// pub mod trades_for_account_request; @@ -18,7 +18,7 @@ pub mod trades_for_account_request; /// Provides the `TradesForLiquidityPoolRequest`. /// /// This module provides the `TradesForLiquidityPoolRequest` struct, specifically designed for constructing requests to -/// retrieve successful trades fulfilled by the given liquidity pool from the Horizon server. It is tailored for use with the +/// retrieve successful trades fulfilled by the given liquidity pool from the Horizon server. It is tailored for use with the /// [`HorizonClient::get_trades_for_liquidity_pool`](crate::horizon_client::HorizonClient::get_trades_for_liquidity_pool) method. /// pub mod trades_for_liquidity_pool_request; @@ -26,7 +26,7 @@ pub mod trades_for_liquidity_pool_request; /// Provides the `TradesForOfferRequest`. /// /// This module provides the `TradesForOfferRequest` struct, specifically designed for constructing requests to -/// retrieve all trades for a given offer from the Horizon server. It is tailored for use with the +/// retrieve all trades for a given offer from the Horizon server. It is tailored for use with the /// [`HorizonClient::get_trades_for_offer`](crate::horizon_client::HorizonClient::get_trades_for_offer) method. /// pub mod trades_for_offer_request; @@ -91,14 +91,15 @@ pub mod prelude { #[cfg(test)] pub mod test { - use crate::{trades::prelude::*, horizon_client::HorizonClient}; + use crate::{horizon_client::HorizonClient, trades::prelude::*}; #[tokio::test] async fn all_trades_request() { const LINK_SELF: &str = ""; const LINK_BASE: &str = "https://horizon-testnet.stellar.org/accounts/GCUOMNFW7YG55YHY5S5W7FE247PWODUDUZ4SOVZFEON47KZ7AXFG6D6A"; const LINK_COUNTER: &str = "https://horizon-testnet.stellar.org/accounts/GBHRHA3KGRJBXBFER7VHI3WS5SKUXOP5TQ3YITVD7WJ2D3INGK62FZJR"; - const LINK_OPERATION: &str = "https://horizon-testnet.stellar.org/operations/23944442687489"; + const LINK_OPERATION: &str = + "https://horizon-testnet.stellar.org/operations/23944442687489"; const ID: &str = "23944442687489-0"; const PAGING_TOKEN: &str = "23944442687489-0"; const LEDGER_CLOSE_TIME: &str = "2024-06-12T04:58:59Z"; @@ -114,27 +115,33 @@ pub mod test { const COUNTER_AMOUNT: &str = "1.0800000"; const COUNTER_ASSET_TYPE: &str = "credit_alphanum4"; const COUNTER_ASSET_CODE: &str = "XUSD"; - const COUNTER_ASSET_ISSUER: &str = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + const COUNTER_ASSET_ISSUER: &str = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; const BASE_IS_SELLER: &bool = &true; const PRICE_N: &str = "3"; const PRICE_R: &str = "10"; let all_trades_request = AllTradesRequest::new(); let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); - let all_trades_response = horizon_client - .get_all_trades(&all_trades_request) - .await; + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); + let all_trades_response = horizon_client.get_all_trades(&all_trades_request).await; assert!(all_trades_response.clone().is_ok()); let binding = all_trades_response.unwrap(); let response = &binding.embedded().records()[0]; - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); assert_eq!(response.links().base().href().as_ref().unwrap(), LINK_BASE); - assert_eq!(response.links().counter().href().as_ref().unwrap(), LINK_COUNTER); - assert_eq!(response.links().operation().href().as_ref().unwrap(), LINK_OPERATION); + assert_eq!( + response.links().counter().href().as_ref().unwrap(), + LINK_COUNTER + ); + assert_eq!( + response.links().operation().href().as_ref().unwrap(), + LINK_OPERATION + ); assert_eq!(response.id(), ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.ledger_close_time(), LEDGER_CLOSE_TIME); @@ -142,15 +149,39 @@ pub mod test { assert_eq!(response.base_offer_id().as_ref().unwrap(), BASE_OFFER_ID); assert_eq!(response.base_account().as_ref().unwrap(), BASE_ACCOUNT); assert_eq!(response.base_amount(), BASE_AMOUNT); - assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE); - assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE); - assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER); - assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID); - assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT); + assert_eq!( + response.base_asset_type().as_ref().unwrap(), + BASE_ASSET_TYPE + ); + assert_eq!( + response.base_asset_code().as_ref().unwrap(), + BASE_ASSET_CODE + ); + assert_eq!( + response.base_asset_issuer().as_ref().unwrap(), + BASE_ASSET_ISSUER + ); + assert_eq!( + response.counter_offer_id().as_ref().unwrap(), + COUNTER_OFFER_ID + ); + assert_eq!( + response.counter_account().as_ref().unwrap(), + COUNTER_ACCOUNT + ); assert_eq!(response.counter_amount(), COUNTER_AMOUNT); - assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE); - assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE); - assert_eq!(response.counter_asset_issuer().as_ref().unwrap(), COUNTER_ASSET_ISSUER); + assert_eq!( + response.counter_asset_type().as_ref().unwrap(), + COUNTER_ASSET_TYPE + ); + assert_eq!( + response.counter_asset_code().as_ref().unwrap(), + COUNTER_ASSET_CODE + ); + assert_eq!( + response.counter_asset_issuer().as_ref().unwrap(), + COUNTER_ASSET_ISSUER + ); assert_eq!(response.base_is_seller(), BASE_IS_SELLER); assert_eq!(response.price().as_ref().unwrap().numenator(), PRICE_N); assert_eq!(response.price().as_ref().unwrap().denominator(), PRICE_R); @@ -158,11 +189,12 @@ pub mod test { #[tokio::test] async fn trades_for_account_request() { - const ACCOUNT_ID: &str = "GCUOMNFW7YG55YHY5S5W7FE247PWODUDUZ4SOVZFEON47KZ7AXFG6D6A"; // ID for the request + const ACCOUNT_ID: &str = "GCUOMNFW7YG55YHY5S5W7FE247PWODUDUZ4SOVZFEON47KZ7AXFG6D6A"; // ID for the request const LINK_SELF: &str = ""; const LINK_BASE: &str = "https://horizon-testnet.stellar.org/accounts/GCUOMNFW7YG55YHY5S5W7FE247PWODUDUZ4SOVZFEON47KZ7AXFG6D6A"; const LINK_COUNTER: &str = "https://horizon-testnet.stellar.org/accounts/GBHRHA3KGRJBXBFER7VHI3WS5SKUXOP5TQ3YITVD7WJ2D3INGK62FZJR"; - const LINK_OPERATION: &str = "https://horizon-testnet.stellar.org/operations/23944442687489"; + const LINK_OPERATION: &str = + "https://horizon-testnet.stellar.org/operations/23944442687489"; const ID: &str = "23944442687489-0"; const PAGING_TOKEN: &str = "23944442687489-0"; const LEDGER_CLOSE_TIME: &str = "2024-06-12T04:58:59Z"; @@ -178,7 +210,8 @@ pub mod test { const COUNTER_AMOUNT: &str = "1.0800000"; const COUNTER_ASSET_TYPE: &str = "credit_alphanum4"; const COUNTER_ASSET_CODE: &str = "XUSD"; - const COUNTER_ASSET_ISSUER: &str = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + const COUNTER_ASSET_ISSUER: &str = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; const BASE_IS_SELLER: &bool = &true; const PRICE_N: &str = "3"; const PRICE_R: &str = "10"; @@ -187,9 +220,7 @@ pub mod test { .set_account_id(ACCOUNT_ID.to_string()) .unwrap(); let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let trades_for_account_response = horizon_client .get_trades_for_account(&trades_for_account_request) .await; @@ -197,10 +228,19 @@ pub mod test { assert!(trades_for_account_response.clone().is_ok()); let binding = trades_for_account_response.unwrap(); let response = &binding.embedded().records()[0]; - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); assert_eq!(response.links().base().href().as_ref().unwrap(), LINK_BASE); - assert_eq!(response.links().counter().href().as_ref().unwrap(), LINK_COUNTER); - assert_eq!(response.links().operation().href().as_ref().unwrap(), LINK_OPERATION); + assert_eq!( + response.links().counter().href().as_ref().unwrap(), + LINK_COUNTER + ); + assert_eq!( + response.links().operation().href().as_ref().unwrap(), + LINK_OPERATION + ); assert_eq!(response.id(), ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.ledger_close_time(), LEDGER_CLOSE_TIME); @@ -208,15 +248,39 @@ pub mod test { assert_eq!(response.base_offer_id().as_ref().unwrap(), BASE_OFFER_ID); assert_eq!(response.base_account().as_ref().unwrap(), BASE_ACCOUNT); assert_eq!(response.base_amount(), BASE_AMOUNT); - assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE); - assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE); - assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER); - assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID); - assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT); + assert_eq!( + response.base_asset_type().as_ref().unwrap(), + BASE_ASSET_TYPE + ); + assert_eq!( + response.base_asset_code().as_ref().unwrap(), + BASE_ASSET_CODE + ); + assert_eq!( + response.base_asset_issuer().as_ref().unwrap(), + BASE_ASSET_ISSUER + ); + assert_eq!( + response.counter_offer_id().as_ref().unwrap(), + COUNTER_OFFER_ID + ); + assert_eq!( + response.counter_account().as_ref().unwrap(), + COUNTER_ACCOUNT + ); assert_eq!(response.counter_amount(), COUNTER_AMOUNT); - assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE); - assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE); - assert_eq!(response.counter_asset_issuer().as_ref().unwrap(), COUNTER_ASSET_ISSUER); + assert_eq!( + response.counter_asset_type().as_ref().unwrap(), + COUNTER_ASSET_TYPE + ); + assert_eq!( + response.counter_asset_code().as_ref().unwrap(), + COUNTER_ASSET_CODE + ); + assert_eq!( + response.counter_asset_issuer().as_ref().unwrap(), + COUNTER_ASSET_ISSUER + ); assert_eq!(response.base_is_seller(), BASE_IS_SELLER); assert_eq!(response.price().as_ref().unwrap().numenator(), PRICE_N); assert_eq!(response.price().as_ref().unwrap().denominator(), PRICE_R); @@ -224,17 +288,20 @@ pub mod test { #[tokio::test] async fn trades_for_liquidity_pools_request() { - const LIQUIDITY_POOL_ID: &str = "0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3"; // ID for the request + const LIQUIDITY_POOL_ID: &str = + "0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3"; // ID for the request const LINK_SELF: &str = ""; const LINK_BASE: &str = "https://horizon-testnet.stellar.org/liquidity_pools/0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3"; const LINK_COUNTER: &str = "https://horizon-testnet.stellar.org/accounts/GAV5JC25XAB4ALRUDNPB6TZMHSNXFFONKGMLRKHBC5KYGXOGXEVE2BOW"; - const LINK_OPERATION: &str = "https://horizon-testnet.stellar.org/operations/1110815981719553"; + const LINK_OPERATION: &str = + "https://horizon-testnet.stellar.org/operations/1110815981719553"; const ID: &str = "1110815981719553-0"; const PAGING_TOKEN: &str = "1110815981719553-0"; const LEDGER_CLOSE_TIME: &str = "2024-06-27T14:28:37Z"; const TRADE_TYPE: &str = "liquidity_pool"; const LIQUIDITY_POOL_FEE_BP: &u32 = &30; - const BASE_LIQUIDITY_POOL_ID: &str = "0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3"; + const BASE_LIQUIDITY_POOL_ID: &str = + "0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3"; const BASE_AMOUNT: &str = "9.3486278"; const BASE_ASSET_TYPE: &str = "credit_alphanum12"; const BASE_ASSET_CODE: &str = "FLUTTER"; @@ -244,7 +311,8 @@ pub mod test { const COUNTER_AMOUNT: &str = "10.0000000"; const COUNTER_ASSET_TYPE: &str = "credit_alphanum4"; const COUNTER_ASSET_CODE: &str = "SDK"; - const COUNTER_ASSET_ISSUER: &str = "GAGTRBIF75N7NUA37JGGJZKXIS4JJKTQERRFWTP5DN4SM4OC2T6QPMQB"; + const COUNTER_ASSET_ISSUER: &str = + "GAGTRBIF75N7NUA37JGGJZKXIS4JJKTQERRFWTP5DN4SM4OC2T6QPMQB"; const BASE_IS_SELLER: &bool = &true; const PRICE_N: &str = "100000000"; const PRICE_D: &str = "93486278"; @@ -253,9 +321,7 @@ pub mod test { .set_liquidity_pool_id(LIQUIDITY_POOL_ID.to_string()) .unwrap(); let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let trades_for_liquidity_pool_response = horizon_client .get_trades_for_liquidity_pool(&trades_for_liquidity_pool_request) .await; @@ -263,26 +329,65 @@ pub mod test { // assert!(trades_for_liquidity_pool_response.clone().is_ok()); let binding = trades_for_liquidity_pool_response.unwrap(); let response = &binding.embedded().records()[0]; - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); assert_eq!(response.links().base().href().as_ref().unwrap(), LINK_BASE); - assert_eq!(response.links().counter().href().as_ref().unwrap(), LINK_COUNTER); - assert_eq!(response.links().operation().href().as_ref().unwrap(), LINK_OPERATION); + assert_eq!( + response.links().counter().href().as_ref().unwrap(), + LINK_COUNTER + ); + assert_eq!( + response.links().operation().href().as_ref().unwrap(), + LINK_OPERATION + ); assert_eq!(response.id(), ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.ledger_close_time(), LEDGER_CLOSE_TIME); assert_eq!(response.trade_type(), TRADE_TYPE); - assert_eq!(response.liquidity_pool_fee_bp().as_ref().unwrap(), LIQUIDITY_POOL_FEE_BP); - assert_eq!(response.base_liquidity_pool_id().as_ref().unwrap(), BASE_LIQUIDITY_POOL_ID); + assert_eq!( + response.liquidity_pool_fee_bp().as_ref().unwrap(), + LIQUIDITY_POOL_FEE_BP + ); + assert_eq!( + response.base_liquidity_pool_id().as_ref().unwrap(), + BASE_LIQUIDITY_POOL_ID + ); assert_eq!(response.base_amount(), BASE_AMOUNT); - assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE); - assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE); - assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER); - assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID); - assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT); + assert_eq!( + response.base_asset_type().as_ref().unwrap(), + BASE_ASSET_TYPE + ); + assert_eq!( + response.base_asset_code().as_ref().unwrap(), + BASE_ASSET_CODE + ); + assert_eq!( + response.base_asset_issuer().as_ref().unwrap(), + BASE_ASSET_ISSUER + ); + assert_eq!( + response.counter_offer_id().as_ref().unwrap(), + COUNTER_OFFER_ID + ); + assert_eq!( + response.counter_account().as_ref().unwrap(), + COUNTER_ACCOUNT + ); assert_eq!(response.counter_amount(), COUNTER_AMOUNT); - assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE); - assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE); - assert_eq!(response.counter_asset_issuer().as_ref().unwrap(), COUNTER_ASSET_ISSUER); + assert_eq!( + response.counter_asset_type().as_ref().unwrap(), + COUNTER_ASSET_TYPE + ); + assert_eq!( + response.counter_asset_code().as_ref().unwrap(), + COUNTER_ASSET_CODE + ); + assert_eq!( + response.counter_asset_issuer().as_ref().unwrap(), + COUNTER_ASSET_ISSUER + ); assert_eq!(response.base_is_seller(), BASE_IS_SELLER); assert_eq!(response.price().as_ref().unwrap().numenator(), PRICE_N); assert_eq!(response.price().as_ref().unwrap().denominator(), PRICE_D); @@ -294,7 +399,8 @@ pub mod test { const LINK_SELF: &str = ""; const LINK_BASE: &str = "https://horizon-testnet.stellar.org/accounts/GCUOMNFW7YG55YHY5S5W7FE247PWODUDUZ4SOVZFEON47KZ7AXFG6D6A"; const LINK_COUNTER: &str = "https://horizon-testnet.stellar.org/accounts/GBHRHA3KGRJBXBFER7VHI3WS5SKUXOP5TQ3YITVD7WJ2D3INGK62FZJR"; - const LINK_OPERATION: &str = "https://horizon-testnet.stellar.org/operations/23944442687489"; + const LINK_OPERATION: &str = + "https://horizon-testnet.stellar.org/operations/23944442687489"; const ID: &str = "23944442687489-0"; const PAGING_TOKEN: &str = "23944442687489-0"; const LEDGER_CLOSE_TIME: &str = "2024-06-12T04:58:59Z"; @@ -309,7 +415,8 @@ pub mod test { const COUNTER_AMOUNT: &str = "1.0800000"; const COUNTER_ASSET_TYPE: &str = "credit_alphanum4"; const COUNTER_ASSET_CODE: &str = "XUSD"; - const COUNTER_ASSET_ISSUER: &str = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + const COUNTER_ASSET_ISSUER: &str = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; const BASE_IS_SELLER: &bool = &true; const PRICE_N: &str = "3"; const PRICE_D: &str = "10"; @@ -318,9 +425,7 @@ pub mod test { .set_offer_id(OFFER_ID.to_string()) .unwrap(); let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let trades_for_liquidity_pools_response = horizon_client .get_trades_for_offer(&trades_for_offer_request) .await; @@ -328,10 +433,19 @@ pub mod test { assert!(trades_for_liquidity_pools_response.clone().is_ok()); let binding = trades_for_liquidity_pools_response.unwrap(); let response = &binding.embedded().records()[0]; - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); assert_eq!(response.links().base().href().as_ref().unwrap(), LINK_BASE); - assert_eq!(response.links().counter().href().as_ref().unwrap(), LINK_COUNTER); - assert_eq!(response.links().operation().href().as_ref().unwrap(), LINK_OPERATION); + assert_eq!( + response.links().counter().href().as_ref().unwrap(), + LINK_COUNTER + ); + assert_eq!( + response.links().operation().href().as_ref().unwrap(), + LINK_OPERATION + ); assert_eq!(response.id(), ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.ledger_close_time(), LEDGER_CLOSE_TIME); @@ -339,16 +453,37 @@ pub mod test { assert_eq!(response.base_offer_id().as_ref().unwrap(), BASE_OFFER_ID); assert_eq!(response.base_account().as_ref().unwrap(), BASE_ACCOUNT); assert_eq!(response.base_amount(), BASE_AMOUNT); - assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE); - assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE); - assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER); - assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT); + assert_eq!( + response.base_asset_type().as_ref().unwrap(), + BASE_ASSET_TYPE + ); + assert_eq!( + response.base_asset_code().as_ref().unwrap(), + BASE_ASSET_CODE + ); + assert_eq!( + response.base_asset_issuer().as_ref().unwrap(), + BASE_ASSET_ISSUER + ); + assert_eq!( + response.counter_account().as_ref().unwrap(), + COUNTER_ACCOUNT + ); assert_eq!(response.counter_amount(), COUNTER_AMOUNT); - assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE); - assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE); - assert_eq!(response.counter_asset_issuer().as_ref().unwrap(), COUNTER_ASSET_ISSUER); + assert_eq!( + response.counter_asset_type().as_ref().unwrap(), + COUNTER_ASSET_TYPE + ); + assert_eq!( + response.counter_asset_code().as_ref().unwrap(), + COUNTER_ASSET_CODE + ); + assert_eq!( + response.counter_asset_issuer().as_ref().unwrap(), + COUNTER_ASSET_ISSUER + ); assert_eq!(response.base_is_seller(), BASE_IS_SELLER); assert_eq!(response.price().as_ref().unwrap().numenator(), PRICE_N); assert_eq!(response.price().as_ref().unwrap().denominator(), PRICE_D); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trades/response.rs b/stellar_rust_sdk/src/trades/response.rs index 80c0987..8dcc5bf 100644 --- a/stellar_rust_sdk/src/trades/response.rs +++ b/stellar_rust_sdk/src/trades/response.rs @@ -70,7 +70,7 @@ pub struct TradeResponse { ledger_close_time: String, // Can be set to `all`, `orderbook`, or `liquidity_pools` to filter only trades executed across a given mechanism. trade_type: String, - // The value for the liquidity pool fee's base points. + // The value for the liquidity pool fee's base points. liquidity_pool_fee_bp: Option, // The base liquidity pool ID, if this trade was executed against a liquidity pool. base_liquidity_pool_id: Option, @@ -110,4 +110,4 @@ impl Response for TradeResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trades/trades_for_account_request.rs b/stellar_rust_sdk/src/trades/trades_for_account_request.rs index 5262d3a..848d177 100644 --- a/stellar_rust_sdk/src/trades/trades_for_account_request.rs +++ b/stellar_rust_sdk/src/trades/trades_for_account_request.rs @@ -68,4 +68,4 @@ impl Request for TradesForAccountRequest { super::TRADES_PATH ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trades/trades_for_liquidity_pool_request.rs b/stellar_rust_sdk/src/trades/trades_for_liquidity_pool_request.rs index 39409c0..ea0d630 100644 --- a/stellar_rust_sdk/src/trades/trades_for_liquidity_pool_request.rs +++ b/stellar_rust_sdk/src/trades/trades_for_liquidity_pool_request.rs @@ -64,4 +64,4 @@ impl Request for TradesForLiquidityPoolRequest { super::TRADES_PATH ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/trades/trades_for_offer_request.rs b/stellar_rust_sdk/src/trades/trades_for_offer_request.rs index f839ddd..fe0d33b 100644 --- a/stellar_rust_sdk/src/trades/trades_for_offer_request.rs +++ b/stellar_rust_sdk/src/trades/trades_for_offer_request.rs @@ -64,4 +64,4 @@ impl Request for TradesForOfferRequest { super::TRADES_PATH ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/all_transactions_request.rs b/stellar_rust_sdk/src/transactions/all_transactions_request.rs index b78472c..609b929 100644 --- a/stellar_rust_sdk/src/transactions/all_transactions_request.rs +++ b/stellar_rust_sdk/src/transactions/all_transactions_request.rs @@ -38,7 +38,9 @@ pub struct AllTransactionsRequest { impl Request for AllTransactionsRequest { fn get_query_parameters(&self) -> String { vec![ - self.include_failed.as_ref().map(|i| format!("include_failed={}", i)), + self.include_failed + .as_ref() + .map(|i| format!("include_failed={}", i)), self.cursor.as_ref().map(|c| format!("cursor={}", c)), self.limit.as_ref().map(|l| format!("limit={}", l)), self.order.as_ref().map(|o| format!("order={}", o)), @@ -66,10 +68,13 @@ impl AllTransactionsRequest { /// /// # Arguments /// * `include_failed` (bool) - when set to `true`, failed operations will be included. - pub fn set_include_failed(self, include_failed: IncludeFailed) -> Result { + pub fn set_include_failed( + self, + include_failed: IncludeFailed, + ) -> Result { Ok(AllTransactionsRequest { include_failed: Some(include_failed), ..self }) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/mod.rs b/stellar_rust_sdk/src/transactions/mod.rs index 34519b0..49fd704 100644 --- a/stellar_rust_sdk/src/transactions/mod.rs +++ b/stellar_rust_sdk/src/transactions/mod.rs @@ -42,14 +42,13 @@ pub mod transactions_for_ledger_request; /// /// # Usage /// This module provides the `TransactionsForLiquidityPoolRequest` struct, specifically designed for -/// constructing requests to query information about all successful transactions referencing -/// a given liquidity pool from the Horizon server. +/// constructing requests to query information about all successful transactions referencing +/// a given liquidity pool from the Horizon server. /// It is tailored for use with the [`HorizonClient::get_transactions_for_liquidity_pool`](crate::horizon_client::HorizonClient::get_transactions_for_liquidity_pool) /// method. /// pub mod transactions_for_liquidity_pool_request; - /// Provides the responses. /// /// This module defines structures representing the response from the Horizon API when querying @@ -98,27 +97,29 @@ pub(crate) static TRANSACTIONS_PATH: &str = "transactions"; /// let single_transactions_request = SingleTransactionRequest::new(); /// ``` pub mod prelude { - pub use super::single_transaction_request::*; pub use super::all_transactions_request::*; + pub use super::response::*; + pub use super::single_transaction_request::*; pub use super::transactions_for_account_request::*; pub use super::transactions_for_ledger_request::*; pub use super::transactions_for_liquidity_pool_request::*; - pub use super::response::*; } #[cfg(test)] pub mod test { use super::prelude::*; - use crate::models::IncludeFailed; use crate::horizon_client::HorizonClient; + use crate::models::IncludeFailed; const LINK_SELF: &str = "https://horizon-testnet.stellar.org/transactions/b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020"; const LINK_ACCOUNT: &str = "https://horizon-testnet.stellar.org/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"; const LINK_LEDGER: &str = "https://horizon-testnet.stellar.org/ledgers/539"; const LINK_OPERATIONS: &str = "https://horizon-testnet.stellar.org/transactions/b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020/operations{?cursor,limit,order}"; const LINK_EFFECTS: &str = "https://horizon-testnet.stellar.org/transactions/b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020/effects{?cursor,limit,order}"; - const LINK_PRECEDES: &str = "https://horizon-testnet.stellar.org/transactions?order=asc&cursor=2314987376640"; - const LINK_SUCCEEDS: &str = "https://horizon-testnet.stellar.org/transactions?order=desc&cursor=2314987376640"; + const LINK_PRECEDES: &str = + "https://horizon-testnet.stellar.org/transactions?order=asc&cursor=2314987376640"; + const LINK_SUCCEEDS: &str = + "https://horizon-testnet.stellar.org/transactions?order=desc&cursor=2314987376640"; const LINK_TRANSACTION: &str = "https://horizon-testnet.stellar.org/transactions/b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020"; const ID: &str = "b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020"; const PAGING_TOKEN: &str = "2314987376640"; @@ -138,19 +139,17 @@ pub mod test { // const RESULT_META_XDR: &str = ""; // const FEE_META_XDR: &str = ""; const MEMO_TYPE: &str = "none"; - const SIGNATURE: &str = "NUHx9PZlcXQ9mq1lf1usrSTP4/gbxUqzUOQOSU/pQuy9dF7FcUF0fjEbzFECxHUcl4QEfbvyGIE029TA3DrODA=="; + const SIGNATURE: &str = + "NUHx9PZlcXQ9mq1lf1usrSTP4/gbxUqzUOQOSU/pQuy9dF7FcUF0fjEbzFECxHUcl4QEfbvyGIE029TA3DrODA=="; const VALID_AFTER: &str = "1970-01-01T00:00:00Z"; const MIN_TIME: &str = "0"; #[tokio::test] async fn test_get_single_transaction() { let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); - let single_transaction_request = - SingleTransactionRequest::new() + let single_transaction_request = SingleTransactionRequest::new() .set_transaction_hash(ID.to_string()) .unwrap(); @@ -160,14 +159,38 @@ pub mod test { assert!(single_transaction_response.clone().is_ok()); let response = single_transaction_response.unwrap(); - assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(response.links().account().href().as_ref().unwrap(), LINK_ACCOUNT); - assert_eq!(response.links().ledger().href().as_ref().unwrap(), LINK_LEDGER); - assert_eq!(response.links().operations().href().as_ref().unwrap(), LINK_OPERATIONS); - assert_eq!(response.links().effects().href().as_ref().unwrap(), LINK_EFFECTS); - assert_eq!(response.links().precedes().href().as_ref().unwrap(), LINK_PRECEDES); - assert_eq!(response.links().succeeds().href().as_ref().unwrap(), LINK_SUCCEEDS); - assert_eq!(response.links().transaction().href().as_ref().unwrap(), LINK_TRANSACTION); + assert_eq!( + response.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + response.links().account().href().as_ref().unwrap(), + LINK_ACCOUNT + ); + assert_eq!( + response.links().ledger().href().as_ref().unwrap(), + LINK_LEDGER + ); + assert_eq!( + response.links().operations().href().as_ref().unwrap(), + LINK_OPERATIONS + ); + assert_eq!( + response.links().effects().href().as_ref().unwrap(), + LINK_EFFECTS + ); + assert_eq!( + response.links().precedes().href().as_ref().unwrap(), + LINK_PRECEDES + ); + assert_eq!( + response.links().succeeds().href().as_ref().unwrap(), + LINK_SUCCEEDS + ); + assert_eq!( + response.links().transaction().href().as_ref().unwrap(), + LINK_TRANSACTION + ); assert_eq!(response.id(), ID); assert_eq!(response.paging_token(), PAGING_TOKEN); assert_eq!(response.successful(), SUCCESSFUL); @@ -183,15 +206,21 @@ pub mod test { assert_eq!(response.memo_type(), MEMO_TYPE); assert_eq!(response.signatures()[0], SIGNATURE); assert_eq!(response.valid_after().as_ref().unwrap(), VALID_AFTER); - assert_eq!(response.preconditions().as_ref().unwrap().timebounds().min_time(), MIN_TIME); + assert_eq!( + response + .preconditions() + .as_ref() + .unwrap() + .timebounds() + .min_time(), + MIN_TIME + ); } #[tokio::test] async fn test_get_all_transactions() { let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let all_transactions_request = AllTransactionsRequest::new() .set_include_failed(IncludeFailed::True) @@ -204,14 +233,38 @@ pub mod test { assert!(all_transactions_response.clone().is_ok()); let binding = all_transactions_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().account().href().as_ref().unwrap(), LINK_ACCOUNT); - assert_eq!(record.links().ledger().href().as_ref().unwrap(), LINK_LEDGER); - assert_eq!(record.links().operations().href().as_ref().unwrap(), LINK_OPERATIONS); - assert_eq!(record.links().effects().href().as_ref().unwrap(), LINK_EFFECTS); - assert_eq!(record.links().precedes().href().as_ref().unwrap(), LINK_PRECEDES); - assert_eq!(record.links().succeeds().href().as_ref().unwrap(), LINK_SUCCEEDS); - assert_eq!(record.links().transaction().href().as_ref().unwrap(), LINK_TRANSACTION); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().account().href().as_ref().unwrap(), + LINK_ACCOUNT + ); + assert_eq!( + record.links().ledger().href().as_ref().unwrap(), + LINK_LEDGER + ); + assert_eq!( + record.links().operations().href().as_ref().unwrap(), + LINK_OPERATIONS + ); + assert_eq!( + record.links().effects().href().as_ref().unwrap(), + LINK_EFFECTS + ); + assert_eq!( + record.links().precedes().href().as_ref().unwrap(), + LINK_PRECEDES + ); + assert_eq!( + record.links().succeeds().href().as_ref().unwrap(), + LINK_SUCCEEDS + ); + assert_eq!( + record.links().transaction().href().as_ref().unwrap(), + LINK_TRANSACTION + ); assert_eq!(record.id(), ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.successful(), SUCCESSFUL); @@ -227,15 +280,21 @@ pub mod test { assert_eq!(record.memo_type(), MEMO_TYPE); assert_eq!(record.signatures()[0], SIGNATURE); // Check only the first signature of the vector assert_eq!(record.valid_after().as_ref().unwrap(), VALID_AFTER); - assert_eq!(record.preconditions().as_ref().unwrap().timebounds().min_time(), MIN_TIME); + assert_eq!( + record + .preconditions() + .as_ref() + .unwrap() + .timebounds() + .min_time(), + MIN_TIME + ); } #[tokio::test] async fn test_get_transactions_for_account() { let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let transactions_for_account_request = TransactionsForAccountRequest::new() .set_account_id("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H".to_string()) @@ -250,14 +309,38 @@ pub mod test { assert!(transactions_for_account_response.clone().is_ok()); let binding = transactions_for_account_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().account().href().as_ref().unwrap(), LINK_ACCOUNT); - assert_eq!(record.links().ledger().href().as_ref().unwrap(), LINK_LEDGER); - assert_eq!(record.links().operations().href().as_ref().unwrap(), LINK_OPERATIONS); - assert_eq!(record.links().effects().href().as_ref().unwrap(), LINK_EFFECTS); - assert_eq!(record.links().precedes().href().as_ref().unwrap(), LINK_PRECEDES); - assert_eq!(record.links().succeeds().href().as_ref().unwrap(), LINK_SUCCEEDS); - assert_eq!(record.links().transaction().href().as_ref().unwrap(), LINK_TRANSACTION); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().account().href().as_ref().unwrap(), + LINK_ACCOUNT + ); + assert_eq!( + record.links().ledger().href().as_ref().unwrap(), + LINK_LEDGER + ); + assert_eq!( + record.links().operations().href().as_ref().unwrap(), + LINK_OPERATIONS + ); + assert_eq!( + record.links().effects().href().as_ref().unwrap(), + LINK_EFFECTS + ); + assert_eq!( + record.links().precedes().href().as_ref().unwrap(), + LINK_PRECEDES + ); + assert_eq!( + record.links().succeeds().href().as_ref().unwrap(), + LINK_SUCCEEDS + ); + assert_eq!( + record.links().transaction().href().as_ref().unwrap(), + LINK_TRANSACTION + ); assert_eq!(record.id(), ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.successful(), SUCCESSFUL); @@ -273,7 +356,15 @@ pub mod test { assert_eq!(record.memo_type(), MEMO_TYPE); assert_eq!(record.signatures()[0], SIGNATURE); // Check only the first signature of the vector assert_eq!(record.valid_after().as_ref().unwrap(), VALID_AFTER); - assert_eq!(record.preconditions().as_ref().unwrap().timebounds().min_time(), MIN_TIME); + assert_eq!( + record + .preconditions() + .as_ref() + .unwrap() + .timebounds() + .min_time(), + MIN_TIME + ); } #[tokio::test] @@ -281,9 +372,7 @@ pub mod test { const LEDGER_SEQUENCE: &str = "539"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let transactions_for_ledger_request = TransactionsForLedgerRequest::new() .set_ledger_sequence(LEDGER_SEQUENCE.to_string()) @@ -298,14 +387,38 @@ pub mod test { assert!(transactions_for_ledger_response.clone().is_ok()); let binding = transactions_for_ledger_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().account().href().as_ref().unwrap(), LINK_ACCOUNT); - assert_eq!(record.links().ledger().href().as_ref().unwrap(), LINK_LEDGER); - assert_eq!(record.links().operations().href().as_ref().unwrap(), LINK_OPERATIONS); - assert_eq!(record.links().effects().href().as_ref().unwrap(), LINK_EFFECTS); - assert_eq!(record.links().precedes().href().as_ref().unwrap(), LINK_PRECEDES); - assert_eq!(record.links().succeeds().href().as_ref().unwrap(), LINK_SUCCEEDS); - assert_eq!(record.links().transaction().href().as_ref().unwrap(), LINK_TRANSACTION); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().account().href().as_ref().unwrap(), + LINK_ACCOUNT + ); + assert_eq!( + record.links().ledger().href().as_ref().unwrap(), + LINK_LEDGER + ); + assert_eq!( + record.links().operations().href().as_ref().unwrap(), + LINK_OPERATIONS + ); + assert_eq!( + record.links().effects().href().as_ref().unwrap(), + LINK_EFFECTS + ); + assert_eq!( + record.links().precedes().href().as_ref().unwrap(), + LINK_PRECEDES + ); + assert_eq!( + record.links().succeeds().href().as_ref().unwrap(), + LINK_SUCCEEDS + ); + assert_eq!( + record.links().transaction().href().as_ref().unwrap(), + LINK_TRANSACTION + ); assert_eq!(record.id(), ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.successful(), SUCCESSFUL); @@ -321,7 +434,15 @@ pub mod test { assert_eq!(record.memo_type(), MEMO_TYPE); assert_eq!(record.signatures()[0], SIGNATURE); // Check only the first signature of the vector assert_eq!(record.valid_after().as_ref().unwrap(), VALID_AFTER); - assert_eq!(record.preconditions().as_ref().unwrap().timebounds().min_time(), MIN_TIME); + assert_eq!( + record + .preconditions() + .as_ref() + .unwrap() + .timebounds() + .min_time(), + MIN_TIME + ); } #[tokio::test] @@ -331,8 +452,10 @@ pub mod test { const LINK_LEDGER: &str = "https://horizon-testnet.stellar.org/ledgers/106867"; const LINK_OPERATIONS: &str = "https://horizon-testnet.stellar.org/transactions/1f6abb2a00ba84469f8d95271bf2eec99da10bddb894be11f29f7a7039f0c0a6/operations{?cursor,limit,order}"; const LINK_EFFECTS: &str = "https://horizon-testnet.stellar.org/transactions/1f6abb2a00ba84469f8d95271bf2eec99da10bddb894be11f29f7a7039f0c0a6/effects{?cursor,limit,order}"; - const LINK_PRECEDES: &str = "https://horizon-testnet.stellar.org/transactions?order=asc&cursor=458990270087168"; - const LINK_SUCCEEDS: &str = "https://horizon-testnet.stellar.org/transactions?order=desc&cursor=458990270087168"; + const LINK_PRECEDES: &str = + "https://horizon-testnet.stellar.org/transactions?order=asc&cursor=458990270087168"; + const LINK_SUCCEEDS: &str = + "https://horizon-testnet.stellar.org/transactions?order=desc&cursor=458990270087168"; const LINK_TRANSACTION: &str = "https://horizon-testnet.stellar.org/transactions/1f6abb2a00ba84469f8d95271bf2eec99da10bddb894be11f29f7a7039f0c0a6"; const ID: &str = "1f6abb2a00ba84469f8d95271bf2eec99da10bddb894be11f29f7a7039f0c0a6"; const PAGING_TOKEN: &str = "458990270087168"; @@ -350,18 +473,18 @@ pub mod test { const SIGNATURE: &str = "T8ediCtghc8L41mZpHLfWGe0a6pe+wfr1cdaHLApD6Kv0nKrQ6FK/biBWf50IrsMQjMfK61m3a997qQc3M3oDA=="; const VALID_AFTER: &str = "1970-01-01T00:00:00Z"; const MIN_TIME: &str = "0"; - - const LIQUIDITY_POOL_ID: &str = "0066b15f5d0dc0be771209c33f3e4126383e58183a598eae8b3813024c6a6d10"; + + const LIQUIDITY_POOL_ID: &str = + "0066b15f5d0dc0be771209c33f3e4126383e58183a598eae8b3813024c6a6d10"; let horizon_client = - HorizonClient::new("https://horizon-testnet.stellar.org" - .to_string()) - .unwrap(); + HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap(); let transactions_for_liquidity_pool_request = TransactionsForLiquidityPoolRequest::new() .set_liquidity_pool_id(LIQUIDITY_POOL_ID.to_string()) .unwrap() - .set_include_failed(true).unwrap(); + .set_include_failed(true) + .unwrap(); let transactions_for_liquidity_pool_response = horizon_client .get_transactions_for_liquidity_pool(&transactions_for_liquidity_pool_request) @@ -370,14 +493,38 @@ pub mod test { assert!(transactions_for_liquidity_pool_response.clone().is_ok()); let binding = transactions_for_liquidity_pool_response.unwrap(); let record = &binding.embedded().records()[0]; - assert_eq!(record.links().self_link().href().as_ref().unwrap(), LINK_SELF); - assert_eq!(record.links().account().href().as_ref().unwrap(), LINK_ACCOUNT); - assert_eq!(record.links().ledger().href().as_ref().unwrap(), LINK_LEDGER); - assert_eq!(record.links().operations().href().as_ref().unwrap(), LINK_OPERATIONS); - assert_eq!(record.links().effects().href().as_ref().unwrap(), LINK_EFFECTS); - assert_eq!(record.links().precedes().href().as_ref().unwrap(), LINK_PRECEDES); - assert_eq!(record.links().succeeds().href().as_ref().unwrap(), LINK_SUCCEEDS); - assert_eq!(record.links().transaction().href().as_ref().unwrap(), LINK_TRANSACTION); + assert_eq!( + record.links().self_link().href().as_ref().unwrap(), + LINK_SELF + ); + assert_eq!( + record.links().account().href().as_ref().unwrap(), + LINK_ACCOUNT + ); + assert_eq!( + record.links().ledger().href().as_ref().unwrap(), + LINK_LEDGER + ); + assert_eq!( + record.links().operations().href().as_ref().unwrap(), + LINK_OPERATIONS + ); + assert_eq!( + record.links().effects().href().as_ref().unwrap(), + LINK_EFFECTS + ); + assert_eq!( + record.links().precedes().href().as_ref().unwrap(), + LINK_PRECEDES + ); + assert_eq!( + record.links().succeeds().href().as_ref().unwrap(), + LINK_SUCCEEDS + ); + assert_eq!( + record.links().transaction().href().as_ref().unwrap(), + LINK_TRANSACTION + ); assert_eq!(record.id(), ID); assert_eq!(record.paging_token(), PAGING_TOKEN); assert_eq!(record.successful(), SUCCESSFUL); @@ -393,6 +540,14 @@ pub mod test { assert_eq!(record.memo_type(), MEMO_TYPE); assert_eq!(record.signatures()[0], SIGNATURE); // Check only the first signature of the vector assert_eq!(record.valid_after().as_ref().unwrap(), VALID_AFTER); - assert_eq!(record.preconditions().as_ref().unwrap().timebounds().min_time(), MIN_TIME); + assert_eq!( + record + .preconditions() + .as_ref() + .unwrap() + .timebounds() + .min_time(), + MIN_TIME + ); } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/response.rs b/stellar_rust_sdk/src/transactions/response.rs index 19672e3..3af8209 100644 --- a/stellar_rust_sdk/src/transactions/response.rs +++ b/stellar_rust_sdk/src/transactions/response.rs @@ -27,7 +27,7 @@ pub struct TransactionResponseLinks { /// This struct details information about the preconditions, including the time bounds, ledger bounds (optional), /// minimum account sequence and its age(optional), mimimum account sequence leder gap (optional, /// and an array of up to 2 additional signers (optional). -/// +/// #[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)] pub struct Preconditions { /// The time range for which this transaction is valid, with bounds as unsigned 64-bit UNIX timestamps. @@ -47,9 +47,9 @@ pub struct Preconditions { /// Represents the time range for which this transaction is valid, with bounds as unsigned 64-bit UNIX timestamps. /// /// # Usage -/// This struct details information about the time range, including the lower time bound +/// This struct details information about the time range, including the lower time bound /// and the upper time bound (optional). -/// +/// #[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)] pub struct TimeBounds { /// The lower bound. @@ -61,9 +61,9 @@ pub struct TimeBounds { /// Represents the the ledger range for which this transaction is valid. /// /// # Usage -/// This struct details information about the ledger range, including the lower ledger bound +/// This struct details information about the ledger range, including the lower ledger bound /// and the upper ledger bound (optional). -/// +/// #[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)] pub struct LedgerBounds { /// The lower bound. @@ -99,63 +99,63 @@ impl Response for AllTransactionsResponse { /// # Usage /// This struct encapsulates detailed information about a single transaction, including its ID, /// hash, creation time, source account, and other relevant data. -/// +/// #[derive(Debug, Clone, Serialize, Deserialize, Getters)] pub struct TransactionResponse { - #[serde(rename = "_links")] - links: TransactionResponseLinks, - /// A unique identifier for this transaction. - id: String, - /// A cursor value for use in pagination. - paging_token: String, - /// Indicates if this transaction was successful or not. - successful: bool, - /// A hex-encoded SHA-256 hash of this transaction’s XDR-encoded form. - hash: String, - /// The sequence number of the ledger that this transaction was included in. - ledger: i64, - /// The date this transaction was created. - created_at: String, - /// The account that originates the transaction. - source_account: String, - // TODO: Missing description in Stellar documentation. - account_muxed: Option, - // TODO: Missing description in Stellar documentation. - account_muxed_id: Option, - /// The source account's sequence number that this transaction consumed. - source_account_sequence: String, - /// The ID of the fee account. - fee_account: String, - /// The fee (in stroops) paid by the source account to apply this transaction to the ledger. - fee_charged: String, - /// The maximum fee (in stroops) that the source account was willing to pay. - max_fee: String, - /// The number of operations contained within this transaction. - operation_count: i64, - /// A base64 encoded string of the raw `TransactionEnvelope` XDR struct for this transaction. - envelope_xdr: String, - /// A base64 encoded string of the raw `TransactionResult` XDR struct for this transaction. - result_xdr: String, - /// A base64 encoded string of the raw `TransactionMeta` XDR struct for this transaction - result_meta_xdr: String, - /// A base64 encoded string of the raw `L`edgerEntryChanges` XDR struct produced by taking fees for this transaction. - fee_meta_xdr: String, - /// The optional memo attached to a transaction. - memo: Option, - /// The type of memo. Potential values include `MEMO_TEXT`, `MEMO_ID`, `MEMO_HASH`, `MEMO_RETURN`. - memo_type: String, - /// An array of signatures used to sign this transaction. - signatures: Vec, - /// The date after which a transaction is valid. - valid_after: Option, - /// The date before which a transaction is valid. - valid_before: Option, - /// A set of transaction preconditions affecting its validity. - preconditions: Option, + #[serde(rename = "_links")] + links: TransactionResponseLinks, + /// A unique identifier for this transaction. + id: String, + /// A cursor value for use in pagination. + paging_token: String, + /// Indicates if this transaction was successful or not. + successful: bool, + /// A hex-encoded SHA-256 hash of this transaction’s XDR-encoded form. + hash: String, + /// The sequence number of the ledger that this transaction was included in. + ledger: i64, + /// The date this transaction was created. + created_at: String, + /// The account that originates the transaction. + source_account: String, + // TODO: Missing description in Stellar documentation. + account_muxed: Option, + // TODO: Missing description in Stellar documentation. + account_muxed_id: Option, + /// The source account's sequence number that this transaction consumed. + source_account_sequence: String, + /// The ID of the fee account. + fee_account: String, + /// The fee (in stroops) paid by the source account to apply this transaction to the ledger. + fee_charged: String, + /// The maximum fee (in stroops) that the source account was willing to pay. + max_fee: String, + /// The number of operations contained within this transaction. + operation_count: i64, + /// A base64 encoded string of the raw `TransactionEnvelope` XDR struct for this transaction. + envelope_xdr: String, + /// A base64 encoded string of the raw `TransactionResult` XDR struct for this transaction. + result_xdr: String, + /// A base64 encoded string of the raw `TransactionMeta` XDR struct for this transaction + result_meta_xdr: String, + /// A base64 encoded string of the raw `L`edgerEntryChanges` XDR struct produced by taking fees for this transaction. + fee_meta_xdr: String, + /// The optional memo attached to a transaction. + memo: Option, + /// The type of memo. Potential values include `MEMO_TEXT`, `MEMO_ID`, `MEMO_HASH`, `MEMO_RETURN`. + memo_type: String, + /// An array of signatures used to sign this transaction. + signatures: Vec, + /// The date after which a transaction is valid. + valid_after: Option, + /// The date before which a transaction is valid. + valid_before: Option, + /// A set of transaction preconditions affecting its validity. + preconditions: Option, } impl Response for TransactionResponse { fn from_json(json: String) -> Result { serde_json::from_str(&json).map_err(|e| e.to_string()) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/single_transaction_request.rs b/stellar_rust_sdk/src/transactions/single_transaction_request.rs index 19a486c..214fe1d 100644 --- a/stellar_rust_sdk/src/transactions/single_transaction_request.rs +++ b/stellar_rust_sdk/src/transactions/single_transaction_request.rs @@ -10,7 +10,7 @@ pub struct NoTransactionHash; #[derive(Default)] pub struct SingleTransactionRequest { - /// Transaction hash must be a hex-encoded, lowercase SHA-256, 64 char string. + /// Transaction hash must be a hex-encoded, lowercase SHA-256, 64 char string. transaction_hash: T, } @@ -21,17 +21,19 @@ impl SingleTransactionRequest { } /// Sets the transaction hash for the request. - /// + /// /// # Arguments /// * `transaction_hash` - A `String` specifying the operation hash. - /// + /// pub fn set_transaction_hash( self, transaction_hash: String, ) -> Result, String> { match transaction_hash.len() { - 64 => Ok(SingleTransactionRequest {transaction_hash: TransactionHash(transaction_hash)}), - _ => Err("Transaction hash must be 64 characters long".to_string()) + 64 => Ok(SingleTransactionRequest { + transaction_hash: TransactionHash(transaction_hash), + }), + _ => Err("Transaction hash must be 64 characters long".to_string()), } } } @@ -54,4 +56,4 @@ impl Request for SingleTransactionRequest { self.get_query_parameters() ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs b/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs index 8c8fad7..6ca9339 100644 --- a/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs +++ b/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs @@ -97,4 +97,4 @@ impl Request for TransactionsForAccountRequest { self.get_query_parameters(), ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/transactions_for_ledger_request.rs b/stellar_rust_sdk/src/transactions/transactions_for_ledger_request.rs index 204e01f..7f7023d 100644 --- a/stellar_rust_sdk/src/transactions/transactions_for_ledger_request.rs +++ b/stellar_rust_sdk/src/transactions/transactions_for_ledger_request.rs @@ -97,4 +97,4 @@ impl Request for TransactionsForLedgerRequest { self.get_query_parameters(), ) } -} \ No newline at end of file +} diff --git a/stellar_rust_sdk/src/transactions/transactions_for_liquidity_pool_request.rs b/stellar_rust_sdk/src/transactions/transactions_for_liquidity_pool_request.rs index 51f4677..e6d86c2 100644 --- a/stellar_rust_sdk/src/transactions/transactions_for_liquidity_pool_request.rs +++ b/stellar_rust_sdk/src/transactions/transactions_for_liquidity_pool_request.rs @@ -97,4 +97,4 @@ impl Request for TransactionsForLiquidityPoolRequest TokenStream { let mut input = parse_macro_input!(input as ItemStruct); - // No arguments should be passed, but if they are, parse them as `Nothing` to prevent misuse. + // No arguments should be passed, but if they are, parse them as `Nothing` to prevent misuse. let _ = parse_macro_input!(args as Nothing); // Create required fields to be added to the struct. @@ -86,4 +86,4 @@ pub fn pagination(args: TokenStream, input: TokenStream) -> TokenStream { } }; TokenStream::from(expanded) -} \ No newline at end of file +}