Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(optimized_transactions): Add send_smart_transaction Functionality #29

Merged
merged 10 commits into from
May 26, 2024
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ chrono = { version = "0.4.11", features = ["serde"] }
solana-client = "1.18.12"
solana-program = "1.18.12"
serde-enum-str = "0.4.0"
bincode = "1.3.3"
base64 = "0.22.1"

[dev-dependencies]
mockito = "1.4.0"
1 change: 1 addition & 0 deletions examples/get_priority_fee_estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async fn main() -> Result<(), HeliusError> {
transaction_encoding: None,
lookback_slots: None,
recommended: None,
include_vote: None,
}),
};

Expand Down
40 changes: 40 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use reqwest::{Error as ReqwestError, StatusCode};
use serde_json::Error as SerdeJsonError;
use solana_client::client_error::ClientError;
use solana_sdk::{
message::CompileError, sanitize::SanitizeError, signature::SignerError, transaction::TransactionError,
};
use thiserror::Error;

/// Represents all possible errors returned by the `Helius` client
Expand All @@ -14,6 +18,18 @@ pub enum HeliusError {
#[error("Bad request to {path}: {text}")]
BadRequest { path: String, text: String },

/// Represents errors from the Solana client
///
/// This captures errors from the Solana client library
#[error("Solana client error: {0}")]
ClientError(#[from] ClientError),

/// Represents compile errors from the Solana SDK
///
/// This captures all compile errors thrown by the Solana SDK
#[error("Compile error: {0}")]
CompileError(#[from] CompileError),

/// Represents errors that occur internally with Helius and our servers
///
/// If the server encounters an unexpected condition that prevents it from fulfilling the request, this error is returned.
Expand Down Expand Up @@ -60,6 +76,24 @@ pub enum HeliusError {
#[error("Serialization / Deserialization error: {0}")]
SerdeJson(SerdeJsonError),

/// Represents errors from the Solana SDK for signing operations
///
/// This captures errors from the signing operations in the Solana SDK
#[error("Signer error: {0}")]
SignerError(#[from] SignerError),

/// Indicates that the transaction confirmation timed out
///
/// For polling a transaction's confirmation status
#[error("Transaction confirmation timed out with error code {code}: {text}")]
Timeout { code: StatusCode, text: String },

/// Represents transaction errors from the Solana SDK
///
/// This captures errors that occur when processing transactions
#[error("Transaction error: {0}")]
TransactionError(#[from] TransactionError),

/// Indicates the request lacked valid authentication credentials
///
/// This error is returned in response to a missing, invalid, or expired API key
Expand Down Expand Up @@ -98,5 +132,11 @@ impl From<SerdeJsonError> for HeliusError {
}
}

impl From<SanitizeError> for HeliusError {
fn from(err: SanitizeError) -> Self {
HeliusError::InvalidInput(err.to_string())
}
}

/// A handy type alias for handling results across the Helius SDK
pub type Result<T> = std::result::Result<T, HeliusError>;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod enhanced_transactions;
pub mod error;
pub mod factory;
pub mod mint_api;
pub mod optimized_transaction;
pub mod request_handler;
pub mod rpc_client;
pub mod types;
Expand Down
Loading
Loading