diff --git a/stellar_rust_sdk/src/accounts/accounts_request.rs b/stellar_rust_sdk/src/accounts/accounts_request.rs index 2beb4a2..af9a584 100644 --- a/stellar_rust_sdk/src/accounts/accounts_request.rs +++ b/stellar_rust_sdk/src/accounts/accounts_request.rs @@ -345,7 +345,7 @@ impl AccountsRequest + sponsor: impl Into, ) -> Result< AccountsRequest, String, diff --git a/stellar_rust_sdk/src/claimable_balances/all_claimable_balances_request.rs b/stellar_rust_sdk/src/claimable_balances/all_claimable_balances_request.rs index 9603fe0..32c8729 100644 --- a/stellar_rust_sdk/src/claimable_balances/all_claimable_balances_request.rs +++ b/stellar_rust_sdk/src/claimable_balances/all_claimable_balances_request.rs @@ -1,4 +1,4 @@ -use crate::{models::*, BuildQueryParametersExt}; +use crate::{models::*, models::prelude::*, BuildQueryParametersExt}; use stellar_rust_sdk_derive::pagination; /// Represents a request to list all claimable balances from the Stellar Horizon API. @@ -17,16 +17,17 @@ use stellar_rust_sdk_derive::pagination; /// /// # Example /// ``` -/// # use stellar_rs::claimable_balances::all_claimable_balances_request::AllClaimableBalancesRequest; -/// # use stellar_rs::models::{Asset, Order, IssuedAsset}; +/// use stellar_rs::claimable_balances::all_claimable_balances_request::AllClaimableBalancesRequest; +/// use stellar_rs::models::{Order, prelude::*}; /// /// let request = AllClaimableBalancesRequest::new() -/// .set_sponsor("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap() // Optional sponsor filter -/// .set_asset(Asset::new().set_issued("USD", "GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap()) // Optional asset filter -/// .set_claimant("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap() // Optional claimant filter -/// .set_cursor(123).unwrap() // Optional cursor for pagination -/// .set_limit(100).unwrap() // Optional limit for response records -/// .set_order(Order::Desc); // Optional order of records +/// .set_sponsor("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap() // optional sponsor filter +/// .set_asset(IssuedOrNative::Issued(AssetData{ +/// asset_code: "USDC".to_string(), +/// asset_issuer: "GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7".to_string(), +/// })) // optional asset filter +/// .set_claimant("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7".to_string()).unwrap() // optional claimant filter +/// .set_limit(4).unwrap(); // optional limit for response records /// /// // Use with HorizonClient::get_all_claimable_balances /// ``` @@ -40,7 +41,7 @@ pub struct AllClaimableBalancesRequest { /// Optional. Indicates issued asset for which claimable balances are being queried. /// When set, the response will filter claimable balances that hold this specific asset. - asset: Option>, + asset: Option, /// Optional. Represents the account ID of the claimant. If provided, the response will /// include only claimable balances that are claimable by the specified account. @@ -49,9 +50,21 @@ pub struct AllClaimableBalancesRequest { impl Request for AllClaimableBalancesRequest { fn get_query_parameters(&self) -> String { + let prefix = "asset="; + let asset = match &self.asset { + Some(IssuedOrNative::Native) => format!("{}native", prefix), + Some(IssuedOrNative::Issued(asset_data)) => { + format!( + "{}{}%3A{}", + prefix, asset_data.asset_code, asset_data.asset_issuer + ) + }, + None => String::new() + }; + vec![ self.sponsor.as_ref().map(|s| format!("sponsor={}", s)), - self.asset.as_ref().map(|a| format!("asset={}", a)), + Some(asset), self.claimant.as_ref().map(|c| format!("claimant={}", c)), self.cursor.as_ref().map(|c| format!("cursor={}", c)), self.limit.as_ref().map(|l| format!("limit={}", l)), @@ -81,7 +94,10 @@ impl AllClaimableBalancesRequest { /// # Arguments /// * `sponsor` - A Stellar public key of the sponsor whose claimable balances are to be retrieved. /// - pub fn set_sponsor(self, sponsor: impl Into) -> Result { + pub fn set_sponsor( + self, + sponsor: impl Into, + ) -> Result { let sponsor = sponsor.into(); if let Err(e) = is_public_key(&sponsor) { return Err(e.to_string()); @@ -98,7 +114,7 @@ impl AllClaimableBalancesRequest { /// # Arguments /// * `asset` - The issued asset to filter claimable balances by asset type. /// - pub fn set_asset(self, asset: Asset) -> AllClaimableBalancesRequest { + pub fn set_asset(self, asset: IssuedOrNative) -> AllClaimableBalancesRequest { AllClaimableBalancesRequest { asset: Some(asset), ..self @@ -110,7 +126,10 @@ impl AllClaimableBalancesRequest { /// # Arguments /// * `claimant` - A Stellar public key of the claimant whose claimable balances are to be retrieved. /// - pub fn set_claimant(self, claimant: impl Into) -> Result { + pub fn set_claimant( + self, + claimant: impl Into, + ) -> Result { let claimant = claimant.into(); if let Err(e) = is_public_key(&claimant) { return Err(e.to_string()); diff --git a/stellar_rust_sdk/src/claimable_balances/mod.rs b/stellar_rust_sdk/src/claimable_balances/mod.rs index 21dc194..18efbe6 100644 --- a/stellar_rust_sdk/src/claimable_balances/mod.rs +++ b/stellar_rust_sdk/src/claimable_balances/mod.rs @@ -98,6 +98,7 @@ pub mod prelude { mod tests { use super::parse_epoch; use super::prelude::*; + use crate::models::prelude::*; use crate::horizon_client::HorizonClient; use chrono::DateTime; use chrono::{TimeZone, Utc}; @@ -184,20 +185,34 @@ mod tests { assert_eq!(predicate.is_valid(jan_first_2024), true); assert_eq!(predicate.is_valid(valid_date), true); let record = &binding.embedded().records()[0]; - assert_eq!(record.id(), ID); - assert_eq!(record.asset(), ASSET); - assert_eq!(record.amount(), AMOUNT); - 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.flags().clawback_enabled(), CLAWBACK_ENABLED); + + // Create request with parameters. + let all_claimable_balances_request = + AllClaimableBalancesRequest::new() + .set_sponsor("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7") + .unwrap() + .set_asset(IssuedOrNative::Issued(AssetData{ + asset_code: "USDC".to_string(), + asset_issuer: "GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7".to_string(), + })) + .set_claimant("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7".to_string()) + .unwrap() + .set_limit(4) + .unwrap(); + + let all_claimable_balances_response = horizon_client + .get_all_claimable_balances(&all_claimable_balances_request) + .await; + + assert!(all_claimable_balances_response.is_ok()); // only test response status code + } #[tokio::test] @@ -218,8 +233,8 @@ mod tests { // Initialize horizon client let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org").unwrap(); - let single_claimable_balance_request = SingleClaimableBalanceRequest::new() - .set_claimable_balance_id(CLAIMABLE_BALANCE_ID); + let single_claimable_balance_request = + SingleClaimableBalanceRequest::new().set_claimable_balance_id(CLAIMABLE_BALANCE_ID); let single_claimable_balance_response = horizon_client .get_single_claimable_balance(&single_claimable_balance_request) diff --git a/stellar_rust_sdk/src/claimable_balances/single_claimable_balance_request.rs b/stellar_rust_sdk/src/claimable_balances/single_claimable_balance_request.rs index 99c3687..a59ad6a 100644 --- a/stellar_rust_sdk/src/claimable_balances/single_claimable_balance_request.rs +++ b/stellar_rust_sdk/src/claimable_balances/single_claimable_balance_request.rs @@ -90,8 +90,7 @@ mod tests { #[test] fn test_single_claimable_balance_request() { - let request = - SingleClaimableBalanceRequest::new().set_claimable_balance_id("00000000"); + let request = SingleClaimableBalanceRequest::new().set_claimable_balance_id("00000000"); assert_eq!(request.get_query_parameters(), "00000000"); 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 787f45b..2ff81c5 100644 --- a/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs @@ -46,7 +46,10 @@ impl EffectForTransactionRequest { /// # Arguments /// * `liquidity_pool_id` - A `String` value representing the liquidity pool id. /// - pub fn set_transaction_hash(self, transaction_hash: impl Into) -> EffectForTransactionRequest { + pub fn set_transaction_hash( + self, + transaction_hash: impl Into, + ) -> EffectForTransactionRequest { EffectForTransactionRequest { transaction_hash: Some(transaction_hash.into()), ..self 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 3853529..d6fab9c 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,5 +1,8 @@ use crate::{ - models::{prelude::{AssetData, AssetType}, Order, Request}, + models::{ + prelude::{AssetData, AssetType}, + Order, Request, + }, BuildQueryParametersExt, }; use stellar_rust_sdk_derive::pagination; @@ -74,7 +77,7 @@ impl AllLiquidityPoolsRequest { asset_issuer, })), None => { - self.reserves = Some(vec![AssetType::Alphanumeric4(AssetData{ + self.reserves = Some(vec![AssetType::Alphanumeric4(AssetData { asset_code, asset_issuer, })]) diff --git a/stellar_rust_sdk/src/models/request_models.rs b/stellar_rust_sdk/src/models/request_models.rs index b8e96e0..72a78ec 100644 --- a/stellar_rust_sdk/src/models/request_models.rs +++ b/stellar_rust_sdk/src/models/request_models.rs @@ -5,7 +5,16 @@ pub struct AssetData { pub asset_issuer: String, } -/// Represents the asset type of an asset. +/// Represents 1 of the asset types which can be specified in a request. +#[derive(Default, Clone, Debug)] +pub enum IssuedOrNative { + #[default] + Native, + Issued(AssetData), +} + +/// Represents 1 of the asset types which can be specified in a request. +/// This type has more specific options to choose from. #[derive(Default, Clone, PartialEq, Debug)] pub enum AssetType { /// A native asset_type type. It holds no value. diff --git a/stellar_rust_sdk/src/offers/all_offers_request.rs b/stellar_rust_sdk/src/offers/all_offers_request.rs index 43fdbc8..460b877 100644 --- a/stellar_rust_sdk/src/offers/all_offers_request.rs +++ b/stellar_rust_sdk/src/offers/all_offers_request.rs @@ -1,4 +1,4 @@ -use crate::{models::*, BuildQueryParametersExt}; +use crate::{models::prelude::*, models::*, BuildQueryParametersExt}; use stellar_rust_sdk_derive::pagination; /// Represents a request to list all offers from the Stellar Horizon API. @@ -17,16 +17,19 @@ use stellar_rust_sdk_derive::pagination; /// # Example /// ``` /// use stellar_rs::offers::all_offers_request::AllOffersRequest; -/// use stellar_rs::models::{Asset, NativeAsset, Order}; +/// use stellar_rs::models::{Order, prelude::*}; /// /// let request = AllOffersRequest::new() -/// .set_sponsor("GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5").unwrap() // Optional sponsor filter -/// .set_seller("GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap() // Optional seller filter -/// .set_selling(Asset::new().set_issued("USD", "GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap()) // Optional selling asset filter -/// .set_buying(Asset::new().set_issued("USD", "GDQJUTQYK2MQX2VGDR2FYWLIYAQIEGXTQVTFEMGH2BEWFG4BRUY4CKI7").unwrap()) // Optional buying asset filter -/// .set_cursor(123).unwrap() // Optional cursor for pagination -/// .set_limit(100).unwrap() // Optional limit for response records -/// .set_order(Order::Desc); // Optional order of records +/// .set_sponsor("GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5").unwrap() // Optional buyer filter +/// .set_seller("GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4").unwrap() // optional seller filter +/// .set_selling(IssuedOrNative::Issued(AssetData { +/// asset_code: "USDC".to_string(), +/// asset_issuer: "GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4".to_string(), +/// })) // optional selling asset filter +/// .set_buying(IssuedOrNative::Native) // optional buying asset filter +/// .set_cursor(123).unwrap() // optional cursor for pagination +/// .set_limit(100).unwrap() // optional limit for response records +/// .set_order(Order::Desc).unwrap(); // optional order of records /// /// // Use with HorizonClient::get_all_offers /// ``` @@ -42,19 +45,45 @@ pub struct AllOffersRequest { seller: Option, /// Optional. Indicates an selling asset for which offers are being queried. /// When set, the response will filter the offers that hold this specific asset. - selling: Option>, + selling: Option, /// Optional. Indicates a buying asset for which offers are being queried. /// When set, the response will filter the offers that hold this specific asset. - buying: Option>, + buying: Option, } impl Request for AllOffersRequest { fn get_query_parameters(&self) -> String { + // Determine selling assets and form parameters. + let prefix = "selling="; + let selling_asset = match &self.selling { + Some(IssuedOrNative::Native) => format!("{}native", prefix), + Some(IssuedOrNative::Issued(asset_data)) => { + format!( + "{}{}%3A{}", + prefix, asset_data.asset_code, asset_data.asset_issuer + ) + }, + None => String::new() + }; + + // Determine buying assets and form parameters. + let prefix = "buying="; + let buying_asset = match &self.buying { + Some(IssuedOrNative::Native) => format!("{}native", prefix), + Some(IssuedOrNative::Issued(asset_data)) => { + format!( + "{}{}%3A{}", + prefix, asset_data.asset_code, asset_data.asset_issuer + ) + }, + None => String::new() + }; + vec![ self.sponsor.as_ref().map(|s| format!("sponsor={}", s)), self.seller.as_ref().map(|s| format!("seller={}", s)), - self.selling.as_ref().map(|s| format!("selling={}", s)), - self.buying.as_ref().map(|b| format!("buying={}", b)), + Some(selling_asset), + Some(buying_asset), 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)), @@ -117,7 +146,7 @@ impl AllOffersRequest { /// # Arguments /// * `selling` - The selling asset to filter offers by. /// - pub fn set_selling(self, selling: Asset) -> AllOffersRequest { + pub fn set_selling(self, selling: IssuedOrNative) -> AllOffersRequest { AllOffersRequest { selling: Some(selling), ..self @@ -129,7 +158,7 @@ impl AllOffersRequest { /// # Arguments /// * `buying` - The buying asset to filter offers by. /// - pub fn set_buying(self, buying: Asset) -> AllOffersRequest { + pub fn set_buying(self, buying: IssuedOrNative) -> AllOffersRequest { AllOffersRequest { buying: Some(buying), ..self diff --git a/stellar_rust_sdk/src/offers/mod.rs b/stellar_rust_sdk/src/offers/mod.rs index 58ace4f..1697b95 100644 --- a/stellar_rust_sdk/src/offers/mod.rs +++ b/stellar_rust_sdk/src/offers/mod.rs @@ -83,7 +83,10 @@ pub mod prelude { #[cfg(test)] pub mod test { use super::prelude::*; - use crate::{horizon_client::HorizonClient, models::*}; + use crate::{horizon_client::HorizonClient, + models::*, + models::prelude::* + }; #[tokio::test] async fn test_get_single_offer() { @@ -109,9 +112,7 @@ pub mod test { let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org").unwrap(); - let single_offer_request = SingleOfferRequest::new() - .set_offer_id(OFFER_ID) - .unwrap(); + let single_offer_request = SingleOfferRequest::new().set_offer_id(OFFER_ID).unwrap(); let single_offer_response = horizon_client.get_single_offer(&single_offer_request).await; @@ -210,6 +211,28 @@ pub mod test { assert_eq!(record.price_decimal(), PRICE); assert_eq!(record.last_modified_ledger(), LAST_MODIFIED_LEDGER); assert_eq!(record.last_modified_time(), LAST_MODIFIED_TIME); + + // Create a request with parameters. + let all_offers_request = AllOffersRequest::new() + .set_sponsor("GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5") + .unwrap() + .set_seller("GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4") + .unwrap() + .set_selling(IssuedOrNative::Issued(AssetData { + asset_code: "USDC".to_string(), + asset_issuer: "GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4" + .to_string(), + })) + .set_buying(IssuedOrNative::Native) + .set_cursor(123) + .unwrap() + .set_limit(100) + .unwrap() + .set_order(Order::Desc) + .unwrap(); + + let all_offers_response = horizon_client.get_all_offers(&all_offers_request).await; + assert!(all_offers_response.is_ok()); // only test response status code } #[tokio::test] 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 1fca63d..b3c2889 100644 --- a/stellar_rust_sdk/src/offers/offers_for_account_request.rs +++ b/stellar_rust_sdk/src/offers/offers_for_account_request.rs @@ -24,7 +24,7 @@ impl OffersForAccountRequest { pub fn set_account_id( self, - account_id: impl Into + account_id: impl Into, ) -> Result, String> { let account_id = account_id.into(); if let Err(e) = is_public_key(&account_id) { diff --git a/stellar_rust_sdk/src/offers/single_offer_request.rs b/stellar_rust_sdk/src/offers/single_offer_request.rs index 2308990..7216d6b 100644 --- a/stellar_rust_sdk/src/offers/single_offer_request.rs +++ b/stellar_rust_sdk/src/offers/single_offer_request.rs @@ -54,7 +54,10 @@ 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: impl Into) -> Result, String> { + pub fn set_offer_id( + self, + offer_id: impl Into, + ) -> Result, String> { let offer_id = offer_id.into(); match offer_id.parse::() { Ok(id) => { diff --git a/stellar_rust_sdk/src/operations/mod.rs b/stellar_rust_sdk/src/operations/mod.rs index a8678ad..8bbbe6c 100644 --- a/stellar_rust_sdk/src/operations/mod.rs +++ b/stellar_rust_sdk/src/operations/mod.rs @@ -195,8 +195,7 @@ pub mod tests { let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org").unwrap(); - let single_operation_request = - SingleOperationRequest::new().set_operation_id(ID); + let single_operation_request = SingleOperationRequest::new().set_operation_id(ID); let all_operations_response: Result = horizon_client .get_single_operation(&single_operation_request) 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 da3c45a..5f5f982 100644 --- a/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs +++ b/stellar_rust_sdk/src/operations/operations_for_transaction_request.rs @@ -22,7 +22,10 @@ impl OperationsForTransactionRequest { /// # Arguments /// * `transaction_hash` - A `String` representing the transaction hash. /// - pub fn set_transaction_hash(self, transaction_hash: impl Into) -> OperationsForTransactionRequest { + pub fn set_transaction_hash( + self, + transaction_hash: impl Into, + ) -> OperationsForTransactionRequest { OperationsForTransactionRequest { transaction_hash: Some(transaction_hash.into()), ..self diff --git a/stellar_rust_sdk/src/operations/single_operation_request.rs b/stellar_rust_sdk/src/operations/single_operation_request.rs index 23fa95e..37e20a3 100644 --- a/stellar_rust_sdk/src/operations/single_operation_request.rs +++ b/stellar_rust_sdk/src/operations/single_operation_request.rs @@ -45,7 +45,10 @@ impl SingleOperationRequest { /// # Arguments /// * `operation_id` - A `String` specifying the operation ID. /// - pub fn set_operation_id(self, operation_id: impl Into) -> SingleOperationRequest { + pub fn set_operation_id( + self, + operation_id: impl Into, + ) -> SingleOperationRequest { SingleOperationRequest { operation_id: OperationId(operation_id.into()), } diff --git a/stellar_rust_sdk/src/paths/mod.rs b/stellar_rust_sdk/src/paths/mod.rs index 2e22b07..0cebc3c 100644 --- a/stellar_rust_sdk/src/paths/mod.rs +++ b/stellar_rust_sdk/src/paths/mod.rs @@ -1,4 +1,5 @@ use crate::models::prelude::*; + /// Provides the `FindPaymentPathsRequest`. /// /// # Usage @@ -75,14 +76,6 @@ pub struct NoSourceAccount; #[derive(Default, Clone, Debug)] pub struct SourceAccount(String); -/// Represents structure of an asset used in the vector of optional assets. -#[derive(Default, Clone, Debug)] -pub enum IssuedOrNative { - #[default] - Native, - Issued(AssetData), -} - /// The `prelude` module of the `paths` module. /// /// # Usage diff --git a/stellar_rust_sdk/src/payments/mod.rs b/stellar_rust_sdk/src/payments/mod.rs index e68634a..f5bebf4 100644 --- a/stellar_rust_sdk/src/payments/mod.rs +++ b/stellar_rust_sdk/src/payments/mod.rs @@ -108,9 +108,8 @@ pub mod test { let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org").unwrap(); let payments_for_account_request: PaymentsForAccountRequest = - PaymentsForAccountRequest::new().set_account_id( - "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", - ); + PaymentsForAccountRequest::new() + .set_account_id("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); let response: Result = horizon_client .get_payments_for_account(&payments_for_account_request) @@ -190,7 +189,9 @@ pub mod test { let payments_for_transaction_request: PaymentsForTransactionRequest = PaymentsForTransactionRequest::new() - .set_transaction_hash("b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020") + .set_transaction_hash( + "b9d0b2292c4e09e8eb22d036171491e87b8d2086bf8b265874c8d182cb9c9020", + ) .set_limit(1) .unwrap(); 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 415af7f..171985d 100644 --- a/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs +++ b/stellar_rust_sdk/src/payments/payments_for_ledger_request.rs @@ -29,7 +29,10 @@ impl PaymentsForLedgerRequest { /// # Arguments /// * `account_id` - The Stellar address of the account for which you want to retrieve payments. /// - pub fn set_ledger_sequence(mut self, ledger_sequence: impl Into) -> PaymentsForLedgerRequest { + pub fn set_ledger_sequence( + mut self, + ledger_sequence: impl Into, + ) -> PaymentsForLedgerRequest { self.ledger_sequence = Some(ledger_sequence.into()); self } diff --git a/stellar_rust_sdk/src/trades/mod.rs b/stellar_rust_sdk/src/trades/mod.rs index 2c43c4c..42b3450 100644 --- a/stellar_rust_sdk/src/trades/mod.rs +++ b/stellar_rust_sdk/src/trades/mod.rs @@ -418,9 +418,7 @@ pub mod test { const PRICE_N: &str = "3"; const PRICE_D: &str = "10"; - let trades_for_offer_request = TradesForOfferRequest::new() - .set_offer_id(OFFER_ID) - .unwrap(); + let trades_for_offer_request = TradesForOfferRequest::new().set_offer_id(OFFER_ID).unwrap(); let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org").unwrap(); let trades_for_liquidity_pools_response = horizon_client .get_trades_for_offer(&trades_for_offer_request) 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 51c8a2e..d61f6bf 100644 --- a/stellar_rust_sdk/src/trades/trades_for_account_request.rs +++ b/stellar_rust_sdk/src/trades/trades_for_account_request.rs @@ -32,7 +32,7 @@ impl TradesForAccountRequest { /// pub fn set_account_id( self, - account_id: impl Into + account_id: impl Into, ) -> Result, String> { let account_id = account_id.into(); if let Err(e) = is_public_key(&account_id) { 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 9e72445..ea60d82 100644 --- a/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs +++ b/stellar_rust_sdk/src/transactions/transactions_for_account_request.rs @@ -34,7 +34,7 @@ impl TransactionsForAccountRequest { /// pub fn set_account_id( self, - account_id: impl Into + account_id: impl Into, ) -> Result, String> { Ok(TransactionsForAccountRequest { account_id: TransactionsAccountId(account_id.into()),