From ab4a2caf6eb0096bb0905fbdfa6ae39d277672d8 Mon Sep 17 00:00:00 2001 From: Kevin Pease Date: Tue, 4 Jun 2024 13:21:59 +0200 Subject: [PATCH 1/2] Add documentation --- .../src/effects/all_effects_request.rs | 5 +- .../effects/effects_for_account_request.rs | 3 - .../src/effects/effects_for_ledger_request.rs | 3 - .../effects_for_liquidity_pools_request.rs | 3 - .../effects/effects_for_operation_request.rs | 3 - .../effects_for_transaction_request.rs | 3 - stellar_rust_sdk/src/effects/mod.rs | 98 +++++++++++++++++++ 7 files changed, 100 insertions(+), 18 deletions(-) diff --git a/stellar_rust_sdk/src/effects/all_effects_request.rs b/stellar_rust_sdk/src/effects/all_effects_request.rs index 574e1ff..e921d01 100644 --- a/stellar_rust_sdk/src/effects/all_effects_request.rs +++ b/stellar_rust_sdk/src/effects/all_effects_request.rs @@ -1,5 +1,6 @@ use crate::{models::*, BuildQueryParametersExt, Paginatable}; use stellar_rust_sdk_derive::Pagination; + /// Represents a request to fetch effect data from the Stellar Horizon API. /// /// `AllEffectsRequest` is a struct used to construct queries for retrieving information about effects @@ -31,11 +32,9 @@ pub struct AllEffectsRequest { /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, @@ -89,4 +88,4 @@ mod tests { assert!(request.is_err()); } -} +} \ No newline at end of file diff --git a/stellar_rust_sdk/src/effects/effects_for_account_request.rs b/stellar_rust_sdk/src/effects/effects_for_account_request.rs index f66415a..cfb4a40 100644 --- a/stellar_rust_sdk/src/effects/effects_for_account_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_account_request.rs @@ -42,15 +42,12 @@ use stellar_rust_sdk_derive::Pagination; pub struct EffectsForAccountRequest { /// The accounts public id account_id: Option, - /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, diff --git a/stellar_rust_sdk/src/effects/effects_for_ledger_request.rs b/stellar_rust_sdk/src/effects/effects_for_ledger_request.rs index 03af2c8..7044e47 100644 --- a/stellar_rust_sdk/src/effects/effects_for_ledger_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_ledger_request.rs @@ -29,15 +29,12 @@ use stellar_rust_sdk_derive::Pagination; pub struct EffectsForLedgerRequest { /// The ledger's sequence number for which effects are to be retrieved. sequence: Option, - /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, 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 86db69a..218e5aa 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 @@ -40,15 +40,12 @@ use stellar_rust_sdk_derive::Pagination; pub struct EffectsForLiquidityPoolRequest { /// The liquidity pool id liquidity_pool_id: Option, - /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, 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 c00bc9b..1c03ea6 100644 --- a/stellar_rust_sdk/src/effects/effects_for_operation_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_operation_request.rs @@ -43,15 +43,12 @@ use stellar_rust_sdk_derive::Pagination; pub struct EffectsForOperationRequest { /// The operation id to filter effects. operation_id: Option, - /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, 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 97e12f7..cecadde 100644 --- a/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs +++ b/stellar_rust_sdk/src/effects/effects_for_transaction_request.rs @@ -31,15 +31,12 @@ use stellar_rust_sdk_derive::Pagination; pub struct EffectForTransactionRequest { /// The transaction hash of the transaction of the effect transaction_hash: Option, - /// A pointer to a specific location in a collection of responses, derived from the /// `paging_token` value of a record. Used for pagination control in the API response. cursor: Option, - /// Specifies the maximum number of records to be returned in a single response. /// The range for this parameter is from 1 to 200. The default value is set to 10. limit: Option, - /// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending) /// and [`Order::Desc`] (descending). If not specified, it defaults to ascending. order: Option, diff --git a/stellar_rust_sdk/src/effects/mod.rs b/stellar_rust_sdk/src/effects/mod.rs index 2b94a4a..22f0189 100644 --- a/stellar_rust_sdk/src/effects/mod.rs +++ b/stellar_rust_sdk/src/effects/mod.rs @@ -1,13 +1,111 @@ +/// 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. +/// +/// 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 +/// and requirements of the Horizon API for asset queries. +/// pub mod all_effects_request; + +/// Provides the `EffectsForAccountRequest`. +/// +/// This module provides the `EffectsForAccountRequest` struct, specifically designed for +/// constructing requests to query information about effects of a specific account from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_effects_for_account`](crate::horizon_client::HorizonClient::get_effects_for_account) +/// method. +/// pub mod effects_for_account_request; + +/// Provides the `EffectsForLedgerRequest`. +/// +/// This module provides the `EffectsForLedgerRequest` struct, specifically designed for +/// constructing requests to query information about effects of a ledger from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_effects_for_ledger`](crate::horizon_client::HorizonClient::get_effects_for_ledger) +/// method. +/// pub mod effects_for_ledger_request; + +/// Provides the `EffectsForLiquidityPoolRequest`. +/// +/// This module provides the `EffectsForLiquidityPoolRequest` struct, specifically designed for +/// constructing requests to query information about effects referencing a given liquidity pool from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_effects_for_liquidity_pools`](crate::horizon_client::HorizonClient::get_effects_for_liquidity_pools) +/// method. +/// pub mod effects_for_liquidity_pools_request; + +/// Provides the `EffectsForOperationRequest`. +/// +/// This module provides the `EffectsForOperationRequest` struct, specifically designed for +/// constructing requests to query information about effects of a specific operation from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_effects_for_operation`](crate::horizon_client::HorizonClient::get_effects_for_operation) +/// method. +/// pub mod effects_for_operation_request; + +/// Provides the `EffectsForTransactionRequest`. +/// +/// This module provides the `EffectsForTransactionRequest` struct, specifically designed for +/// constructing requests to query information about effects of a specific transaction from the Horizon +/// server. It is tailored for use with the [`HorizonClient::get_effects_for_transaction`](crate::horizon_client::HorizonClient::get_effects_for_transaction) +/// method. +/// pub mod effects_for_transaction_request; + +/// Provides the responses. +/// +/// This module defines structures representing the response from the Horizon API when querying +/// for effects. The structures are designed to deserialize the JSON response into Rust +/// objects, enabling straightforward access to various details of a single Stellar account. +/// +/// These structures are equipped with serialization capabilities to handle the JSON data from the +/// Horizon server and with getter methods for easy field access. +/// pub mod response; +/// The base path for effect-related endpoints in the Horizon API. +/// +/// # Usage +/// This variable is intended to be used internally by the request-building logic +/// to ensure consistent and accurate path construction for effect-related API calls. +/// static EFFECTS_PATH: &str = "effects"; +/// The `prelude` module of the `effects` module. +/// +/// This module serves as a convenience for users of the Horizon Rust SDK, allowing for easy and +/// ergonomic import of the most commonly used items across various modules. It re-exports +/// key structs and traits from the sibling modules, simplifying access to these components +/// when using the library. +/// +/// By importing the contents of `prelude`, users can conveniently access the primary +/// functionalities of the effect-related modules without needing to import each item +/// individually. +/// +/// # Contents +/// +/// The `prelude` includes the following re-exports: +/// +/// * From `all_effects_request`: All items (e.g. `AllEffectsRequest`). +/// * From `effects_for_account_request`: All items (e.g. `EffectsForAccountRequest`). +/// * From `effects_for_ledger_request`: All items (e.g. `EffectsForLedgerRequest`). +/// * From `effects_for_liquidity_pools_request`: All items (e.g. `EffectsForLiquidityPoolRequest`). +/// * From `effects_for_operation_request`: All items (e.g. `EffectsForOperationRequest`). +/// * From `effects_for_transaction_request`: All items (e.g. `EffectForTransactionRequest`). +/// * From `response`: All items (e.g. `EffectsResponse`, `Effect`, `EffectLink`). +/// +/// # Example +/// ``` +/// # use crate::stellar_rs::models::*; +/// // Import the contents of the effects prelude. +/// use stellar_rs::effects::prelude::*; +/// +/// // Now you can directly use AllEffectsRequest, EffectsForAccountRequest, etc. +/// let all_effects_request = AllEffectsRequest::new(); +/// ``` +/// pub mod prelude { pub use super::all_effects_request::*; pub use super::effects_for_account_request::*; From 082e2caab073ee91a6580e34df34af76875865ac Mon Sep 17 00:00:00 2001 From: Kevin Pease Date: Tue, 4 Jun 2024 13:25:04 +0200 Subject: [PATCH 2/2] Update test values --- stellar_rust_sdk/src/offers/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stellar_rust_sdk/src/offers/mod.rs b/stellar_rust_sdk/src/offers/mod.rs index ff85897..e752283 100644 --- a/stellar_rust_sdk/src/offers/mod.rs +++ b/stellar_rust_sdk/src/offers/mod.rs @@ -190,12 +190,12 @@ pub mod test { const BUYING_ASSET_TYPE: &str = "credit_alphanum12"; const BUYING_ASSET_CODE: &str = "EURCAllow"; const BUYING_ASSET_ISSUER: &str = "GA6HVGLFUF3BHHGR5CMYXIVZ3RYVUH5EUYAOAY4T3OKI5OQVIWVRK24R"; - const AMOUNT: &str = "922278138224.9775807"; + const AMOUNT: &str = "922274722883.0675807"; const PRICE_R_N: &u32 = &1; const PRICE_R_D: &u32 = &1; const PRICE: &str = "1.0000000"; - const LAST_MODIFIED_LEDGER: &u32 = &1762248; - const LAST_MODIFIED_TIME: &str = "2024-05-23T22:12:07Z"; + const LAST_MODIFIED_LEDGER: &u32 = &1938375; + const LAST_MODIFIED_TIME: &str = "2024-06-03T15:21:13Z"; let horizon_client = HorizonClient::new("https://horizon-testnet.stellar.org"