From c34fa238239740cdd4d155f9beef11b5536c047d Mon Sep 17 00:00:00 2001 From: Evan <0xIchigo@protonmail.com> Date: Sun, 26 May 2024 00:54:36 -0400 Subject: [PATCH 1/2] Add Smart Transactions Section to README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 10b47e9..ac60744 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,11 @@ Our SDK is designed to provide a seamless developer experience when building on - [`get_webhook_by_id`](https://docs.helius.dev/webhooks-and-websockets/api-reference/get-webhook) - Gets a webhook config given a webhook ID - [`remove_addresses_from_webhook`](https://github.com/helius-labs/helius-rust-sdk/blob/bf24259e3333ae93126bb65b342c2c63e80e07a6/src/webhook.rs#L75-L105) - Removes a list of addresses from an existing webhook by its ID +### Smart Transactions +- [`get_compute_units`](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/optimized_transaction.rs#L29-L75) - Simulates a transaction to get the total compute units consumed +- [`poll_transaction_confirmation`](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/optimized_transaction.rs#L77-L112) - Polls a transaction to check whether it has been confirmed in 5 second intervals with a 15 second timeout +- [`send_smart_transaction`](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/optimized_transaction.rs#L114-L332) - Builds and sends an optimized transaction, and handles its confirmation status + ### Helper Methods - [`get_priority_fee_estimate`](https://docs.helius.dev/solana-rpc-nodes/alpha-priority-fee-api) - Gets an estimate of the priority fees required for a transaction to be processed more quickly - [`deserialize_str_to_number`](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/deserialize_str_to_number.rs) - Deserializes a `String` to a `Number` From 839910dcc932e995451aaa6599f1f49ede8fdaa7 Mon Sep 17 00:00:00 2001 From: Evan <0xIchigo@protonmail.com> Date: Sun, 26 May 2024 01:03:48 -0400 Subject: [PATCH 2/2] Add HeliusFactory Documentation --- README.md | 9 +++++++++ src/factory.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac60744..bb6f3ff 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ where `x.y.z` is your desired version. Alternatively, use `cargo add helius` to Remember to run `cargo update` regularly to fetch the latest version of the SDK. ## Usage +### `Helius` The SDK provides a [`Helius`](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/client.rs) instance that can be configured with an API key and a given Solana cluster. Developers can generate a new API key on the [Helius Developer Dashboard](https://dev.helius.xyz/dashboard/app). This instance acts as the main entry point for interacting with the SDK by providing methods to access different Solana and RPC client functionalities. The following code is an example of how to use the SDK to fetch info on [Mad Lad #8420](https://xray.helius.xyz/token/F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk?network=mainnet): ```rust use helius::error::HeliusError; @@ -52,8 +53,16 @@ async fn main() -> Result<(), HeliusError> { Ok(()) } ``` +### `HeliusFactory` +The SDK also comes equipped with `HeliusFactory`, a factory for creating instances of `Helius`. This factory allows for a centralized configuration and creation of `Helius` clients so work can be done across multiple clusters at the same time. Using a factory simplifies client code and enhances maintainability by ensuring that all `Helius` clients are configured consistently. It has the following functionality: +- A [`new` method](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/factory.rs#L21-L36) used to create a new `HeliusFactory` capable of producing `Helius` clients. Note this method does not create a `reqwest` client +- A [`with_client` method](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/factory.rs#L38-L53) used to provide a given `HeliusFactory` created with the `new` method its own `reqwest` client +- A [`create` method](https://github.com/helius-labs/helius-rust-sdk/blob/a79a751e1a064125010bdb359068a366d635d005/src/factory.rs#L55-L94) used to create multiple `Helius` clients in a thread-safe manner + +### Embedded Solana Client The `Helius` client has an embedded [Solana client](https://docs.rs/solana-client/latest/solana_client/rpc_client/struct.RpcClient.html) that can be accessed via `helius.connection().request_name()` where `request_name()` is a given [RPC method](https://docs.rs/solana-client/latest/solana_client/rpc_client/struct.RpcClient.html#implementations). A full list of all Solana RPC HTTP methods can be found [here](https://solana.com/docs/rpc/http). +### Examples More examples of how to use the SDK can be found in the [`examples`](https://github.com/helius-labs/helius-rust-sdk/tree/dev/examples) directory. ## Error Handling diff --git a/src/factory.rs b/src/factory.rs index 60ae723..76dab18 100644 --- a/src/factory.rs +++ b/src/factory.rs @@ -10,7 +10,7 @@ use reqwest::Client; /// A factory for creating instances of `Helius` /// -/// This factor allows for a centralized configuration and creation of `Helius` client so work can be done across multiple clusters at the same time. +/// This factory allows for a centralized configuration and creation of `Helius` clients so work can be done across multiple clusters at the same time. /// Using a factory simplifies client code and enhances maintainability by ensuring that all `Helius` clients are configured consistently. pub struct HeliusFactory { api_key: String, @@ -38,7 +38,7 @@ impl HeliusFactory { /// Use your own reqwest client /// /// # Arguments - /// * `client` - a [`request::Client`] + /// * `client` - a [`reqwest::Client`] /// /// # Example /// ```rust