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
use crate::{ types::{AllowTrustOp, OperationBody}, AssetCode, IntoAccountId, Operation, StellarSdkError, TrustLineFlags, }; impl Operation { pub fn new_allow_trust<T: IntoAccountId, S: AsRef<[u8]>>( trustor: T, asset_code: S, authorize: Option<TrustLineFlags>, ) -> Result<Operation, StellarSdkError> { let authorize: u32 = match authorize { Some(authorize) => match authorize { TrustLineFlags::TrustlineClawbackEnabledFlag => { return Err(StellarSdkError::InvalidAuthorizeFlag) } _ => authorize as u32, }, None => 0, }; Ok(Operation { source_account: None, body: OperationBody::AllowTrust(AllowTrustOp { trustor: trustor.into_account_id()?, asset: AssetCode::new(asset_code)?, authorize, }), }) } }