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
use crate::{
    types::{ChangeTrustOp, OperationBody},
    Asset, IntoAmount, Operation, StellarSdkError,
};

impl Operation {
    pub fn new_change_trust(line: Asset) -> Result<Operation, StellarSdkError> {
        Ok(Operation {
            source_account: None,
            body: OperationBody::ChangeTrust(ChangeTrustOp {
                line,
                limit: i64::MAX,
            }),
        })
    }

    pub fn new_change_trust_with_limit<T: IntoAmount>(
        line: Asset,
        limit: T,
    ) -> Result<Operation, StellarSdkError> {
        Ok(Operation {
            source_account: None,
            body: OperationBody::ChangeTrust(ChangeTrustOp {
                line,
                limit: limit.into_stroop_amount(true)?,
            }),
        })
    }
}