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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;
/// Operation is an XDR Struct defined as:
///
/// ```text
/// struct Operation
/// {
/// // sourceAccount is the account used to run the operation
/// // if not set, the runtime defaults to "sourceAccount" specified at
/// // the transaction level
/// MuxedAccount* sourceAccount;
///
/// union switch (OperationType type)
/// {
/// case CREATE_ACCOUNT:
/// CreateAccountOp createAccountOp;
/// case PAYMENT:
/// PaymentOp paymentOp;
/// case PATH_PAYMENT_STRICT_RECEIVE:
/// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp;
/// case MANAGE_SELL_OFFER:
/// ManageSellOfferOp manageSellOfferOp;
/// case CREATE_PASSIVE_SELL_OFFER:
/// CreatePassiveSellOfferOp createPassiveSellOfferOp;
/// case SET_OPTIONS:
/// SetOptionsOp setOptionsOp;
/// case CHANGE_TRUST:
/// ChangeTrustOp changeTrustOp;
/// case ALLOW_TRUST:
/// AllowTrustOp allowTrustOp;
/// case ACCOUNT_MERGE:
/// MuxedAccount destination;
/// case INFLATION:
/// void;
/// case MANAGE_DATA:
/// ManageDataOp manageDataOp;
/// case BUMP_SEQUENCE:
/// BumpSequenceOp bumpSequenceOp;
/// case MANAGE_BUY_OFFER:
/// ManageBuyOfferOp manageBuyOfferOp;
/// case PATH_PAYMENT_STRICT_SEND:
/// PathPaymentStrictSendOp pathPaymentStrictSendOp;
/// case CREATE_CLAIMABLE_BALANCE:
/// CreateClaimableBalanceOp createClaimableBalanceOp;
/// case CLAIM_CLAIMABLE_BALANCE:
/// ClaimClaimableBalanceOp claimClaimableBalanceOp;
/// case BEGIN_SPONSORING_FUTURE_RESERVES:
/// BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp;
/// case END_SPONSORING_FUTURE_RESERVES:
/// void;
/// case REVOKE_SPONSORSHIP:
/// RevokeSponsorshipOp revokeSponsorshipOp;
/// case CLAWBACK:
/// ClawbackOp clawbackOp;
/// case CLAWBACK_CLAIMABLE_BALANCE:
/// ClawbackClaimableBalanceOp clawbackClaimableBalanceOp;
/// case SET_TRUST_LINE_FLAGS:
/// SetTrustLineFlagsOp setTrustLineFlagsOp;
/// case LIQUIDITY_POOL_DEPOSIT:
/// LiquidityPoolDepositOp liquidityPoolDepositOp;
/// case LIQUIDITY_POOL_WITHDRAW:
/// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp;
/// case INVOKE_HOST_FUNCTION:
/// InvokeHostFunctionOp invokeHostFunctionOp;
/// case EXTEND_FOOTPRINT_TTL:
/// ExtendFootprintTTLOp extendFootprintTTLOp;
/// case RESTORE_FOOTPRINT:
/// RestoreFootprintOp restoreFootprintOp;
/// }
/// body;
/// };
/// ```
///
#[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 Operation {
pub source_account: Option<MuxedAccount>,
pub body: OperationBody,
}
impl ReadXdr for Operation {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
source_account: Option::<MuxedAccount>::read_xdr(r)?,
body: OperationBody::read_xdr(r)?,
})
})
}
}
impl WriteXdr for Operation {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.source_account.write_xdr(w)?;
self.body.write_xdr(w)?;
Ok(())
})
}
}