From f6285bbe27330498adea8deb2c14d1e968aceae8 Mon Sep 17 00:00:00 2001 From: Evan <0xIchigo@protonmail.com> Date: Sat, 4 May 2024 12:08:18 -0400 Subject: [PATCH] Update Documentation --- README.md | 50 +++++++++++++------------- src/enhanced_transactions.rs | 8 ++++- src/rpc_client.rs | 4 +-- src/utils/deserialize_str_to_number.rs | 8 +++++ src/utils/is_valid_solana_address.rs | 10 +++++- 5 files changed, 51 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index ceb8814..779f9cd 100644 --- a/README.md +++ b/README.md @@ -67,32 +67,32 @@ If you encounter any of these errors, refer to the Helius documentation for furt ## Using the Helius SDK Our SDK is designed to provide a seamless developer experience when building on Solana. We've separated the core functionality into various segments: -DAS API -- [get_asset](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset) -- [get_asset_batch](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset/get-asset-batch) -- [get_asset_proof](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset-proof) -- [get_asset_proof_batch](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset-proof/get-asset-proof-batch) -- [get_assets_by_owner](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-owner) -- [get_assets_by_authority](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-authority) -- [get_assets_by_creator](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-creator) -- [get_assets_by_group](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-group) -- [search_assets](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/search-assets) -- [get_signatures_for_asset](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-signatures-for-asset) -- [get_token_accounts](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-token-accounts) -- [get_nft_edition](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-nft-editions) -- [get_rwa_asset](https://github.com/helius-labs/helius-sdk/pull/71) - -Mint API -- [mint_compressed_nft](https://docs.helius.dev/compression-and-das-api/mint-api/mint-compressed-nft) +### DAS API +- [`get_asset`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset) - Gets an asset by its ID +- [`get_asset_batch`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset/get-asset-batch) - Gets multiple assets by their ID +- [`get_asset_proof`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset-proof) - Gets a merkle proof for a compressed asset by its ID +- [`get_asset_proof_batch`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset-proof/get-asset-proof-batch) - Gets multiple asset proofs by their IDs +- [`get_assets_by_owner`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-owner) - Gets a list of assets owned by a given address +- [`get_assets_by_authority`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-authority) - Gets a list of assets of a given authority +- [`get_assets_by_creator`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-creator) - Gets a list of assets of a given creator +- [`get_assets_by_group`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-assets-by-group) - Gets a list of assets by a group key and value +- [`search_assets`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/search-assets) - Gets assets based on the custom search criteria passed in +- [`get_signatures_for_asset`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-signatures-for-asset) - Gets transaction signatures for a given asset +- [`get_token_accounts`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-token-accounts) - Gets information about all token accounts for a specific mint or owner +- [`get_nft_edition`](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-nft-editions) - Gets all the NFT editions associated with a specific master NFT +- [`get_rwa_asset`](https://github.com/helius-labs/helius-sdk/pull/71) - Gets a Real-World Asset (RWA) based on its mint address + +### Mint API +- [`mint_compressed_nft`](https://docs.helius.dev/compression-and-das-api/mint-api/mint-compressed-nft) - The easiest way to mint a compressed NFT (cNFT) Enhanced Transactions API -- [parse_transactions](https://docs.helius.dev/solana-apis/enhanced-transactions-api/parse-transaction-s) -- [parsed_transaction_history](https://docs.helius.dev/solana-apis/enhanced-transactions-api/parsed-transaction-history) +- [`parse_transactions`](https://docs.helius.dev/solana-apis/enhanced-transactions-api/parse-transaction-s) - Parses transactions given an array of transaction IDs +- [`parsed_transaction_history`](https://docs.helius.dev/solana-apis/enhanced-transactions-api/parsed-transaction-history) - Retrieves a parsed transaction history for a specific address -Webhooks +### Webhooks -Helper Methods -- [get_priority_fee_estimate](https://docs.helius.dev/solana-rpc-nodes/alpha-priority-fee-api) -- [deserialize_str_to_number](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/deserialize_str_to_number.rs) -- [is_valid_solana_address](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/is_valid_solana_address.rs) -- [make_keypairs](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/make_keypairs.rs) \ No newline at end of file +### 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` +- [`is_valid_solana_address`](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/is_valid_solana_address.rs) - Returns whether a given string slice is a valid Solana address +- [`make_keypairs`](https://github.com/helius-labs/helius-rust-sdk/blob/dev/src/utils/make_keypairs.rs) - Generates a specified number of keypairs \ No newline at end of file diff --git a/src/enhanced_transactions.rs b/src/enhanced_transactions.rs index 0c7adcf..a67d047 100644 --- a/src/enhanced_transactions.rs +++ b/src/enhanced_transactions.rs @@ -27,7 +27,13 @@ impl Helius { .await } - /// Retrieves parsed transaction history for a specific address + /// Retrieves a parsed transaction history for a specific address + /// + /// # Arguments + /// * `address` - An address for which a given parsed transaction history will be retrieved + /// + /// # Returns + /// A `Result` wrapping a vector of `EnhancedTransaction`s pub async fn parsed_transaction_history(&self, address: &str) -> Result> { let url: String = format!( "{}v0/addresses/{}/transactions?api-key={}", diff --git a/src/rpc_client.rs b/src/rpc_client.rs index 43c333b..4e27f9f 100644 --- a/src/rpc_client.rs +++ b/src/rpc_client.rs @@ -208,7 +208,7 @@ impl RpcClient { self.post_rpc_request("getSignaturesForAsset", request).await } - /// Gets transaction signatures for a given asset + /// Gets information about all token accounts for a specific mint or owner /// /// # Arguments /// * `request` - A struct that includes the owner or mint address, along with optional sorting, pagination, and display options @@ -230,7 +230,7 @@ impl RpcClient { self.post_rpc_request("getNftEditions", request).await } - /// Gets an estimate of the priority fees required for a transaction to be processed more quicklGetPriorityFeeEstimateRequest + /// Gets an estimate of the priority fees required for a transaction to be processed more quickly /// /// This method calculates varying levels of transaction fees that can influence the priority of a transaction, based on current network conditions /// diff --git a/src/utils/deserialize_str_to_number.rs b/src/utils/deserialize_str_to_number.rs index 15ba575..cd65cb5 100644 --- a/src/utils/deserialize_str_to_number.rs +++ b/src/utils/deserialize_str_to_number.rs @@ -3,6 +3,14 @@ use serde::{Deserialize, Deserializer}; use serde_json::{Number, Value}; /// Deserializes a `String` to a `Number` +/// +/// # Arguments +/// * `deserializer` - The deserializer instance from which to read the JSON value +/// +/// # Returns a `Result` that is: +/// - `Ok(Number)` when the input is either a valid `Number` string or a JSON `Number` +/// - `Err(D::Error)` when there's an error from the deserializer if the input is neither a stringified number nor a direct `Number`, +/// or if the `String` cannot be parsed into a `Number` pub fn deserialize_str_to_number<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/utils/is_valid_solana_address.rs b/src/utils/is_valid_solana_address.rs index 75f431d..4c5fe7a 100644 --- a/src/utils/is_valid_solana_address.rs +++ b/src/utils/is_valid_solana_address.rs @@ -1,7 +1,15 @@ use solana_sdk::pubkey::Pubkey; use std::str::FromStr; -/// Returns whether a given string slice is a valid Solana address +/// Checks whether a given string slice is a valid Solana address +/// +/// # Arguments +/// * `address` - A string slice representing an address to validate +/// +/// # Returns +/// `true` if the input is a valid Solana address based on the following criteria: +/// - Have a length between 32 and 44 characters, inclusive +/// - Be parsable as a Solana 'Pubkey` without any errors pub fn is_valid_solana_address(address: &str) -> bool { address.len() >= 32 && address.len() <= 44 && Pubkey::from_str(address).is_ok() }