cbe_program/sysvar/fees.rs
1//! Current cluster fees.
2//!
3//! The _fees sysvar_ provides access to the [`Fees`] type, which contains the
4//! current [`FeeCalculator`].
5//!
6//! [`Fees`] implements [`Sysvar::get`] and can be loaded efficiently without
7//! passing the sysvar account ID to the program.
8//!
9//! This sysvar is deprecated and will not be available in the future.
10//! Transaction fees should be determined with the [`getFeeForMessage`] RPC
11//! method. For additional context see the [Comprehensive Compute Fees
12//! proposal][ccf].
13//!
14//! [`getFeeForMessage`]: https://docs.cartallum.com/developing/clients/jsonrpc-api#getfeeformessage
15//! [ccf]: https://docs.cartallum.com/proposals/comprehensive-compute-fees
16//!
17//! See also the Cartallum CBE [documentation on the fees sysvar][sdoc].
18//!
19//! [sdoc]: https://docs.cartallum.com/developing/runtime-facilities/sysvars#fees
20
21#![allow(deprecated)]
22
23use {
24 crate::{
25 fee_calculator::FeeCalculator, impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar,
26 },
27 cbe_sdk_macro::CloneZeroed,
28};
29
30crate::declare_deprecated_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees);
31
32/// Transaction fees.
33#[deprecated(
34 since = "1.9.0",
35 note = "Please do not use, will no longer be available in the future"
36)]
37#[repr(C)]
38#[derive(Serialize, Deserialize, Debug, CloneZeroed, Default, PartialEq, Eq)]
39pub struct Fees {
40 pub fee_calculator: FeeCalculator,
41}
42
43impl Fees {
44 pub fn new(fee_calculator: &FeeCalculator) -> Self {
45 #[allow(deprecated)]
46 Self {
47 fee_calculator: *fee_calculator,
48 }
49 }
50}
51
52impl Sysvar for Fees {
53 impl_sysvar_get!(cbe_get_fees_sysvar);
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_clone() {
62 let fees = Fees {
63 fee_calculator: FeeCalculator {
64 scoobies_per_signature: 1,
65 },
66 };
67 let cloned_fees = fees.clone();
68 assert_eq!(cloned_fees, fees);
69 }
70}