solana_program/sysvar/
fees.rs

1//! This account contains the current cluster fees
2//!
3#![allow(deprecated)]
4
5use {
6    crate::{
7        clone_zeroed, copy_field, fee_calculator::FeeCalculator, impl_sysvar_get,
8        program_error::ProgramError, sysvar::Sysvar,
9    },
10    std::mem::MaybeUninit,
11};
12
13crate::declare_deprecated_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
14
15#[deprecated(
16    since = "1.9.0",
17    note = "Please do not use, will no longer be available in the future"
18)]
19#[repr(C)]
20#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
21pub struct Fees {
22    pub fee_calculator: FeeCalculator,
23}
24
25impl Clone for Fees {
26    fn clone(&self) -> Self {
27        clone_zeroed(|cloned: &mut MaybeUninit<Self>| {
28            let ptr = cloned.as_mut_ptr();
29            unsafe {
30                copy_field!(ptr, self, fee_calculator);
31            }
32        })
33    }
34}
35
36impl Fees {
37    pub fn new(fee_calculator: &FeeCalculator) -> Self {
38        #[allow(deprecated)]
39        Self {
40            fee_calculator: *fee_calculator,
41        }
42    }
43}
44
45impl Sysvar for Fees {
46    impl_sysvar_get!(sol_get_fees_sysvar);
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_clone() {
55        let fees = Fees {
56            fee_calculator: FeeCalculator {
57                lamports_per_signature: 1,
58            },
59        };
60        let cloned_fees = fees.clone();
61        assert_eq!(cloned_fees, fees);
62    }
63}