gemachain_client/
rpc_deprecated_config.rs

1#![allow(deprecated)]
2use {
3    crate::rpc_config::{
4        EncodingConfig, RpcBlockConfig, RpcEncodingConfigWrapper, RpcTransactionConfig,
5    },
6    gemachain_sdk::{clock::Slot, commitment_config::CommitmentConfig},
7    gemachain_transaction_status::{TransactionDetails, UiTransactionEncoding},
8};
9
10#[deprecated(
11    since = "1.7.0",
12    note = "Please use RpcSignaturesForAddressConfig instead"
13)]
14#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct RpcGetConfirmedSignaturesForAddress2Config {
17    pub before: Option<String>, // Signature as base-58 string
18    pub until: Option<String>,  // Signature as base-58 string
19    pub limit: Option<usize>,
20    #[serde(flatten)]
21    pub commitment: Option<CommitmentConfig>,
22}
23
24#[deprecated(since = "1.7.0", note = "Please use RpcBlockConfig instead")]
25#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub struct RpcConfirmedBlockConfig {
28    pub encoding: Option<UiTransactionEncoding>,
29    pub transaction_details: Option<TransactionDetails>,
30    pub rewards: Option<bool>,
31    #[serde(flatten)]
32    pub commitment: Option<CommitmentConfig>,
33}
34
35impl EncodingConfig for RpcConfirmedBlockConfig {
36    fn new_with_encoding(encoding: &Option<UiTransactionEncoding>) -> Self {
37        Self {
38            encoding: *encoding,
39            ..Self::default()
40        }
41    }
42}
43
44impl RpcConfirmedBlockConfig {
45    pub fn rewards_only() -> Self {
46        Self {
47            transaction_details: Some(TransactionDetails::None),
48            ..Self::default()
49        }
50    }
51
52    pub fn rewards_with_commitment(commitment: Option<CommitmentConfig>) -> Self {
53        Self {
54            transaction_details: Some(TransactionDetails::None),
55            commitment,
56            ..Self::default()
57        }
58    }
59}
60
61impl From<RpcConfirmedBlockConfig> for RpcEncodingConfigWrapper<RpcConfirmedBlockConfig> {
62    fn from(config: RpcConfirmedBlockConfig) -> Self {
63        RpcEncodingConfigWrapper::Current(Some(config))
64    }
65}
66
67impl From<RpcConfirmedBlockConfig> for RpcBlockConfig {
68    fn from(config: RpcConfirmedBlockConfig) -> Self {
69        Self {
70            encoding: config.encoding,
71            transaction_details: config.transaction_details,
72            rewards: config.rewards,
73            commitment: config.commitment,
74        }
75    }
76}
77
78#[deprecated(since = "1.7.0", note = "Please use RpcTransactionConfig instead")]
79#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
80#[serde(rename_all = "camelCase")]
81pub struct RpcConfirmedTransactionConfig {
82    pub encoding: Option<UiTransactionEncoding>,
83    #[serde(flatten)]
84    pub commitment: Option<CommitmentConfig>,
85}
86
87impl EncodingConfig for RpcConfirmedTransactionConfig {
88    fn new_with_encoding(encoding: &Option<UiTransactionEncoding>) -> Self {
89        Self {
90            encoding: *encoding,
91            ..Self::default()
92        }
93    }
94}
95
96impl From<RpcConfirmedTransactionConfig> for RpcTransactionConfig {
97    fn from(config: RpcConfirmedTransactionConfig) -> Self {
98        Self {
99            encoding: config.encoding,
100            commitment: config.commitment,
101        }
102    }
103}
104
105#[deprecated(since = "1.7.0", note = "Please use RpcBlocksConfigWrapper instead")]
106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum RpcConfirmedBlocksConfigWrapper {
109    EndSlotOnly(Option<Slot>),
110    CommitmentOnly(Option<CommitmentConfig>),
111}
112
113impl RpcConfirmedBlocksConfigWrapper {
114    pub fn unzip(&self) -> (Option<Slot>, Option<CommitmentConfig>) {
115        match &self {
116            RpcConfirmedBlocksConfigWrapper::EndSlotOnly(end_slot) => (*end_slot, None),
117            RpcConfirmedBlocksConfigWrapper::CommitmentOnly(commitment) => (None, *commitment),
118        }
119    }
120}