-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use elements from helius-sdk for send logic
rm helius error rm unused code add get_priority_fee_estimate wip
- Loading branch information
1 parent
a92f42d
commit 287a29f
Showing
12 changed files
with
524 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
use std::time::Duration; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use solana_sdk::{address_lookup_table::AddressLookupTableAccount, instruction::Instruction}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
pub struct MicroLamportPriorityFeeLevels { | ||
pub min: f64, | ||
pub low: f64, | ||
pub medium: f64, | ||
pub high: f64, | ||
#[serde(rename = "veryHigh")] | ||
pub very_high: f64, | ||
#[serde(rename = "unsafeMax")] | ||
pub unsafe_max: f64, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum PriorityLevel { | ||
Min, | ||
Low, | ||
Medium, | ||
High, | ||
VeryHigh, | ||
UnsafeMax, | ||
Default, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum UiTransactionEncoding { | ||
Binary, | ||
Base64, | ||
Base58, | ||
Json, | ||
JsonParsed, | ||
} | ||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)] | ||
pub struct RpcRequest<T> { | ||
pub jsonrpc: String, | ||
pub id: String, | ||
pub method: String, | ||
#[serde(rename = "params")] | ||
pub parameters: T, | ||
} | ||
|
||
impl<T> RpcRequest<T> { | ||
pub fn new(method: String, parameters: T) -> Self { | ||
Self { | ||
jsonrpc: "2.0".to_string(), | ||
id: "1".to_string(), | ||
method, | ||
parameters, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)] | ||
pub struct RpcResponse<T> { | ||
pub jsonrpc: String, | ||
pub id: String, | ||
pub result: T, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct GetPriorityFeeEstimateOptions { | ||
pub priority_level: Option<PriorityLevel>, | ||
pub include_all_priority_fee_levels: Option<bool>, | ||
pub transaction_encoding: Option<UiTransactionEncoding>, | ||
pub lookback_slots: Option<u8>, | ||
pub recommended: Option<bool>, | ||
pub include_vote: Option<bool>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
pub struct GetPriorityFeeEstimateRequest { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub transaction: Option<String>, | ||
#[serde(rename = "accountKeys", skip_serializing_if = "Option::is_none")] | ||
pub account_keys: Option<Vec<String>>, | ||
pub options: Option<GetPriorityFeeEstimateOptions>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
pub struct GetPriorityFeeEstimateResponse { | ||
pub priority_fee_estimate: Option<f64>, | ||
pub priority_fee_levels: Option<MicroLamportPriorityFeeLevels>, | ||
} | ||
|
||
pub struct Timeout { | ||
pub duration: Duration, | ||
} | ||
|
||
impl Default for Timeout { | ||
fn default() -> Self { | ||
Self { | ||
duration: Duration::from_secs(60), | ||
} | ||
} | ||
} | ||
|
||
impl From<Timeout> for Duration { | ||
fn from(val: Timeout) -> Self { | ||
val.duration | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct CreateSmartTransactionSeedConfig { | ||
pub instructions: Vec<Instruction>, | ||
pub signer_seeds: Vec<[u8; 32]>, | ||
pub fee_payer_seed: Option<[u8; 32]>, | ||
pub lookup_tables: Option<Vec<AddressLookupTableAccount>>, | ||
pub priority_fee_cap: Option<u64>, | ||
} | ||
|
||
impl CreateSmartTransactionSeedConfig { | ||
pub fn new(instructions: Vec<Instruction>, signer_seeds: Vec<[u8; 32]>) -> Self { | ||
Self { | ||
instructions, | ||
signer_seeds, | ||
fee_payer_seed: None, | ||
lookup_tables: None, | ||
priority_fee_cap: None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.