substrate_stellar_sdk/xdr/impls/operations/
manage_sell_offer.rs

1use crate::{
2    types::{ManageSellOfferOp, OperationBody},
3    Asset, IntoAmount, Operation, Price, StellarSdkError,
4};
5
6impl Operation {
7    pub fn new_manage_sell_offer<S: IntoAmount>(
8        selling: Asset,
9        buying: Asset,
10        amount: S,
11        price: Price,
12        offer_id: Option<i64>,
13    ) -> Result<Operation, StellarSdkError> {
14        Ok(Operation {
15            source_account: None,
16            body: OperationBody::ManageSellOffer(ManageSellOfferOp {
17                selling,
18                buying,
19                amount: amount.into_stroop_amount(true)?,
20                price,
21                offer_id: offer_id.unwrap_or(0),
22            }),
23        })
24    }
25}