substrate_stellar_sdk/xdr/impls/operations/
set_trust_line_flags.rs1use sp_std::vec::Vec;
2
3use crate::{
4 types::{OperationBody, SetTrustLineFlagsOp},
5 Asset, IntoAccountId, Operation, StellarSdkError, TrustLineFlags,
6};
7
8impl Operation {
9 pub fn new_set_trustline_flags<T: IntoAccountId>(
10 trustor: T,
11 asset: Asset,
12 clear_flags: Vec<TrustLineFlags>,
13 set_flags: Vec<TrustLineFlags>,
14 ) -> Result<Operation, StellarSdkError> {
15 let clear_flags = clear_flags.iter().fold(0, |a, b| a | (*b as u32));
16 let set_flags = set_flags.iter().fold(0, |a, b| a | (*b as u32));
17
18 Ok(Operation {
19 source_account: None,
20 body: OperationBody::SetTrustLineFlags(SetTrustLineFlagsOp {
21 trustor: trustor.into_account_id()?,
22 asset,
23 clear_flags,
24 set_flags,
25 }),
26 })
27 }
28}