1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;
/// SorobanTransactionData is an XDR Struct defined as:
///
/// ```text
/// struct SorobanTransactionData
/// {
/// union switch (int v)
/// {
/// case 0:
/// void;
/// case 1:
/// SorobanResourcesExtV0 resourceExt;
/// } ext;
/// SorobanResources resources;
/// // Amount of the transaction `fee` allocated to the Soroban resource fees.
/// // The fraction of `resourceFee` corresponding to `resources` specified
/// // above is *not* refundable (i.e. fees for instructions, ledger I/O), as
/// // well as fees for the transaction size.
/// // The remaining part of the fee is refundable and the charged value is
/// // based on the actual consumption of refundable resources (events, ledger
/// // rent bumps).
/// // The `inclusionFee` used for prioritization of the transaction is defined
/// // as `tx.fee - resourceFee`.
/// int64 resourceFee;
/// };
/// ```
///
#[cfg_attr(feature = "alloc", derive(Default))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_with::serde_as,
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct SorobanTransactionData {
pub ext: SorobanTransactionDataExt,
pub resources: SorobanResources,
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_as(as = "NumberOrString")
)]
pub resource_fee: i64,
}
impl ReadXdr for SorobanTransactionData {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
ext: SorobanTransactionDataExt::read_xdr(r)?,
resources: SorobanResources::read_xdr(r)?,
resource_fee: i64::read_xdr(r)?,
})
})
}
}
impl WriteXdr for SorobanTransactionData {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.ext.write_xdr(w)?;
self.resources.write_xdr(w)?;
self.resource_fee.write_xdr(w)?;
Ok(())
})
}
}