shuttle_core/
operation.rs

1use amount::{Amount, Price};
2use asset::Asset;
3use crypto::PublicKey;
4
5/// Create and fund a new account.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct CreateAccountOperation {
8    /// The source account for the operation.
9    pub source: Option<PublicKey>,
10    /// New account id.
11    pub destination: PublicKey,
12    /// Amount (in XLM) the account should be funded for. Must be greater than
13    /// the [reserve balance amount](https://www.stellar.org/developers/guides/concepts/fees.html)
14    pub balance: Amount,
15}
16
17/// Payment operation.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct PaymentOperation {
20    /// The source account for the operation.
21    pub source: Option<PublicKey>,
22    /// The destination account id.
23    pub destination: PublicKey,
24    /// The asset to send.
25    pub asset: Asset,
26    /// The amount to send.
27    pub amount: Amount,
28}
29
30/// Send the specified asset to the destination account, optionally through a path.
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct PathPaymentOperation {
33    /// The source account for the operation.
34    pub source: Option<PublicKey>,
35    /// The destination account id.
36    pub destination: PublicKey,
37    /// The asset to pay with.
38    pub send_asset: Asset,
39    /// The maximum amount of send_asset to send.
40    pub send_max: Amount,
41    /// The asset the destination will receive.
42    pub dest_asset: Asset,
43    /// The amount the destination receives.
44    pub dest_amount: Amount,
45    /// The assets path.
46    pub path: Vec<Asset>,
47}
48
49/// Create, update, or delete an offer.
50#[derive(Debug, Clone, PartialEq, Eq)]
51pub struct ManageOfferOperation {
52    /// The source account for the operation.
53    pub source: Option<PublicKey>,
54    /// What you're selling.
55    pub selling: Asset,
56    /// What you're buying.
57    pub buying: Asset,
58    /// The total amount you're selling. If 0, deletes the offer.
59    pub amount: Amount,
60    /// The exchange rate ratio.
61    pub price: Price,
62    /// Offer id. If 0, creates a new offer.
63    pub offer_id: u64,
64}
65
66/// Create a passive offer.
67#[derive(Debug, Clone, PartialEq, Eq)]
68pub struct CreatePassiveOfferOperation {
69    /// The source account for the operation.
70    pub source: Option<PublicKey>,
71    /// What you're selling.
72    pub selling: Asset,
73    /// What you're buying.
74    pub buying: Asset,
75    /// The total amount you're selling. If 0, deletes the offer.
76    pub amount: Amount,
77    /// The exchange rate ratio.
78    pub price: Price,
79}
80
81/// Add data entry to the ledger.
82#[derive(Debug, Clone, PartialEq, Eq)]
83pub struct ManageDataOperation {
84    /// The source account for the operation.
85    pub source: Option<PublicKey>,
86    /// The key of the data entry
87    pub name: String,
88    /// The value of the data entry. A value of `None` will delete the entry.
89    pub value: Option<Vec<u8>>,
90}
91
92/// Generate inflation.
93#[derive(Debug, Clone, PartialEq, Eq)]
94pub struct InflationOperation {
95    /// The source account for the operation.
96    pub source: Option<PublicKey>,
97}
98
99/// An operation that mutates the ledger.
100#[derive(Debug, Clone, PartialEq, Eq)]
101pub enum Operation {
102    /// Create new account.
103    CreateAccount(CreateAccountOperation),
104    /// Send payment.
105    Payment(PaymentOperation),
106    /// Send specified payment to account, optionally through path.
107    PathPayment(PathPaymentOperation),
108    /// Create, update, and delete offer.
109    ManageOffer(ManageOfferOperation),
110    /// Create an offer that won't consume a counter offer.
111    CreatePassiveOffer(CreatePassiveOfferOperation),
112    /// Set or clear account flags.
113    SetOptions,
114    /// Add, update, or remove a trust line.
115    ChangeTrust,
116    /// Allow another account to hold the account credit for an asset.
117    AllowTrust,
118    /// Transfer balance to destination account.
119    AccountMerge,
120    /// Generate inflation.
121    Inflation(InflationOperation),
122    /// Add, update, or remove account data.
123    ManageData(ManageDataOperation),
124}