substrate_stellar_sdk/xdr/impls/operations/
path_payment_strict_receive.rs1use sp_std::vec::Vec;
2
3use crate::{
4 compound_types::LimitedVarArray,
5 types::{OperationBody, PathPaymentStrictReceiveOp},
6 Asset, IntoAmount, IntoMuxedAccountId, Operation, StellarSdkError,
7};
8
9impl Operation {
10 pub fn new_path_payment_strict_receive<S: IntoAmount, U: IntoAmount, V: IntoMuxedAccountId>(
11 send_asset: Asset,
12 send_max: S,
13 destination: V,
14 dest_asset: Asset,
15 dest_amount: U,
16 path: Option<Vec<Asset>>,
17 ) -> Result<Operation, StellarSdkError> {
18 let path = match path {
19 Some(path) => LimitedVarArray::new(path)?,
20 None => LimitedVarArray::new_empty(),
21 };
22
23 Ok(Operation {
24 source_account: None,
25 body: OperationBody::PathPaymentStrictReceive(PathPaymentStrictReceiveOp {
26 send_asset,
27 send_max: send_max.into_stroop_amount(false)?,
28 destination: destination.into_muxed_account_id()?,
29 dest_asset,
30 dest_amount: dest_amount.into_stroop_amount(false)?,
31 path,
32 }),
33 })
34 }
35}