stellar_xdr/generated/soroban_transaction_meta_ext_v1.rs
1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// SorobanTransactionMetaExtV1 is an XDR Struct defined as:
5///
6/// ```text
7/// struct SorobanTransactionMetaExtV1
8/// {
9/// ExtensionPoint ext;
10///
11/// // The following are the components of the overall Soroban resource fee
12/// // charged for the transaction.
13/// // The following relation holds:
14/// // `resourceFeeCharged = totalNonRefundableResourceFeeCharged + totalRefundableResourceFeeCharged`
15/// // where `resourceFeeCharged` is the overall fee charged for the
16/// // transaction. Also, `resourceFeeCharged` <= `sorobanData.resourceFee`
17/// // i.e.we never charge more than the declared resource fee.
18/// // The inclusion fee for charged the Soroban transaction can be found using
19/// // the following equation:
20/// // `result.feeCharged = resourceFeeCharged + inclusionFeeCharged`.
21///
22/// // Total amount (in stroops) that has been charged for non-refundable
23/// // Soroban resources.
24/// // Non-refundable resources are charged based on the usage declared in
25/// // the transaction envelope (such as `instructions`, `readBytes` etc.) and
26/// // is charged regardless of the success of the transaction.
27/// int64 totalNonRefundableResourceFeeCharged;
28/// // Total amount (in stroops) that has been charged for refundable
29/// // Soroban resource fees.
30/// // Currently this comprises the rent fee (`rentFeeCharged`) and the
31/// // fee for the events and return value.
32/// // Refundable resources are charged based on the actual resources usage.
33/// // Since currently refundable resources are only used for the successful
34/// // transactions, this will be `0` for failed transactions.
35/// int64 totalRefundableResourceFeeCharged;
36/// // Amount (in stroops) that has been charged for rent.
37/// // This is a part of `totalNonRefundableResourceFeeCharged`.
38/// int64 rentFeeCharged;
39/// };
40/// ```
41///
42#[cfg_attr(feature = "alloc", derive(Default))]
43#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
44#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
45#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
46#[cfg_attr(
47 all(feature = "serde", feature = "alloc"),
48 serde_with::serde_as,
49 derive(serde::Serialize, serde::Deserialize),
50 serde(rename_all = "snake_case")
51)]
52#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
53pub struct SorobanTransactionMetaExtV1 {
54 pub ext: ExtensionPoint,
55 #[cfg_attr(
56 all(feature = "serde", feature = "alloc"),
57 serde_as(as = "NumberOrString")
58 )]
59 pub total_non_refundable_resource_fee_charged: i64,
60 #[cfg_attr(
61 all(feature = "serde", feature = "alloc"),
62 serde_as(as = "NumberOrString")
63 )]
64 pub total_refundable_resource_fee_charged: i64,
65 #[cfg_attr(
66 all(feature = "serde", feature = "alloc"),
67 serde_as(as = "NumberOrString")
68 )]
69 pub rent_fee_charged: i64,
70}
71
72impl ReadXdr for SorobanTransactionMetaExtV1 {
73 #[cfg(feature = "std")]
74 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
75 r.with_limited_depth(|r| {
76 Ok(Self {
77 ext: ExtensionPoint::read_xdr(r)?,
78 total_non_refundable_resource_fee_charged: i64::read_xdr(r)?,
79 total_refundable_resource_fee_charged: i64::read_xdr(r)?,
80 rent_fee_charged: i64::read_xdr(r)?,
81 })
82 })
83 }
84}
85
86impl WriteXdr for SorobanTransactionMetaExtV1 {
87 #[cfg(feature = "std")]
88 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
89 w.with_limited_depth(|w| {
90 self.ext.write_xdr(w)?;
91 self.total_non_refundable_resource_fee_charged
92 .write_xdr(w)?;
93 self.total_refundable_resource_fee_charged.write_xdr(w)?;
94 self.rent_fee_charged.write_xdr(w)?;
95 Ok(())
96 })
97 }
98}