diff --git a/src/rpc_client.rs b/src/rpc_client.rs index 976ec4b..8e88816 100644 --- a/src/rpc_client.rs +++ b/src/rpc_client.rs @@ -24,9 +24,7 @@ use crate::error::Result; use crate::request_handler::RequestHandler; use crate::types::types::{RpcRequest, RpcResponse}; use crate::types::{ - Asset, AssetList, AssetProof, EditionsList, GetAsset, GetAssetBatch, GetAssetProof, GetAssetProofBatch, - GetAssetSignatures, GetAssetsByAuthority, GetAssetsByCreator, GetAssetsByGroup, GetAssetsByOwner, GetNftEditions, - GetTokenAccounts, SearchAssets, TokenAccountsList, TransactionSignatureList, + Asset, AssetList, AssetProof, EditionsList, GetAsset, GetAssetBatch, GetAssetProof, GetAssetProofBatch, GetAssetSignatures, GetAssetsByAuthority, GetAssetsByCreator, GetAssetsByGroup, GetAssetsByOwner, GetNftEditions, GetPriorityFeeEstimateRequest, GetTokenAccounts, SearchAssets, TokenAccountsList, TransactionSignatureList }; use reqwest::{Client, Method, Url}; @@ -228,4 +226,15 @@ impl RpcClient { pub async fn get_nft_editions(&self, request: GetNftEditions) -> Result { self.post_rpc_request("getNftEditions", request).await } + + /// Gets an estimate of the priority fees required for a transaction to be processed more quicklGetPriorityFeeEstimateRequest + /// + /// This method calculates varying levels of transaction fees that can influence the priority of a transaction, based on current network conditions + /// + /// # Arguments + /// * `request` - A struct that includes the following: + /// `transaction` - Optionally, the serialized transaction for which the fee estimate is requested + pub async fn get_priority_fee_estimate(&self, request: GetPriorityFeeEstimateRequest) -> Result { + self.post_rpc_request("getPriorityFeeEstimate", request).await + } } diff --git a/src/types/enums.rs b/src/types/enums.rs index 112e8b9..bbf712e 100644 --- a/src/types/enums.rs +++ b/src/types/enums.rs @@ -150,3 +150,23 @@ impl MintApiAuthority { } } } + +#[derive(Serialize, Deserialize, Debug)] +pub enum PriorityLevel { + None, + Low, + Medium, + High, + VeryHigh, + UnsafeMax, + Default, +} + +#[derive(Serialize, Deserialize, Debug)] +pub enum UiTransactionEncoding { + Binary, + Base64, + Base58, + Json, + JsonParsed, +} \ No newline at end of file diff --git a/src/types/types.rs b/src/types/types.rs index 75cfeed..c048032 100644 --- a/src/types/types.rs +++ b/src/types/types.rs @@ -1,6 +1,6 @@ use super::{ enums::{AssetSortBy, AssetSortDirection, Context, Interface, OwnershipModel, RoyaltyModel, Scope, UseMethod}, - SearchAssetsOptions, SearchConditionType, TokenType, + SearchAssetsOptions, SearchConditionType, TokenType, PriorityLevel, UiTransactionEncoding }; use crate::types::{DisplayOptions, GetAssetOptions}; // use chrono::{DateTime, Utc}; @@ -768,3 +768,39 @@ pub struct MintResponse { #[serde(rename = "assetId")] pub asset_id: Option, } + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct GetPriorityFeeEstimateOptions { + priority_level: Option, + include_all_priority_fee_levels: Option, + transaction_encoding: Option, + lookback_slots: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct GetPriorityFeeEstimateRequest { + transaction: Option, + #[serde(rename = "accountKeys")] + account_keys: Option>, + options: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct MicroLamportPriorityFeeLevels { + none: f64, + low: f64, + medium: f64, + high: f64, + #[serde(rename = "veryHigh")] + very_high: f64, + #[serde(rename = "unsafeMax")] + unsafe_max: f64, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct GetPriorityFeeResponse { + priority_fee_estimate: Option, + priority_fee_levels: Option, +} \ No newline at end of file