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
113
114
115
116
117
118
119
120
121
122
123
124
use amount::{Amount, Price};
use asset::Asset;
use crypto::PublicKey;

/// Create and fund a new account.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CreateAccountOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// New account id.
    pub destination: PublicKey,
    /// Amount (in XLM) the account should be funded for. Must be greater than
    /// the [reserve balance amount](https://www.stellar.org/developers/guides/concepts/fees.html)
    pub balance: Amount,
}

/// Payment operation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PaymentOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// The destination account id.
    pub destination: PublicKey,
    /// The asset to send.
    pub asset: Asset,
    /// The amount to send.
    pub amount: Amount,
}

/// Send the specified asset to the destination account, optionally through a path.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PathPaymentOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// The destination account id.
    pub destination: PublicKey,
    /// The asset to pay with.
    pub send_asset: Asset,
    /// The maximum amount of send_asset to send.
    pub send_max: Amount,
    /// The asset the destination will receive.
    pub dest_asset: Asset,
    /// The amount the destination receives.
    pub dest_amount: Amount,
    /// The assets path.
    pub path: Vec<Asset>,
}

/// Create, update, or delete an offer.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ManageOfferOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// What you're selling.
    pub selling: Asset,
    /// What you're buying.
    pub buying: Asset,
    /// The total amount you're selling. If 0, deletes the offer.
    pub amount: Amount,
    /// The exchange rate ratio.
    pub price: Price,
    /// Offer id. If 0, creates a new offer.
    pub offer_id: u64,
}

/// Create a passive offer.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CreatePassiveOfferOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// What you're selling.
    pub selling: Asset,
    /// What you're buying.
    pub buying: Asset,
    /// The total amount you're selling. If 0, deletes the offer.
    pub amount: Amount,
    /// The exchange rate ratio.
    pub price: Price,
}

/// Add data entry to the ledger.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ManageDataOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
    /// The key of the data entry
    pub name: String,
    /// The value of the data entry. A value of `None` will delete the entry.
    pub value: Option<Vec<u8>>,
}

/// Generate inflation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InflationOperation {
    /// The source account for the operation.
    pub source: Option<PublicKey>,
}

/// An operation that mutates the ledger.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Operation {
    /// Create new account.
    CreateAccount(CreateAccountOperation),
    /// Send payment.
    Payment(PaymentOperation),
    /// Send specified payment to account, optionally through path.
    PathPayment(PathPaymentOperation),
    /// Create, update, and delete offer.
    ManageOffer(ManageOfferOperation),
    /// Create an offer that won't consume a counter offer.
    CreatePassiveOffer(CreatePassiveOfferOperation),
    /// Set or clear account flags.
    SetOptions,
    /// Add, update, or remove a trust line.
    ChangeTrust,
    /// Allow another account to hold the account credit for an asset.
    AllowTrust,
    /// Transfer balance to destination account.
    AccountMerge,
    /// Generate inflation.
    Inflation(InflationOperation),
    /// Add, update, or remove account data.
    ManageData(ManageDataOperation),
}